From nobody Mon Oct 02 08:17:18 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 4RzYhv2Fwqz4vmDC; Mon, 2 Oct 2023 08:17:19 +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 4RzYhv1dnrz4JHj; Mon, 2 Oct 2023 08:17:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696234639; 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=jzyfAB80UcPFmXz7kgpg6POlYPSV77eQ7WLuQerPxQE=; b=dOvq1D6GBtp2tRGChSiXzlVCmD5yqOrU7Z5HYrQM4OgL+b8US6/0O9gbaGK7UJ0XfUibKn Pf+v9yhRDnVuKJaFYFh31oRT3xdfgS9rDlr1+W1ngKMxdR88cha1Bx2TD/1sqUA1HJ1ptK qjJc24dgc+9kItRrxy5vpKrQjr1uLxPEzu+63DrSW7kVvX+51a5QvKCuGJDMK1UN/MxbdN EN7NYNmWVcEuKWthFgrSKDEZXE17VncBlPWg9mchmpHeoBchn2GWGP6cUogfYAc1CBCxlC uJf1g8hftbrUl7hDoU4fDET2t5woZp/jODdki04frXJJsMYwXHJWcvgdD2NoAQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696234639; a=rsa-sha256; cv=none; b=VUebLNiw7Hhh5vMWOQLjIrLlKwZDhsMwWRlUctGk10cAFlusfnSa3YPNo6vCY91RIwZ2qk P/QYx4NyfZ7LyvXK7UYCyfx5M/ZwbhvG2HhaWiTBK1A0DK+f5gv2OdOcMy55qBwESgGx94 eVpDB/pP1Q4Xgkfyj9P6APyr2uCduGAwTnrfMNlgKQbsrl4BHs0qOGMkd+zop+EbnlI97m p3bfUpqETHIRsv9ukqt064FCad9WGQUepzt6hp4mvNWrgMUgsqlxpkA+Q1y7u7QZJKoPBG qkV8rsENmefAoULko2R6gLRmMiFBwBT2IpqvW/cVC83prZOv/G6r8ERFuoNqlg== 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=1696234639; 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=jzyfAB80UcPFmXz7kgpg6POlYPSV77eQ7WLuQerPxQE=; b=vrYFf6+mlaK5xiwqDM+zME4qcq9MMUOHdIQ8emmDaTMhi1PILuyM5BxXHLjFwPH4WQUdO6 KM4xcJMaw0DXDfd8qH/j69TOjmD/MRBhA1O9uIQgQ7ZSRntUafdtZFVi9f37BcZ8cWFUt+ ZbihO5FitE5ah7SZ1R0RU1vwn7h3ZwsYdDYY5BflMKSxwwVe1iIxys/4ZXGMofqiwhya5R 6Y0OjN4rvyE6M3gtujWuS4kT3jQov/I1RKYPPhhWO00UH72qv6OcTtoH7thUaIrOudjL5e xQIXeZPozp8M+GAZr8TbQYKygxCGbL4BHnCrycg9Cz8/NznyS0e8gOGnfW2p6A== 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 4RzYhv0hJvz14H3; Mon, 2 Oct 2023 08:17:19 +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 3928HJ1U069436; Mon, 2 Oct 2023 08:17:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3928HI2G069433; Mon, 2 Oct 2023 08:17:18 GMT (envelope-from git) Date: Mon, 2 Oct 2023 08:17:18 GMT Message-Id: <202310020817.3928HI2G069433@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mariusz Zaborski Subject: git: 857ce53d1d46 - releng/14.0 - 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: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 857ce53d1d4689884b624c4ec596b1bb77843761 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=857ce53d1d4689884b624c4ec596b1bb77843761 commit 857ce53d1d4689884b624c4ec596b1bb77843761 Author: Mariusz Zaborski AuthorDate: 2023-09-28 13:24:39 +0000 Commit: Mariusz Zaborski CommitDate: 2023-10-02 08:18:07 +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) (cherry picked from commit 87d68b131ef65a0a5fb897280359e46067064a53) Approved by: re (gjb) --- 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 06b861a2eb73..9d85a295a6ef 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4899,7 +4899,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) { @@ -4910,7 +4911,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) {