kern_copy_file_range(): handle rangelock recursion

PR:	281073
Reviewed by:	markj
Tested by:	lwhsu
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D46465
This commit is contained in:
Konstantin Belousov 2024-08-28 00:34:16 +03:00
parent 0b6b1c2859
commit 4e1f29b92d

View file

@ -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. */