git: c7b2fd667952 - main - fchroot(2): audit

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 23 Nov 2026 02:09:19 UTC
The branch main has been updated by kib:

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

commit c7b2fd667952a2c7347b290922f1dededbbc620c
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-11-23 01:29:54 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-23 02:08:58 +0000

    fchroot(2): audit
    
    The AUE_FCHROOT identifier was already added, but not used to audit the
    fchroot(2) syscall.
    
    Reported by:    llm-postcr
    Fixes:  b165e9e3ea4e ("Add fchroot(2)")
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/kern/syscalls.master       | 2 +-
 sys/kern/vfs_syscalls.c        | 2 ++
 sys/security/audit/audit_bsm.c | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index aca0d13f7bd8..d6d2b8ed3efd 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -3341,7 +3341,7 @@
 		    _Out_ rlim_t *res
 		);
 	}
-590	AUE_NULL	STD {
+590	AUE_FCHROOT	STD {
 		int fchroot(
 		    int fd
 		);
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 23de410cc74d..4f2684e1a996 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1095,6 +1095,7 @@ sys_fchroot(struct thread *td, struct fchroot_args *uap)
 	int error;
 	uint8_t fdflags;
 
+	AUDIT_ARG_FD(uap->fd);
 	error = getvnode_path(td, uap->fd, &cap_fchroot_rights, &fdflags, &fp);
 	if (error != 0)
 		return (error);
@@ -1106,6 +1107,7 @@ sys_fchroot(struct thread *td, struct fchroot_args *uap)
 	vrefact(vp);
 	fdrop(fp, td);
 	vn_lock(vp, LK_SHARED | LK_RETRY);
+	AUDIT_ARG_VNODE1(vp);
 	error = kern_chroot(td, vp);
 	return (error);
 }
diff --git a/sys/security/audit/audit_bsm.c b/sys/security/audit/audit_bsm.c
index ba4f960b988c..adc627b1f4c7 100644
--- a/sys/security/audit/audit_bsm.c
+++ b/sys/security/audit/audit_bsm.c
@@ -1046,6 +1046,7 @@ kaudit_to_bsm(struct kaudit_record *kar, struct au_record **pau)
 	 */
 	case AUE_FCHALTROOT:
 	case AUE_FCHDIR:
+	case AUE_FCHROOT:
 	case AUE_FPATHCONF:
 	case AUE_FSTAT:
 	case AUE_FSTATFS: