git: 902a18d50aef - stable/13 - copy_file_range(2): Fix for small values of input file offset and len

Rick Macklem rmacklem at FreeBSD.org
Wed Mar 3 14:49:19 UTC 2021


The branch stable/13 has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=902a18d50aef8775aa833dde3638356f994e28e8

commit 902a18d50aef8775aa833dde3638356f994e28e8
Author:     Rick Macklem <rmacklem at FreeBSD.org>
AuthorDate: 2021-03-01 14:28:30 +0000
Commit:     Rick Macklem <rmacklem at FreeBSD.org>
CommitDate: 2021-03-03 14:46:33 +0000

    copy_file_range(2): Fix for small values of input file offset and len
    
    r366302 broke copy_file_range(2) for small values of
    input file offset and len.
    
    It was possible for rem to be greater than len and then
    "len - rem" was a large value, since both variables are
    unsigned.
    
    (cherry picked from commit a5f9fe2bab789f49e8b53da3a62dbd34725e23ea)
---
 sys/kern/vfs_vnops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 781968f2db53..7a0951fb07ca 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -3143,7 +3143,7 @@ vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp,
 		rem = *inoffp % blksize;
 		if (rem > 0)
 			rem = blksize - rem;
-		if (len - rem > blksize)
+		if (len > rem && len - rem > blksize)
 			len = savlen = rounddown(len - rem, blksize) + rem;
 	}
 


More information about the dev-commits-src-all mailing list