git: 87d8a910d30f - main - nmount(2): add kern_nmount

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Thu, 12 Nov 2026 10:23:47 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=87d8a910d30f88eb53dd00272aefb5dfc59e0d6b

commit 87d8a910d30f88eb53dd00272aefb5dfc59e0d6b
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-12 10:23:23 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-12 10:23:23 +0000

    nmount(2): add kern_nmount
    
    Effort:         CHERI UK
    Sponsored by:   Innovate UK
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
---
 sys/kern/vfs_mount.c  | 18 ++++++++++++------
 sys/sys/syscallsubr.h |  2 ++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 69b448f8fe39..39c9135f3f4c 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -435,10 +435,17 @@ struct nmount_args {
 #endif
 int
 sys_nmount(struct thread *td, struct nmount_args *uap)
+{
+	return (kern_nmount(td, uap->iovp, uap->iovcnt, uap->flags,
+	    copyinuio));
+}
+
+int
+kern_nmount(struct thread *td, struct iovec *iovp, u_int iovcnt, int flags32,
+    copyinuio_t *copyinuio_f)
 {
 	struct uio *auio;
 	int error;
-	u_int iovcnt;
 	uint64_t flags;
 
 	/*
@@ -446,11 +453,11 @@ sys_nmount(struct thread *td, struct nmount_args *uap)
 	 * 32-bits are passed in, but from here on everything handles
 	 * 64-bit flags correctly.
 	 */
-	flags = uap->flags;
+	flags = flags32;
 
 	AUDIT_ARG_FFLAGS(flags);
 	CTR4(KTR_VFS, "%s: iovp %p with iovcnt %d and flags %d", __func__,
-	    uap->iovp, uap->iovcnt, flags);
+	    (void *)iovp, iovcnt, flags);
 
 	/*
 	 * Filter out MNT_ROOTFS.  We do not want clients of nmount() in
@@ -461,18 +468,17 @@ sys_nmount(struct thread *td, struct nmount_args *uap)
 	 */
 	flags &= ~MNT_ROOTFS;
 
-	iovcnt = uap->iovcnt;
 	/*
 	 * Check that we have an even number of iovec's
 	 * and that we have at least two options.
 	 */
 	if ((iovcnt & 1) || (iovcnt < 4)) {
 		CTR2(KTR_VFS, "%s: failed for invalid iovcnt %d", __func__,
-		    uap->iovcnt);
+		    iovcnt);
 		return (EINVAL);
 	}
 
-	error = copyinuio(uap->iovp, iovcnt, &auio);
+	error = copyinuio_f(iovp, iovcnt, &auio);
 	if (error) {
 		CTR2(KTR_VFS, "%s: failed for invalid uio op with %d errno",
 		    __func__, error);
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 5c46451b516f..c8da8dc8300d 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -381,6 +381,8 @@ int	kern_munlock(struct thread *td, uintptr_t addr, size_t size);
 int	kern_munmap(struct thread *td, uintptr_t addr, size_t size);
 int     kern_nanosleep(struct thread *td, struct timespec *rqt,
 	    struct timespec *rmt);
+int	kern_nmount(struct thread *td, struct iovec *iovp, u_int iovcnt,
+	    int flags32, copyinuio_t *copyinuio_f);
 int	kern_nosys(struct thread *td, int dummy);
 int	kern_ntp_adjtime(struct thread *td, struct timex *ntv, int *retvalp);
 int	kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,