From nobody Tue Oct 03 22:13:58 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 4S0XCq1r6Tz4w4Ng; Tue, 3 Oct 2023 22:13:59 +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 4S0XCq0wBHz4rFY; Tue, 3 Oct 2023 22:13:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696371239; 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=1k9V5kW7d3YOiF6lgdMIAOfXUxC0uomfnbRIZ3nYbxY=; b=ThzNvVRqfzGEQuWwB22OpIyxwmunu+WNl8fq/Nq1G0Nd2nlLYvv+qTZbQToFnmbBtD8r5k RBrfqnjzgEdvsSjsey3dUOuwNf5wXawBIb6Xa1Nyo7uArrbHnNqee/lkOc5nd1sYe5NuKP pwMjOPGmpGhEvqUGnZuUDYjXm922zOYUPzIhbGQT1ro+qW7et7VO9myrVPPHOZAmheCoaw trQaUstcW8lu6lFsaP2ma14UQm4yXAl94kFHQeSP9DbOnOoqdbeAeWAeoGxucuww2E92os HNdlr++uUDQ7o/s0deYgerCU0rcz4A+d/sNkAjt7w6k0bKSUAMa/ltWXrg3xtA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696371239; a=rsa-sha256; cv=none; b=LaM/hfJLv+x8YOYReqQOwVGXtxmSjNyRFzy9pia+c/Da60+iIVoatnOH2KeSE2OR7rorSw pt08qNXZwpGFZIYV4aEyXuSQqtGg5a2jcfQajSzjaRGfKvKXv4JI1+I4cbwmNP/T17IXzZ eXTTY+lrNUuwRXN3oQzyZ1LCZbnlIO1GZhjcb2A6jzQ5rDzM2cpAkHTeJvQhnGxZau/u/m dASy8XIYi7Ys1J2K/fd/YZN46uEIrNDPwu7iIfvLMsHEWXo0qVm6aj2rKvLMpXgDZ4o7LR lEZ+6bqcJp9RhyHJew8ab51gFWP3Q8cz+deGCbGmn1UC0m4mOt1EtrsqXgHoSA== 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=1696371239; 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=1k9V5kW7d3YOiF6lgdMIAOfXUxC0uomfnbRIZ3nYbxY=; b=wPIkbzokatnv0axGw15mjfDCnxq4rUrF94yGfP+LBwqX5hdr/Lck9qa7RJEnRowGLMmgHO AahXQEuNbrRxy1KdBqIRbPmpyIv9MFUV8WgQqA88EgrbRyNhyt6+CimRp6IGQ8bk/+hrY7 +xfjZz9u5nxS5k+osa0Fq78yUyV6u0EMiNPFDQqUVegSrfnX7OPK58qJibM7e5FdXrc0JD MS9vwpoinAeGiUS/ouv0dP7YTJ5RU/qFlbLdINmSUQClvv0cxNuXiHeBT95VNNkHA7Pkw0 6lirDYE/PnfoNwIOnCI5T5cnPSggiC7Cmbcl940uGQgb39vqMjTQtO2X2MOr3Q== 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 4S0XCp6tZXz1Blx; Tue, 3 Oct 2023 22:13:58 +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 393MDw8E071029; Tue, 3 Oct 2023 22:13:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 393MDwGc071026; Tue, 3 Oct 2023 22:13:58 GMT (envelope-from git) Date: Tue, 3 Oct 2023 22:13:58 GMT Message-Id: <202310032213.393MDwGc071026@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 2d23f6c33431 - releng/13.2 - 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: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: 2d23f6c33431b19d8f91ad4832db01aa25062d43 Auto-Submitted: auto-generated The branch releng/13.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=2d23f6c33431b19d8f91ad4832db01aa25062d43 commit 2d23f6c33431b19d8f91ad4832db01aa25062d43 Author: Mariusz Zaborski AuthorDate: 2023-09-28 13:24:39 +0000 Commit: Gordon Tetlow CommitDate: 2023-10-03 21:24:41 +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: so Security: FreeBSD-SA-23:13.capsicum Security: CVE-2023-5369 Differential Revision: https://reviews.freebsd.org/D41967 (cherry picked from commit 15a51d3abaef27ddea66320cac7caa549738a1a6) (cherry picked from commit 3f0ce63828dc3d4030b32ad0effb4e588af49c03) --- 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 3b3947b2ccb7..449c5ace6094 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4896,7 +4896,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) { @@ -4907,7 +4908,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) {