Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Oct 2023 16:02:34 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 3f0ce63828dc - stable/13 - copy_file_range: require CAP_SEEK capability
Message-ID:  <202310021602.392G2YTT052396@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f0ce63828dc3d4030b32ad0effb4e588af49c03

commit 3f0ce63828dc3d4030b32ad0effb4e588af49c03
Author:     Mariusz Zaborski <oshogbo@FreeBSD.org>
AuthorDate: 2023-09-28 13:24:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-10-02 16:00:27 +0000

    copy_file_range: require CAP_SEEK capability
    
    When using copy_file_range(2) with an offset parameter,
    the CAP_SEEK capability should be required.
    This requirement is similar to the behavior observed with
    pread(2)/pwrite(2).
    
    Reported by:    theraven
    Reviewed by:    emaste, theraven, kib, markj
    Approved by:    secteam
    Differential Revision:  https://reviews.freebsd.org/D41967
    
    (cherry picked from commit 15a51d3abaef27ddea66320cac7caa549738a1a6)
---
 sys/kern/vfs_syscalls.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 594c4f5ef23a..cf733133bec0 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -4886,7 +4886,8 @@ kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd,
 		len = SSIZE_MAX;
 
 	/* Get the file structures for the file descriptors. */
-	error = fget_read(td, infd, &cap_read_rights, &infp);
+	error = fget_read(td, infd,
+	    inoffp != NULL ? &cap_pread_rights : &cap_read_rights, &infp);
 	if (error != 0)
 		goto out;
 	if (infp->f_ops == &badfileops) {
@@ -4897,7 +4898,8 @@ kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd,
 		error = EINVAL;
 		goto out;
 	}
-	error = fget_write(td, outfd, &cap_write_rights, &outfp);
+	error = fget_write(td, outfd,
+	    outoffp != NULL ? &cap_pwrite_rights : &cap_write_rights, &outfp);
 	if (error != 0)
 		goto out;
 	if (outfp->f_ops == &badfileops) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310021602.392G2YTT052396>