git: 156db3557332 - stable/13 - readlinkat(2): allow O_PATH fd

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 10 Oct 2021 09:24:30 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=156db355733241fc1fd824fd8b1ce9f6f7f5f30a

commit 156db355733241fc1fd824fd8b1ce9f6f7f5f30a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-10-09 05:12:05 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-10-10 09:22:58 +0000

    readlinkat(2): allow O_PATH fd
    
    PR:     258856
    
    (cherry picked from commit 5fb54d2fc845464ea809e6a1a69380693943cf51)
---
 lib/libc/sys/open.2     | 5 +++--
 sys/kern/vfs_syscalls.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
index 5a6f161291f6..da42c238a151 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 May 6, 2021
+.Dd October 9, 2021
 .Dt OPEN 2
 .Os
 .Sh NAME
@@ -327,7 +327,7 @@ and others.
 The other functionality of the returned file descriptor is limited to
 the descriptor-level operations.
 It can be used for
-.Bl -tag -width SCM_RIGHTS -offset indent -compact
+.Bl -tag -width readlinkat(2) -offset indent -compact
 .It Xr fcntl 2
 but advisory locking is not allowed
 .It Xr dup 2
@@ -346,6 +346,7 @@ message
 .It Xr kqueue 2
 using for
 .Dv EVFILT_VNODE
+.It Xr readlinkat 2
 .El
 But operations like
 .Xr read 2 ,
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 8fae55c2862d..6dc6ca43a774 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2628,8 +2628,8 @@ kern_readlinkat(struct thread *td, int fd, const char *path,
 	if (count > IOSIZE_MAX)
 		return (EINVAL);
 
-	NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1,
-	    pathseg, path, fd, td);
+	NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1 |
+	    EMPTYPATH, pathseg, path, fd, td);
 
 	if ((error = namei(&nd)) != 0)
 		return (error);