From nobody Mon Oct 02 16:02:34 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rzm1k3Lsjz4wDNF; Mon, 2 Oct 2023 16:02:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rzm1k2tfTz4JDq; Mon, 2 Oct 2023 16:02:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696262554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ByPDq3R3koidvE6i+l6FqlX6aNRx4UAHlebq9R3DWqA=; b=T+2mG9ERme1GGsUzHGXF/Btks88E1jUJBVmfDKXuKyMhKzYWPYhjhbc+zPuCjW3cR2Eh0a oERRI7JyKCXkHtAwiBiV16hFHoVoxjIwfAAgum+O9fcKn4zZ7NKbfaHmdIyDK6HL5Jd7EL 3+rBPT0nBJd/4LEBNBfmzrK9a8zC8Xa8FkyYoMfQsdzQJhNQadn2lpQNpsFVcRoYznwIHI +xOBt2w02r2svlz6YxJDSQ8/efW3gjrlr2Df5I+kYgRy5Ya3CQiM9I88HvorVkhXoY21hm Aq8FeJ6an4fTboWr4F0gKxcsFumEZIe/L8NaQOfFjO//kZbvSgjl2Sx98ncPwA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696262554; a=rsa-sha256; cv=none; b=TqWlH3g/anaieOJK3RbuceB1fsS9FUYSL/ig0xHz/KnB0BJQFpL86dCz7NUwuxHloKtiH1 CCZ2a7euIzKQwTTvVYL9NKFtwY3h45BP9NYnovHjk5uh/gZYUgUcoaBWWFuNpL+OkBwEvF oFXR9mBfCqfXl3QriF5HcSxKDhpf78pn7LAzNvzvxTQTb3lja41uSKnxdQKLG5qWqkIeNl IY0mKp8iCFa/b1UEihHMQjcgLaGUi1YO4E7dY1HIQgYHkn/ircYJUndIi0QvrusBFQtbwj Lct4eWc0irjCaBhBGmOSZ/BMcOq0RwcaYjJ5rvGe0HCjI5VJWUlK0y3hEL2Zxw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696262554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ByPDq3R3koidvE6i+l6FqlX6aNRx4UAHlebq9R3DWqA=; b=mh5lDnS7KFJbD0vGADhh7tx6pSfnxINZgy35g8xt+EsoE26swY2qHm8kH7zYyug0+d8BGj 4s93iBpXtDXeWk6RykyP5FqFTFc9llqF4mfnB2ALSjk3HWQCsBC1p1pBX9z0jm680iU0Nz mYZFtasG5txEhIKxjVKOoaKCA10ZxufBr8DrgoGj6lEM8l+NZlR7xUP8f80JNEh0Q/yRFw VnbnhwiM2/A7hWMgJrKiRHP048XL2hMLlWxSQcgbjwdXc/UwCBAolHQhFHZmQdJwBno/qx 7udqIme9aG0VdfUA+QMA0Sc+BFADJiVRPzs659b41JdjVJ1DC99bjJ4thO08xw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rzm1k1z0Jz45Y; Mon, 2 Oct 2023 16:02:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 392G2Ype052399; Mon, 2 Oct 2023 16:02:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 392G2YTT052396; Mon, 2 Oct 2023 16:02:34 GMT (envelope-from git) Date: Mon, 2 Oct 2023 16:02:34 GMT Message-Id: <202310021602.392G2YTT052396@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 3f0ce63828dc - stable/13 - copy_file_range: require CAP_SEEK capability List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3f0ce63828dc3d4030b32ad0effb4e588af49c03 Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=3f0ce63828dc3d4030b32ad0effb4e588af49c03 commit 3f0ce63828dc3d4030b32ad0effb4e588af49c03 Author: Mariusz Zaborski AuthorDate: 2023-09-28 13:24:39 +0000 Commit: Ed Maste 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) {