Bug 289645 - sys/kern/kern_jail.c: D51719 breaks things
Summary: sys/kern/kern_jail.c: D51719 breaks things
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2025-09-16 11:57 UTC by Dan Kotowski
Modified: 2025-09-16 15:45 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Kotowski 2025-09-16 11:57:22 UTC
Since D51719 (commit 246d7e9fc23928be22db38220f5439f5cdee5264) a lot of my jails are now failing as services are no longer able to set or get auids.

This also prevents changing user contexts, even just from root to toor.

```
root@hulk:~ # id
uid=0(root) gid=0(wheel) groups=0(wheel),5(operator)
root@hulk:~ # su -l toor
su: Permission denied
root@hulk:~ # tail /var/log/auth.log /var/log/messages
==> /var/log/auth.log <==
Sep 16 11:26:56 hulk su[34105]: getauid: Operation not permitted
Sep 16 11:28:48 hulk su[37744]: getauid: Operation not permitted
Sep 16 11:29:48 hulk login[39549]: login on pts/2 as root
Sep 16 11:29:51 hulk su[39614]: getauid: Operation not permitted
Sep 16 11:44:58 hulk su[94608]: getauid: Operation not permitted
Sep 16 11:55:01 hulk su[29349]: getauid: Operation not permitted
Sep 16 11:55:02 hulk su[29373]: getauid: Operation not permitted
Sep 16 11:55:23 hulk login[30080]: login on pts/2 as root
Sep 16 11:55:33 hulk su[30310]: getauid: Operation not permitted
Sep 16 11:55:36 hulk su[30372]: getauid: Operation not permitted

==> /var/log/messages <==
Sep 16 11:44:58 hulk su[94608]: getauid: Operation not permitted
Sep 16 11:44:59 hulk root[94619]: /usr/local/etc/rc.d/mysql-server: WARNING: failed to start mysql
Sep 16 11:48:54 hulk syslogd: exiting on signal 15
Sep 16 11:54:59 hulk syslogd: kernel boot file is /boot/kernel/kernel
Sep 16 11:55:01 hulk su[29349]: getauid: Operation not permitted
Sep 16 11:55:01 hulk root[29353]: /etc/rc: WARNING: failed to start mysql
Sep 16 11:55:02 hulk su[29373]: getauid: Operation not permitted
Sep 16 11:55:02 hulk root[29382]: /etc/rc: WARNING: failed to start redis
Sep 16 11:55:33 hulk su[30310]: getauid: Operation not permitted
Sep 16 11:55:36 hulk su[30372]: getauid: Operation not permitted
```

And when attempting to start databases/mariadb1011-server:
```
+ umask
+ _m=0022
+ 
+ eval $' limits -C daemon  su -m mysql -c \'sh -c " /usr/sbin/daemon  -c -f /usr/local/bin/mariadbd-safe --defaults-extra-file=/usr/local/etc/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/run/mysql/mysqld.pid  "\''
+ limits -C daemon su -m mysql -c 'sh -c " /usr/sbin/daemon  -c -f /usr/local/bin/mariadbd-safe --defaults-extra-file=/usr/local/etc/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/run/mysql/mysqld.pid  "'
su: Permission denied
```
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2025-09-16 12:14:44 UTC
^Triage: this came in as 246d7e9fc23928be22db38220f5439f5cdee5264 .  Assign
to committer.
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2025-09-16 13:34:57 UTC
https://reviews.freebsd.org/D52572
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-09-16 13:45:14 UTC
A commit in branch main references this bug:

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

commit 1c3ca0c733a4e4ba550cedfa8019260fb0cf5707
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-09-16 13:43:47 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-09-16 13:44:58 +0000

    Revert "jail: Optionally allow audit session state to be configured in a jail"

    Changing audit system calls to return EPERM instead of ENOSYS when
    invoked from a jail breaks some userspace applications.  Revert for now
    until a more complete change is reviewed.

    This reverts commit 246d7e9fc23928be22db38220f5439f5cdee5264.

    PR:             289645

 sys/kern/kern_jail.c                   | 13 +------------
 sys/security/audit/audit_syscalls.c    | 12 ++++++++++++
 sys/sys/jail.h                         |  3 +--
 usr.sbin/jail/jail.8                   | 19 ++++---------------
 usr.sbin/jail/tests/jail_basic_test.sh | 20 --------------------
 5 files changed, 18 insertions(+), 49 deletions(-)
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2025-09-16 15:45:28 UTC
I've recommitted the change with modifications to avoid this problem.  Thanks for the report.