Skip to content

Commit

Permalink
kern_copy_file_range(): handle rangelock recursion
Browse files Browse the repository at this point in the history
PR:	281073
Reviewed by:	markj
Tested by:	lwhsu
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D46465
  • Loading branch information
kostikbel committed Aug 28, 2024
1 parent 0b6b1c2 commit 4e1f29b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sys/kern/vfs_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -4978,11 +4978,13 @@ kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd,
* If infp and outfp refer to the same file, the byte ranges cannot
* overlap.
*/
if (invp == outvp && ((savinoff <= savoutoff && savinoff + len >
savoutoff) || (savinoff > savoutoff && savoutoff + len >
savinoff))) {
error = EINVAL;
goto out;
if (invp == outvp) {
if ((savinoff <= savoutoff && savinoff + len > savoutoff) ||
(savinoff > savoutoff && savoutoff + len > savinoff)) {
error = EINVAL;
goto out;
}
rangelock_may_recurse(&invp->v_rl);
}

/* Range lock the byte ranges for both invp and outvp. */
Expand Down

0 comments on commit 4e1f29b

Please sign in to comment.