diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 1a3400a87ee..7b71ffc7689 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -5075,6 +5075,15 @@ kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd, if (len == 0) goto out; + /* + * Make sure that the ranges we check and lock below are valid. Note + * that len is clamped to SSIZE_MAX above. + */ + if (inoff < 0 || outoff < 0) { + error = EINVAL; + goto out; + } + /* * If infp and outfp refer to the same file, the byte ranges cannot * overlap.