From nobody Thu Mar 2 20:59:21 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 4PSNkx5PYhz3wFy5; Thu, 2 Mar 2023 20:59:21 +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 4PSNkx4lR9z3xdS; Thu, 2 Mar 2023 20:59:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677790761; 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=xPt0gANCkYTRKldjPlWKR1PowFP/WbCD1mQUjkSCzOA=; b=AC/CEHIq5miWZb8/pmhki6lvVDIDtiHbq10bnacvrpBJFRVvqxEREPv479SY9B1+yXy89+ 0IQuJfHrnOJODt0RggFQJAsQihz7zFynOdirv/vA/M3jfPpW0jS3FwNkIjQ3WLiOsfDNmM dDcaTuAeKQlqoSLUdm/ePo7YNAZ+vvgRIwRwDN0/vC/EKFR7+zgeYqn7UlTzEQ1TUm9orY neKOgqz60elwf+/q3a7IkW8SCCP6IHm3H0DNt1kXVkJcihCsgUI5zTXgkU3dIwd/lJEbJn 0Pz/gt9UmQ1TYzwbEoHmDrcIbp5v2Ry6rnWKgatuzpIlzIvsnKkNpJHZeEJA+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677790761; 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=xPt0gANCkYTRKldjPlWKR1PowFP/WbCD1mQUjkSCzOA=; b=eL7EV+yEZb3QXqCJ8vytIDB1h7lwQcWryWxZ/Qd2Wc8iONNzzE2+uWZBjlt4f1RgrEF2dK E68qqOOdihVNuG+JDDTIxWQvbZE+zmrSQZQvGSqFN6wzfSuLclGvvak0m2C0S74uH6y2rm cBULi5vYx54ywpibGfaYg9Q1OohajFmKnPX7C6ZzyX2PAERglQBZ6mBWGsNQtswXhqWX3I JyaAoHosjRLntDh+SLLtYrGVHlHYITirhoSNr5QhjuVGzE67h3HRaNRiPSRrbGrc7ZzVs/ RUdWuRYFNQRjEGxIdkl2TZSlqE9rg2Xe0+X0/hgVE6Y0p3iidfpo63vTN/pVFA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677790761; a=rsa-sha256; cv=none; b=ejvdKyoZYayw95yszxjAV9cfBIXrIaWjwlAQfmEUccAHIAlgN86fKo7LCXgG0mq4GDl7sx QiHIPbWVq1Ydf/I/1mTYPycDaTsYS7luwt6NWshOYMGu/OV3ERTrcWvG9pWsCU05UP+/7W ulNYo7LKPZG9G0ppUsEWmKjXgOX6YtZq7m/PccWAxcmm7JcQRmh1pY/HSJRZNMywf569PX jO3rgUZxnvADAE9QPBIiPNZCbSLGpMeB2f0pZccDyje3Qw97hRYcBMkiIrxMPnLk9LDJi7 ywO86dC23aq/nDPHTwCbfLa2DcDIhiUGv8cuqrsx4gxzBOQPLYSma/nz+T2adQ== 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 4PSNkx3gqPzWDc; Thu, 2 Mar 2023 20:59:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 322KxLJF098511; Thu, 2 Mar 2023 20:59:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 322KxL1Y098510; Thu, 2 Mar 2023 20:59:21 GMT (envelope-from git) Date: Thu, 2 Mar 2023 20:59:21 GMT Message-Id: <202303022059.322KxL1Y098510@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: c7a8502bdf18 - main - open.2: describe O_RESOLVE_BENEATH errors correctly 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/main X-Git-Reftype: branch X-Git-Commit: c7a8502bdf187ccf035c5b29a93e34cc01346a73 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=c7a8502bdf187ccf035c5b29a93e34cc01346a73 commit c7a8502bdf187ccf035c5b29a93e34cc01346a73 Author: Val Packett AuthorDate: 2023-02-19 20:14:15 +0000 Commit: Ed Maste CommitDate: 2023-03-02 20:58:00 +0000 open.2: describe O_RESOLVE_BENEATH errors correctly The behavior is the same as in capability mode, it does not actually return EINVAL for absolute lookups: openat(AT_FDCWD,"/tmp/test",O_RDONLY|O_DIRECTORY,00) = 3 (0x3) openat(3,"../../",O_RDONLY|0x800000,00) ERR#93 'Capabilities insufficient' openat(3,"/etc/passwd",O_RDONLY|0x800000,00) ERR#93 'Capabilities insufficient' Fixes: 1f305be43 ("Document {O,AT}_RESOLVE_BENEATH...") Reviewed by: kib, pauamma (manpages), emaste Sponsored by: https://www.patreon.com/valpackett Pull Request: https://github.com/freebsd/freebsd-src/pull/680 Differential Revision: https://reviews.freebsd.org/D38675 --- lib/libc/sys/open.2 | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index 876a4ce1e57d..574b6b136d39 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd April 22, 2022 +.Dd March 2, 2023 .Dt OPEN 2 .Os .Sh NAME @@ -572,12 +572,6 @@ and .Dv O_EXEC or .Dv O_SEARCH . -.It Bq Er EINVAL -The -.Dv O_RESOLVE_BENEATH -flag is specified and -.Dv path -is absolute. .It Bq Er EBADF The .Fa path @@ -606,19 +600,32 @@ is specified and the process is in capability mode. was called and the process is in capability mode. .It Bq Er ENOTCAPABLE .Fa path -is an absolute path, -or contained a ".." component leading to a -directory outside of the directory hierarchy specified by -.Fa fd , +is an absolute path and the process is in capability mode. +.It Bq Er ENOTCAPABLE +.Fa path +is an absolute path and +.Dv O_RESOLVE_BENEATH +is specified. +.It Bq Er ENOTCAPABLE +.Fa path +contains a ".." component leading to a directory outside +of the directory hierarchy specified by +.Fa fd and the process is in capability mode. .It Bq Er ENOTCAPABLE -The +.Fa path +contains a ".." component leading to a directory outside +of the directory hierarchy specified by +.Fa fd +and .Dv O_RESOLVE_BENEATH -flag was provided, and the relative +is specified. +.It Bq Er ENOTCAPABLE .Fa path -escapes the -.Ar fd -directory. +contains a ".." component, the +.Dv vfs.lookup_cap_dotdot +.Xr sysctl 3 +is set, and the process is in capability mode. .El .Sh SEE ALSO .Xr chmod 2 ,