git: 133344405f53 - main - kern_loginclass.c: add kern_ implementations

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Mon, 09 Nov 2026 11:54:24 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=133344405f532bd54ff3629a77d4c4e062f01fdb

commit 133344405f532bd54ff3629a77d4c4e062f01fdb
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-11-24 14:16:16 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-09 11:34:59 +0000

    kern_loginclass.c: add kern_ implementations
    
    Effort:         CHERI upstreaming
    Sponsored by:   DARPA, AFRL, Innovate UK
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
---
 sys/kern/kern_loginclass.c | 19 ++++++++++++++++---
 sys/sys/syscallsubr.h      |  2 ++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/sys/kern/kern_loginclass.c b/sys/kern/kern_loginclass.c
index 07d388f18f8d..e2b155317ea8 100644
--- a/sys/kern/kern_loginclass.c
+++ b/sys/kern/kern_loginclass.c
@@ -55,6 +55,7 @@
 #include <sys/rctl.h>
 #include <sys/refcount.h>
 #include <sys/rwlock.h>
+#include <sys/syscallsubr.h>
 #include <sys/sysproto.h>
 #include <sys/systm.h>
 
@@ -178,15 +179,21 @@ struct getloginclass_args {
 /* ARGSUSED */
 int
 sys_getloginclass(struct thread *td, struct getloginclass_args *uap)
+{
+	return (kern_getloginclass(td, uap->namebuf, uap->namelen));
+}
+
+int
+kern_getloginclass(struct thread *td, char *namebuf, size_t namelen)
 {
 	struct loginclass *lc;
 	size_t lcnamelen;
 
 	lc = td->td_ucred->cr_loginclass;
 	lcnamelen = strlen(lc->lc_name) + 1;
-	if (lcnamelen > uap->namelen)
+	if (lcnamelen > namelen)
 		return (ERANGE);
-	return (copyout(lc->lc_name, uap->namebuf, lcnamelen));
+	return (copyout(lc->lc_name, namebuf, lcnamelen));
 }
 
 /*
@@ -200,6 +207,12 @@ struct setloginclass_args {
 /* ARGSUSED */
 int
 sys_setloginclass(struct thread *td, struct setloginclass_args *uap)
+{
+	return (kern_setloginclass(td, uap->namebuf));
+}
+
+int
+kern_setloginclass(struct thread *td, const char *namebuf)
 {
 	struct proc *p = td->td_proc;
 	int error;
@@ -210,7 +223,7 @@ sys_setloginclass(struct thread *td, struct setloginclass_args *uap)
 	error = priv_check(td, PRIV_PROC_SETLOGINCLASS);
 	if (error != 0)
 		return (error);
-	error = copyinstr(uap->namebuf, lcname, sizeof(lcname), NULL);
+	error = copyinstr(namebuf, lcname, sizeof(lcname), NULL);
 	if (error != 0)
 		return (error);
 
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 9a9d93ccd3ff..bc00c4c7ee41 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -254,6 +254,7 @@ int	kern_getfhat(struct thread *td, int flags, int fd, const char *path,
 int	kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
 	    size_t *countp, enum uio_seg bufseg, int mode);
 int	kern_getitimer(struct thread *, u_int, struct itimerval *);
+int	kern_getloginclass(struct thread *td, char *namebuf, size_t namelen);
 int	kern_getppid(struct thread *);
 int	kern_getpeername(struct thread *td, int fd, struct sockaddr *sa);
 int	kern_getpriority(struct thread *td, int which, int who);
@@ -421,6 +422,7 @@ int	kern_setgroups(struct thread *td, int *ngrpp, gid_t *groups,
 	    bool includes_egid);
 int	kern_setitimer(struct thread *, u_int, struct itimerval *,
 	    struct itimerval *);
+int	kern_setloginclass(struct thread *td, const char *namebuf);
 int	kern_setpriority(struct thread *td, int which, int who, int prio);
 int	kern_setrlimit(struct thread *, u_int, struct rlimit *);
 int	kern_setsockopt(struct thread *td, int s, int level, int name,