git: 6e87733f73ff - main - __acl_*(2): add kern_ implementations

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Wed, 11 Nov 2026 13:21:04 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=6e87733f73ff2bc1a5b2d1a370c15e4907deb326

commit 6e87733f73ff2bc1a5b2d1a370c15e4907deb326
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-11-24 20:28:54 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-11 13:14:43 +0000

    __acl_*(2): add kern_ implementations
    
    Effort:         CHERI upstreaming
    Sponsored by:   Innovate UK
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
---
 sys/kern/vfs_acl.c    | 59 ++++++++++++++++++++++++++++++---------------------
 sys/sys/syscallsubr.h | 15 +++++++++++++
 2 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c
index 6076a5f7bdf8..eb0c6029716b 100644
--- a/sys/kern/vfs_acl.c
+++ b/sys/kern/vfs_acl.c
@@ -55,6 +55,7 @@
 #include <sys/filedesc.h>
 #include <sys/proc.h>
 #include <sys/acl.h>
+#include <sys/syscallsubr.h>
 
 #include <security/audit/audit.h>
 #include <security/mac/mac_framework.h>
@@ -63,14 +64,6 @@ CTASSERT(ACL_MAX_ENTRIES >= OLDACL_MAX_ENTRIES);
 
 MALLOC_DEFINE(M_ACL, "acl", "Access Control Lists");
 
-static int	kern___acl_aclcheck_path(struct thread *td, const char *path,
-		    acl_type_t type, struct acl *aclp, int follow);
-static int	kern___acl_delete_path(struct thread *td, const char *path,
-		    acl_type_t type, int follow);
-static int	kern___acl_get_path(struct thread *td, const char *path,
-		    acl_type_t type, struct acl *aclp, int follow);
-static int	kern___acl_set_path(struct thread *td, const char *path,
-		    acl_type_t type, const struct acl *aclp, int follow);
 static int	vacl_set_acl(struct thread *td, struct vnode *vp,
 		    acl_type_t type, const struct acl *aclp);
 static int	vacl_get_acl(struct thread *td, struct vnode *vp,
@@ -366,7 +359,7 @@ sys___acl_get_link(struct thread *td, struct __acl_get_link_args *uap)
 	    NOFOLLOW));
 }
 
-static int
+int
 kern___acl_get_path(struct thread *td, const char *path, acl_type_t type,
     struct acl *aclp, int follow)
 {
@@ -405,7 +398,7 @@ sys___acl_set_link(struct thread *td, struct __acl_set_link_args *uap)
 	    NOFOLLOW));
 }
 
-static int
+int
 kern___acl_set_path(struct thread *td, const char *path,
     acl_type_t type, const struct acl *aclp, int follow)
 {
@@ -427,16 +420,23 @@ kern___acl_set_path(struct thread *td, const char *path,
  */
 int
 sys___acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
+{
+	return (kern___acl_get_fd(td, uap->filedes, uap->type, uap->aclp));
+}
+
+int
+kern___acl_get_fd(struct thread *td, int filedes, acl_type_t type,
+    struct acl *aclp)
 {
 	struct file *fp;
 	cap_rights_t rights;
 	int error;
 
-	AUDIT_ARG_FD(uap->filedes);
-	error = getvnode_path(td, uap->filedes,
+	AUDIT_ARG_FD(filedes);
+	error = getvnode_path(td, filedes,
 	    cap_rights_init_one(&rights, CAP_ACL_GET), NULL, &fp);
 	if (error == 0) {
-		error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
+		error = vacl_get_acl(td, fp->f_vnode, type, aclp);
 		fdrop(fp, td);
 	}
 	return (error);
@@ -447,16 +447,23 @@ sys___acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
  */
 int
 sys___acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
+{
+	return (kern___acl_set_fd(td, uap->filedes, uap->type, uap->aclp));
+}
+
+int
+kern___acl_set_fd(struct thread *td, int filedes, acl_type_t type,
+    const struct acl *aclp)
 {
 	struct file *fp;
 	cap_rights_t rights;
 	int error;
 
-	AUDIT_ARG_FD(uap->filedes);
-	error = getvnode(td, uap->filedes,
+	AUDIT_ARG_FD(filedes);
+	error = getvnode(td, filedes,
 	    cap_rights_init_one(&rights, CAP_ACL_SET), &fp);
 	if (error == 0) {
-		error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
+		error = vacl_set_acl(td, fp->f_vnode, type, aclp);
 		fdrop(fp, td);
 	}
 	return (error);
@@ -468,7 +475,6 @@ sys___acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
 int
 sys___acl_delete_file(struct thread *td, struct __acl_delete_file_args *uap)
 {
-
 	return (kern___acl_delete_path(td, uap->path, uap->type, FOLLOW));
 }
 
@@ -478,11 +484,10 @@ sys___acl_delete_file(struct thread *td, struct __acl_delete_file_args *uap)
 int
 sys___acl_delete_link(struct thread *td, struct __acl_delete_link_args *uap)
 {
-
 	return (kern___acl_delete_path(td, uap->path, uap->type, NOFOLLOW));
 }
 
-static int
+int
 kern___acl_delete_path(struct thread *td, const char *path,
     acl_type_t type, int follow)
 {
@@ -525,7 +530,6 @@ sys___acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
 int
 sys___acl_aclcheck_file(struct thread *td, struct __acl_aclcheck_file_args *uap)
 {
-
 	return (kern___acl_aclcheck_path(td, uap->path, uap->type, uap->aclp,
 	    FOLLOW));
 }
@@ -540,7 +544,7 @@ sys___acl_aclcheck_link(struct thread *td, struct __acl_aclcheck_link_args *uap)
 	    NOFOLLOW));
 }
 
-static int
+int
 kern___acl_aclcheck_path(struct thread *td, const char *path, acl_type_t type,
     struct acl *aclp, int follow)
 {
@@ -562,16 +566,23 @@ kern___acl_aclcheck_path(struct thread *td, const char *path, acl_type_t type,
  */
 int
 sys___acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
+{
+	return (kern___acl_aclcheck_fd(td, uap->filedes, uap->type, uap->aclp));
+}
+
+int
+kern___acl_aclcheck_fd(struct thread *td, int filedes, acl_type_t type,
+    const struct acl *aclp)
 {
 	struct file *fp;
 	cap_rights_t rights;
 	int error;
 
-	AUDIT_ARG_FD(uap->filedes);
-	error = getvnode_path(td, uap->filedes,
+	AUDIT_ARG_FD(filedes);
+	error = getvnode_path(td, filedes,
 	    cap_rights_init_one(&rights, CAP_ACL_CHECK), NULL, &fp);
 	if (error == 0) {
-		error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
+		error = vacl_aclcheck(td, fp->f_vnode, type, aclp);
 		fdrop(fp, td);
 	}
 	return (error);
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 794eaf58b618..2f65eb2aaed4 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -39,6 +39,7 @@
 #include <sys/socket.h>
 
 struct __wrusage;
+struct acl;
 struct cpuset_copy_cb;
 struct ffclock_estimate;
 struct file;
@@ -120,6 +121,20 @@ typedef int (copyinuio_t)(const void *iovp, unsigned int iovcnt,
 typedef int (updateiov_t)(const struct uio *uiop, void *iovp);
 
 uint64_t at2cnpflags(u_int at_flags, u_int mask);
+int	kern___acl_aclcheck_fd(struct thread *td, int filedes,
+	    __acl_type_t type, const struct acl *aclp);
+int	kern___acl_aclcheck_path(struct thread *td, const char *path,
+	    __acl_type_t type, struct acl *aclp, int follow);
+int	kern___acl_delete_path(struct thread *td, const char *path,
+	    __acl_type_t type, int follow);
+int	kern___acl_get_fd(struct thread *td, int filedes, __acl_type_t type,
+	    struct acl *aclp);
+int	kern___acl_get_path(struct thread *td, const char *path,
+	    __acl_type_t type, struct acl *aclp, int follow);
+int	kern___acl_set_fd(struct thread *td, int filedes, __acl_type_t type,
+	    const struct acl *aclp);
+int	kern___acl_set_path(struct thread *td, const char *path,
+	    __acl_type_t type, const struct acl *aclp, int follow);
 int	kern___cap_rights_get(struct thread *td, int version, int fd,
 	    cap_rights_t *rightsp);
 int	kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg,