Tested on these Docker hosts:
The cage is started with an apparmor option, so WSL2 needs AppArmor in its LSM list. The stock WSL2 kernel supports it.
apparmor
(Windows) Add the LSM list to %UserProfile%\.wslconfig:
%UserProfile%\.wslconfig
[wsl2] kernelCommandLine = lsm=apparmor,bpf,integrity,landlock,loadpin,lockdown,safesetid,selinux,tomoyo,yama
(WSL) Open /etc/fstab:
/etc/fstab
sudo nano /etc/fstab
Add the securityfs mount:
securityfs
none /sys/kernel/security securityfs defaults 0 0
(WSL) Reload systemd, so it picks up the new mount unit:
sudo systemctl daemon-reload
(Windows) Restart WSL2 in PowerShell or cmd, then open a new shell:
wsl --shutdown
(WSL) Check the result, which lists the enabled LSMs in order:
cat /sys/kernel/security/lsm
There was an error while loading. Please reload this page.