From nobody Sat Nov 07 12:11:00 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jMFJ53S5Fz6yWGv for ; Sat, 07 Nov 2026 12:11:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jMFJ46kpvz3CKm for ; Sat, 07 Nov 2026 12:11:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794053460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hFef6F1qYaAHXB/Oi1APCnPAx1aYYJGKTo60+S3mwi4=; b=tntGYVNbCJlD8VJU0rgbHVzTQRgBlwSrox5cBb9MQqUDoDiwnevrfoVS9X+PgMYpUB/rcs AWI2N1ijfFKt9VPyO3aW+u37DxqhWdjX6DRNpT704w461IMTHU0Ay8i1FrvDDqwGwxpczA veylC41j5+L0b6RjqZUxuIR2RJCuJaapW64c3e1HPwpe8qL6h5jDN0ZsAPihqDte1MpsAd 6/t6rELB98I2V8ZfHDZZx/Tea4MUrdC8gV4+Fz34YHGURrrs1CsRiXRLkTacmwGiQs+i76 DP3SswU+yli3JjrRZ8SF3y5lDc7AhOU7qlYUY6wWq103KV0C800DtZaZAMo2eA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794053460; b=E8Pkmwb4k4KbXnBbutBB11BwR07p+HBGK2xLDsWHnhp+7gZEdMTCs2m8WKatWlhDLdbsBY 7kz8X5OVK2dxzqGbvUuGqiRm0+JOYAdp/PyRJMI3M3t7xFzWWwrzAip64VuU6VaSkgLjMp ZEhu9FJ3elm89UO6INY6kDS9dLeCFiUXxa6KEYwC/Q8oDwtviEZDcsEiVGw0viXj/Pftyq h8zsjSy2i7qlWMiKC8Ye2/G/Qbkkpa3SMX16LMgQ4RnxngrsvDpmEvP6c3eGwYrKyvCVMr HeTsuZldfn/x9Q0QYj2YwmsK/1WyKyHFASvHUYxDS718tm0zqNL0zp/cDLmULw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794053460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hFef6F1qYaAHXB/Oi1APCnPAx1aYYJGKTo60+S3mwi4=; b=U5m//jILXxlwgjsPoRe/5FYzC5VqjC6rItRD613l9pLb3RmOk3BYnSQHIt4rgkUXPFByEP BDRZQ5HrZq7nwTVC5RU5M562lsC8LPT9zZsFY0jfHfOY/Aeb381vb7O6zrDc/3xYFoIjmz kYqt1eq9TkOeWkwjhvalDwAkHpkFIkv2WKZloQra1WQqh9+TsYqAy7f6z+I76to9JjpdY6 snmpSdjr9YbSpz6stwdJNEes25yyabdSHRo+olySDjoRnroGlNaBdoAlCqd/bQFW+yYYNn N79OzqbTqTPj7zzuszBbQLOlAdJr627reEwO2kt0m7cBcPpIZCe6TAM6O62hdA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jMFJ465jdzLW5 for ; Sat, 07 Nov 2026 12:11:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 477a1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 07 Nov 2026 12:11:00 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 7b18863d597e - main - mac syscalls: add kern_ implementations List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7b18863d597e0dad0734cf6e06c5e7689be2047c Auto-Submitted: auto-generated Date: Sat, 07 Nov 2026 12:11:00 +0000 Message-Id: <6aef1554.477a1.5934271b@gitrepo.freebsd.org> The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=7b18863d597e0dad0734cf6e06c5e7689be2047c commit 7b18863d597e0dad0734cf6e06c5e7689be2047c Author: Brooks Davis AuthorDate: 2026-11-07 12:10:45 +0000 Commit: Brooks Davis CommitDate: 2026-11-07 12:10:45 +0000 mac syscalls: add kern_ implementations Where the kern_ interfaces map trivially to the syscall interface, follow the syscall name even if awkward (e.g., sys___mac* -> kern___mac*). Otherwise use shorter names. Effort: CHERI upstreaming Sponsored by: DARPA, AFRL Pull Request: https://github.com/freebsd/freebsd-src/pull/2284 --- sys/security/mac/mac_syscalls.c | 88 ++++++++++++++++++++++++++--------------- sys/sys/syscallsubr.h | 11 ++++++ 2 files changed, 68 insertions(+), 31 deletions(-) diff --git a/sys/security/mac/mac_syscalls.c b/sys/security/mac/mac_syscalls.c index 9bafa6d30c36..5a5d4b1b7161 100644 --- a/sys/security/mac/mac_syscalls.c +++ b/sys/security/mac/mac_syscalls.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -78,11 +79,6 @@ FEATURE(security_mac, "Mandatory Access Control Framework support"); -static int kern___mac_get_path(struct thread *td, const char *path_p, - struct mac *mac_p, int follow); -static int kern___mac_set_path(struct thread *td, const char *path_p, - struct mac *mac_p, int follow); - #ifdef COMPAT_FREEBSD32 struct mac32 { uint32_t m_buflen; /* size_t */ @@ -161,6 +157,12 @@ free_copied_label(const struct mac *const mac) int sys___mac_get_pid(struct thread *td, struct __mac_get_pid_args *uap) +{ + return (kern___mac_get_pid(td, uap->pid, uap->mac_p)); +} + +int +kern___mac_get_pid(struct thread *td, pid_t pid, void *mac_p) { char *buffer, *u_buffer; struct mac mac; @@ -168,11 +170,11 @@ sys___mac_get_pid(struct thread *td, struct __mac_get_pid_args *uap) struct ucred *tcred; int error; - error = mac_label_copyin(uap->mac_p, &mac, &u_buffer); + error = mac_label_copyin(mac_p, &mac, &u_buffer); if (error) return (error); - tproc = pfind(uap->pid); + tproc = pfind(pid); if (tproc == NULL) { error = ESRCH; goto free_mac_and_exit; @@ -201,12 +203,18 @@ free_mac_and_exit: int sys___mac_get_proc(struct thread *td, struct __mac_get_proc_args *uap) +{ + return (kern___mac_get_proc(td, uap->mac_p)); +} + +int +kern___mac_get_proc(struct thread *td, void *mac_p) { char *buffer, *u_buffer; struct mac mac; int error; - error = mac_label_copyin(uap->mac_p, &mac, &u_buffer); + error = mac_label_copyin(mac_p, &mac, &u_buffer); if (error) return (error); @@ -454,6 +462,12 @@ mac_set_prison_finish(struct thread *const td, bool prison_label_set __unused, int sys___mac_set_proc(struct thread *td, struct __mac_set_proc_args *uap) +{ + return (kern___mac_set_proc(td, uap->mac_p)); +} + +int +kern___mac_set_proc(struct thread *td, void *mac_p) { struct ucred *newcred, *oldcred; void *intlabel; @@ -461,7 +475,7 @@ sys___mac_set_proc(struct thread *td, struct __mac_set_proc_args *uap) struct mac mac; int error; - error = mac_label_copyin(uap->mac_p, &mac, NULL); + error = mac_label_copyin(mac_p, &mac, NULL); if (error) return (error); @@ -496,6 +510,12 @@ free_label: int sys___mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap) +{ + return (kern___mac_get_fd(td, uap->fd, uap->mac_p)); +} + +int +kern___mac_get_fd(struct thread *td, int fd, void *mac_p) { char *u_buffer, *buffer; struct label *intlabel; @@ -508,13 +528,12 @@ sys___mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap) cap_rights_t rights; int error; - error = mac_label_copyin(uap->mac_p, &mac, &u_buffer); + error = mac_label_copyin(mac_p, &mac, &u_buffer); if (error) return (error); buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO); - error = fget(td, uap->fd, cap_rights_init_one(&rights, CAP_MAC_GET), - &fp); + error = fget(td, fd, cap_rights_init_one(&rights, CAP_MAC_GET), &fp); if (error) goto out; @@ -600,19 +619,17 @@ out: int sys___mac_get_file(struct thread *td, struct __mac_get_file_args *uap) { - - return (kern___mac_get_path(td, uap->path_p, uap->mac_p, FOLLOW)); + return (kern_mac_get_path(td, uap->path_p, uap->mac_p, FOLLOW)); } int sys___mac_get_link(struct thread *td, struct __mac_get_link_args *uap) { - - return (kern___mac_get_path(td, uap->path_p, uap->mac_p, NOFOLLOW)); + return (kern_mac_get_path(td, uap->path_p, uap->mac_p, NOFOLLOW)); } -static int -kern___mac_get_path(struct thread *td, const char *path_p, struct mac *mac_p, +int +kern_mac_get_path(struct thread *td, const char *path_p, struct mac *mac_p, int follow) { char *u_buffer, *buffer; @@ -654,6 +671,12 @@ out: int sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap) +{ + return (kern___mac_set_fd(td, uap->fd, uap->mac_p)); +} + +int +kern___mac_set_fd(struct thread *td, int fd, void *mac_p) { struct label *intlabel; struct pipe *pipe; @@ -666,11 +689,11 @@ sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap) cap_rights_t rights; int error; - error = mac_label_copyin(uap->mac_p, &mac, NULL); + error = mac_label_copyin(mac_p, &mac, NULL); if (error) return (error); - error = fget(td, uap->fd, cap_rights_init_one(&rights, CAP_MAC_SET), + error = fget(td, fd, cap_rights_init_one(&rights, CAP_MAC_SET), &fp); if (error) goto out; @@ -767,19 +790,17 @@ out: int sys___mac_set_file(struct thread *td, struct __mac_set_file_args *uap) { - - return (kern___mac_set_path(td, uap->path_p, uap->mac_p, FOLLOW)); + return (kern_mac_set_path(td, uap->path_p, uap->mac_p, FOLLOW)); } int sys___mac_set_link(struct thread *td, struct __mac_set_link_args *uap) { - - return (kern___mac_set_path(td, uap->path_p, uap->mac_p, NOFOLLOW)); + return (kern_mac_set_path(td, uap->path_p, uap->mac_p, NOFOLLOW)); } -static int -kern___mac_set_path(struct thread *td, const char *path_p, struct mac *mac_p, +int +kern_mac_set_path(struct thread *td, const char *path_p, struct mac *mac_p, int follow) { struct label *intlabel; @@ -820,12 +841,18 @@ out: int sys_mac_syscall(struct thread *td, struct mac_syscall_args *uap) +{ + return (kern_mac_syscall(td, uap->policy, uap->call, uap->arg)); +} + +int +kern_mac_syscall(struct thread *td, const char *policy, int call, void *arg) { struct mac_policy_conf *mpc; char target[MAC_MAX_POLICY_NAME]; int error; - error = copyinstr(uap->policy, target, sizeof(target), NULL); + error = copyinstr(policy, target, sizeof(target), NULL); if (error) return (error); @@ -833,8 +860,7 @@ sys_mac_syscall(struct thread *td, struct mac_syscall_args *uap) LIST_FOREACH(mpc, &mac_static_policy_list, mpc_list) { if (strcmp(mpc->mpc_name, target) == 0 && mpc->mpc_ops->mpo_syscall != NULL) { - error = mpc->mpc_ops->mpo_syscall(td, - uap->call, uap->arg); + error = mpc->mpc_ops->mpo_syscall(td, call, arg); goto out; } } @@ -844,8 +870,8 @@ sys_mac_syscall(struct thread *td, struct mac_syscall_args *uap) LIST_FOREACH(mpc, &mac_policy_list, mpc_list) { if (strcmp(mpc->mpc_name, target) == 0 && mpc->mpc_ops->mpo_syscall != NULL) { - error = mpc->mpc_ops->mpo_syscall(td, - uap->call, uap->arg); + error = mpc->mpc_ops->mpo_syscall(td, call, + arg); break; } } diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index a9cf1ef4390d..1abd99438bce 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -108,6 +108,11 @@ typedef int (updateiov_t)(const struct uio *uiop, void *iovp); uint64_t at2cnpflags(u_int at_flags, u_int mask); int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, size_t buflen, size_t path_max); +int kern___mac_get_fd(struct thread *td, int fd, void *mac_p); +int kern___mac_get_pid(struct thread *td, pid_t pid, void *mac_p); +int kern___mac_get_proc(struct thread *td, void *mac_p); +int kern___mac_set_fd(struct thread *td, int fd, void *mac_p); +int kern___mac_set_proc(struct thread *td, void *mac_p); int kern_abort2(struct thread *td, const char *why, int nargs, void **uargs); int kern_accept(struct thread *td, int s, struct sockaddr *sa, @@ -275,6 +280,12 @@ int kern_listen(struct thread *td, int s, int backlog); int kern_lseek(struct thread *td, int fd, off_t offset, int whence); int kern_lutimes(struct thread *td, const char *path, enum uio_seg pathseg, const struct timeval *tptr, enum uio_seg tptrseg); +int kern_mac_get_path(struct thread *td, const char *path_p, + struct mac *mac_p, int follow); +int kern_mac_set_path(struct thread *td, const char *path_p, + struct mac *mac_p, int follow); +int kern_mac_syscall(struct thread *td, const char *policy, int call, + void *arg); int kern_madvise(struct thread *td, uintptr_t addr, size_t len, int behav); int kern_membarrier(struct thread *td, int cmd, unsigned flags, int cpu_id);