Closed mattgodbolt closed 3 months ago
I just thought to check dmesg
and:
[266713.881047] audit: type=1400 audit(1722708589.045:468): apparmor="AUDIT" operation="userns_create" class="namespace" info="Userns create - transitioning profile" profile="unconfined" pid=2054703 comm="nsjail" requested="userns_create" target="unprivileged_userns"
[266713.893050] audit: type=1400 audit(1722708589.057:469): apparmor="DENIED" operation="capable" class="cap" profile="unprivileged_userns" pid=2054704 comm="nsjail" capability=6 capname="setgid"
[266713.893126] audit: type=1400 audit(1722708589.057:470): apparmor="DENIED" operation="mount" class="mount" info="failed mntpnt match" error=-13 profile="unprivileged_userns" name="/" pid=2054704 comm="nsjail" flags="rw, rprivate"
Looks like this came in 23.10: https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces; now trying to work out how to disable it. Leaving this issue open in case folks who have more experience have advice.
Per the above link; this is a workaround:
sudo sysctl -w kernel.apparmor_restrict_unprivileged_unconfined=0
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
But the general advice is to make an apparmor profile. Perhaps this is something nsjail can do?
Unfortunately nsjail does not support AppArmor profiles at this moment (I believe they would be happy to do so). If you are running things via Docker (I guess you are not, but still maybe worth documenting it here) you can use --security-opt apparmor=unconfined
.
I also believe there should be some way to disable AppArmor just for a single process. An alternative is to create an empty profile for it as well.
Some commands from here may be helpful: https://www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/
Thanks @disconnect3d . We're not running in Docker. I'm running on a vanilla install of Ubuntu 24.40 here, with only the setup commands above. An empty profile sounds OK. too; thanks. Just worth knowing about this gotcha (maybe updating some docs somewhere?)
Will close now as the sysctl
disable "works" as would disabling AA entirely and probably some kind of per-process disablement too.
We have
nsjail
working on Ubuntu 20.x with cgroupsv2 (despite initially hitting issues around #196); but on an upgraded machine now running 24.x we see this (tail of a log):seemingly it can't mount the root directory (?) which seems surprising. The command is:
and the referenced cfg file is https://github.com/compiler-explorer/compiler-explorer/blob/main/etc/nsjail/compilers-and-tools.cfg (with the
log_level
set toDEBUG
).Additionally these commands were run before, to get the cgroups to work: