From nobody Thu Sep 26 14:47:31 2024 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 4XDxK00zZxz5XNs2; Thu, 26 Sep 2024 14:47:32 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XDxK00TF6z4f5k; Thu, 26 Sep 2024 14:47:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727362052; 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=MJhXwBfqVrmd+8ntgpeYgdAT7tbsp4jZbcqL4wAYdpc=; b=pSLg/ifa1YTPxxKUNJ5MMCdlZ19f00Ze2M3oK0zJqTs1Ydj/EYCo25gh8DCWSTI5Zow2n8 WvSpMPt1enOMEAWaf2s2F/xueoYrxyEoXBBB2nm4kNnOeXwglz8b1JfgNJhyQUp6do+LHN 1GBJ2a+x9/7ld3zi/N6RHGAdHQMqH0leIAzrAVwLBz8XpIb49KkUY+4amMLc1ghRhus7N9 9I9Ca9pFe6cwLtwNRKpnhkoVpIueySmbPuyHtvPQEHb12xyEfVxzqeSzuQi93ge09Ly2pB csNkKHlH5Oesx9km2zahXrlHbesagIKf4kkemAUDdrRr8Z2LS9wP0PTcucfkzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727362052; 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=MJhXwBfqVrmd+8ntgpeYgdAT7tbsp4jZbcqL4wAYdpc=; b=cyr2vVWJ50RffKgNBqvat6yEUtym49UWn3dAB4xkQJfIRzBiES9iPYy/fDqTQp8T+5aJK9 0j+otB5LMXsdmSN3c0XrsDQSxysGUu5eV73hd0uTIFrAUfSTmeadN/YrGnpErVy+9XQybr uhCgHdRuHdq/W4azeTxYdgsys98U0CI8E269X9+a95MRx5Upp6lorc8l4LsgOTOTNpe+7Y 3Rjma2Mof4yUxWF9d/ihuq0JMHz5PXFGz6xAOedJjZ27EXSuneTbS7a4K+5OK/UB0KSHwp ZN9TTxwXaHu2crYUimrvhUoel7ZTQ90n/2jQLUth+gi9If506CVsTdqjaJ+TGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727362052; a=rsa-sha256; cv=none; b=gM0jPKspOzX2+JqrcI4fJi52Yjt7lXMHAVTMBB+VZN9Hz2A1SVNDj+PKOaFVp57U6kW80R 4coGRxpkmorV5nWR1OgE0P2ORC+J05Xu2j1SrxMVyoJ/728GxNJ79AKyBWHXuHELS2kItl bhkoRPOJelSnuzob4IChgL+S88rRHh7Pd12SRUgsvyZAK7gZtqC6Rn5iAzMvZy0XYeQrm7 hMckUU9rM9ihGkwAe31iLVpzuxs3zz2jBUpFoiMALuyCRmo5eD7Gija0P0TwVMf484Jykc omON9jdvQGhc4tZeV5mZ0WFkAAA+OGcXpH+2Ora8of8tUJtiX4tIdb+hqBBkOg== 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 4XDxK0002sz119K; Thu, 26 Sep 2024 14:47:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48QElVqc036936; Thu, 26 Sep 2024 14:47:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48QElVSq036933; Thu, 26 Sep 2024 14:47:31 GMT (envelope-from git) Date: Thu, 26 Sep 2024 14:47:31 GMT Message-Id: <202409261447.48QElVSq036933@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: ddbbc129ae0f - stable/14 - faccessat(2): Honor AT_SYMLINK_NOFOLLOW 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/14 X-Git-Reftype: branch X-Git-Commit: ddbbc129ae0fc35cef2834b308097ae1490176e3 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ddbbc129ae0fc35cef2834b308097ae1490176e3 commit ddbbc129ae0fc35cef2834b308097ae1490176e3 Author: Fernando ApesteguĂ­a AuthorDate: 2024-08-11 15:43:04 +0000 Commit: Ed Maste CommitDate: 2024-09-26 13:13:50 +0000 faccessat(2): Honor AT_SYMLINK_NOFOLLOW Make the system call honor `AT_SYMLINK_NOFOLLOW`. Also enable this from `linux_faccessat2` where the issue arised the first time. Update manual pages accordingly. PR: 275295 Reported by: kenrap@kennethraplee.com Approved by: kib@ Differential Revision: https://reviews.freebsd.org/D46267 (cherry picked from commit 5ab6ed93cd3680f8b69dd4d05823f4740a2bdef9) --- bin/ln/symlink.7 | 5 ++--- lib/libc/sys/access.2 | 8 +++++--- sys/compat/linux/linux_file.c | 6 ++++-- sys/kern/vfs_syscalls.c | 7 ++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/bin/ln/symlink.7 b/bin/ln/symlink.7 index 5c5d0a64026c..28d9908f2053 100644 --- a/bin/ln/symlink.7 +++ b/bin/ln/symlink.7 @@ -26,9 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)symlink.7 8.3 (Berkeley) 3/31/94 -.\" -.Dd February 16, 2015 +.Dd August 11, 2024 .Dt SYMLINK 7 .Os .Sh NAME @@ -146,6 +144,7 @@ unless given the .Dv AT_SYMLINK_NOFOLLOW flag: .Xr chflagsat 2 , +.Xr faccessat 2 , .Xr fchmodat 2 , .Xr fchownat 2 , .Xr fstatat 2 diff --git a/lib/libc/sys/access.2 b/lib/libc/sys/access.2 index 8595444720b1..94a13dcc4dcf 100644 --- a/lib/libc/sys/access.2 +++ b/lib/libc/sys/access.2 @@ -25,9 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)access.2 8.2 (Berkeley) 4/1/94 -.\" -.Dd May 21, 2024 +.Dd August 11, 2024 .Dt ACCESS 2 .Os .Sh NAME @@ -156,6 +154,10 @@ If is equal to .Dv AT_FDCWD , operate on the current working directory. +.It Dv AT_SYMLINK_NOFOLLOW +If +.Fa path +names a symbolic link, access of the symbolic link is evaluated. .El .Pp Even if a process's real or effective user has appropriate privileges diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 1279490ae8be..1341df8bc7fc 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -636,8 +636,8 @@ linux_faccessat2(struct thread *td, struct linux_faccessat2_args *args) { int flags, unsupported; - /* XXX. AT_SYMLINK_NOFOLLOW is not supported by kern_accessat */ - unsupported = args->flags & ~(LINUX_AT_EACCESS | LINUX_AT_EMPTY_PATH); + unsupported = args->flags & ~(LINUX_AT_EACCESS | LINUX_AT_EMPTY_PATH | + LINUX_AT_SYMLINK_NOFOLLOW); if (unsupported != 0) { linux_msg(td, "faccessat2 unsupported flag 0x%x", unsupported); return (EINVAL); @@ -647,6 +647,8 @@ linux_faccessat2(struct thread *td, struct linux_faccessat2_args *args) AT_EACCESS; flags |= (args->flags & LINUX_AT_EMPTY_PATH) == 0 ? 0 : AT_EMPTY_PATH; + flags |= (args->flags & LINUX_AT_SYMLINK_NOFOLLOW) == 0 ? 0 : + AT_SYMLINK_NOFOLLOW; return (linux_do_accessat(td, args->dfd, args->filename, args->amode, flags)); } diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 0915751785f4..fbb1e1cdda92 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -2153,7 +2153,8 @@ kern_accessat(struct thread *td, int fd, const char *path, struct nameidata nd; int error; - if ((flag & ~(AT_EACCESS | AT_RESOLVE_BENEATH | AT_EMPTY_PATH)) != 0) + if ((flag & ~(AT_EACCESS | AT_RESOLVE_BENEATH | AT_EMPTY_PATH | + AT_SYMLINK_NOFOLLOW)) != 0) return (EINVAL); if (amode != F_OK && (amode & ~(R_OK | W_OK | X_OK)) != 0) return (EINVAL); @@ -2173,8 +2174,8 @@ kern_accessat(struct thread *td, int fd, const char *path, } else usecred = cred; AUDIT_ARG_VALUE(amode); - NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | - AUDITVNODE1 | at2cnpflags(flag, AT_RESOLVE_BENEATH | + NDINIT_ATRIGHTS(&nd, LOOKUP, LOCKSHARED | LOCKLEAF | + AUDITVNODE1 | at2cnpflags(flag, AT_RESOLVE_BENEATH | AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH), pathseg, path, fd, &cap_fstat_rights); if ((error = namei(&nd)) != 0) goto out;