git: 1625e2db222c - stable/13 - O_PATH: allow vfs_extattr syscalls

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 16 Oct 2021 13:02:50 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=1625e2db222cad581593d4079385707e2e15cdbe

commit 1625e2db222cad581593d4079385707e2e15cdbe
Author:     Greg V <greg@unrelenting.technology>
AuthorDate: 2021-10-10 12:45:31 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-10-16 13:01:47 +0000

    O_PATH: allow vfs_extattr syscalls
    
    (cherry picked from commit 98dae405de7f8b3506dd94dcd3e9f51d3fb15962)
---
 lib/libc/sys/extattr_get_file.2 | 7 ++++++-
 sys/kern/vfs_extattr.c          | 8 ++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/libc/sys/extattr_get_file.2 b/lib/libc/sys/extattr_get_file.2
index 5134c8d8ac0f..c38b27e17423 100644
--- a/lib/libc/sys/extattr_get_file.2
+++ b/lib/libc/sys/extattr_get_file.2
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 7, 2020
+.Dd October 11, 2021
 .Dt EXTATTR 2
 .Os
 .Sh NAME
@@ -149,6 +149,11 @@ functions take a file descriptor, while the
 functions take a path.
 Both arguments describe a file associated with the extended attribute
 that should be manipulated.
+The
+.Qq Li _fd
+functions can be used with file descriptors opened with the
+.Dv O_PATH
+flag.
 .Pp
 The following arguments are common to all the system calls described here:
 .Bl -tag -width attrnamespace
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index adb882288f6c..43b000c78110 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -242,7 +242,7 @@ sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap)
 		return (error);
 	AUDIT_ARG_TEXT(attrname);
 
-	error = getvnode(td, uap->fd,
+	error = getvnode_path(td, uap->fd,
 	    cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp);
 	if (error)
 		return (error);
@@ -409,7 +409,7 @@ sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap)
 		return (error);
 	AUDIT_ARG_TEXT(attrname);
 
-	error = getvnode(td, uap->fd,
+	error = getvnode_path(td, uap->fd,
 	    cap_rights_init_one(&rights, CAP_EXTATTR_GET), &fp);
 	if (error)
 		return (error);
@@ -544,7 +544,7 @@ sys_extattr_delete_fd(struct thread *td, struct extattr_delete_fd_args *uap)
 		return (error);
 	AUDIT_ARG_TEXT(attrname);
 
-	error = getvnode(td, uap->fd,
+	error = getvnode_path(td, uap->fd,
 	    cap_rights_init_one(&rights, CAP_EXTATTR_DELETE), &fp);
 	if (error)
 		return (error);
@@ -690,7 +690,7 @@ sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap)
 
 	AUDIT_ARG_FD(uap->fd);
 	AUDIT_ARG_VALUE(uap->attrnamespace);
-	error = getvnode(td, uap->fd,
+	error = getvnode_path(td, uap->fd,
 	    cap_rights_init_one(&rights, CAP_EXTATTR_LIST), &fp);
 	if (error)
 		return (error);