git: 0e100820c4bb - main - uipc_shm.c: add kern_ implementations

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

URL: https://cgit.FreeBSD.org/src/commit/?id=0e100820c4bb87dc3c365fa1f6a16e6f84363f5b

commit 0e100820c4bb87dc3c365fa1f6a16e6f84363f5b
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2025-11-24 18:14:57 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-11 13:14:42 +0000

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

diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c
index 3544ebd35336..eefe6a63b53c 100644
--- a/sys/kern/uipc_shm.c
+++ b/sys/kern/uipc_shm.c
@@ -1407,12 +1407,18 @@ freebsd12_shm_open(struct thread *td, struct freebsd12_shm_open_args *uap)
 
 int
 sys_shm_unlink(struct thread *td, struct shm_unlink_args *uap)
+{
+	return (kern_shm_unlink(td, uap->path));
+}
+
+int
+kern_shm_unlink(struct thread *td, const char *userpath)
 {
 	char *path;
 	Fnv32_t fnv;
 	int error;
 
-	error = shm_copyin_path(td, uap->path, &path);
+	error = shm_copyin_path(td, userpath, &path);
 	if (error != 0)
 		return (error);
 
@@ -1428,15 +1434,20 @@ sys_shm_unlink(struct thread *td, struct shm_unlink_args *uap)
 
 int
 sys_shm_rename(struct thread *td, struct shm_rename_args *uap)
+{
+	return (kern_shm_rename(td, uap->path_from, uap->path_to, uap->flags));
+}
+
+int
+kern_shm_rename(struct thread *td, const char *path_from_p,
+    const char *path_to_p, int flags)
 {
 	char *path_from = NULL, *path_to = NULL;
 	Fnv32_t fnv_from, fnv_to;
 	struct shmfd *fd_from;
 	struct shmfd *fd_to;
 	int error;
-	int flags;
 
-	flags = uap->flags;
 	AUDIT_ARG_FFLAGS(flags);
 
 	/*
@@ -1462,16 +1473,16 @@ sys_shm_rename(struct thread *td, struct shm_rename_args *uap)
 	}
 
 	/* Renaming to or from anonymous makes no sense */
-	if (uap->path_from == SHM_ANON || uap->path_to == SHM_ANON) {
+	if (path_from_p == SHM_ANON || path_to_p == SHM_ANON) {
 		error = EINVAL;
 		goto out;
 	}
 
-	error = shm_copyin_path(td, uap->path_from, &path_from);
+	error = shm_copyin_path(td, path_from_p, &path_from);
 	if (error != 0)
 		goto out;
 
-	error = shm_copyin_path(td, uap->path_to, &path_to);
+	error = shm_copyin_path(td, path_to_p, &path_to);
 	if (error != 0)
 		goto out;
 
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 0068f5c16cbc..0dbc81fd4ffb 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -475,6 +475,9 @@ int	kern_shm_open2(struct thread *td, const char *path, int flags,
 	    const char *name, struct shmfd *shmfd);
 int	kern_shmat(struct thread *td, int shmid, const void *shmaddr,
 	    int shmflg);
+int	kern_shm_rename(struct thread *td, const char *path_from_p,
+	    const char *path_to_p, int flags);
+int	kern_shm_unlink(struct thread *td, const char *userpath);
 int	kern_shmctl(struct thread *td, int shmid, int cmd, void *buf,
 	    size_t *bufsz);
 int	kern_shutdown(struct thread *td, int s, int how);