WSL: Inserting seccomp notify filter in WSL kernel 5.15.83.1 fails with EBUSY
Version
Microsoft Windows [Version 10.0.22621.1245]
WSL Version
- WSL 2
- WSL 1
Kernel Version
5.15.83.1-microsoft-standard-WSL2
Distro Version
Ubuntu 22.04
Other Software
No response
Repro Steps
Starting with WSL kernel 5.15.83.1, there is an issue inserting seccomp filters that have the “notify” action (see SECCOMP_FILTER_FLAG_NEW_LISTENER in the Linux seccomp man page). Inserting such filters returns EBUSY from the kernel.
Possible cause is that PID 1 in the WSL distro appears to have a seccomp filter attached to it by default:
wsl -d Ubuntu-22.04
$ grep -i seccomp /proc/1/status
Seccomp: 2
Seccomp_filters: 1 <<< HERE
I believe the presence of this filter on PID 1 is causing the problem: the filter is inherited by all child processes in the distro, and therefore a child process that tries to insert a seccomp notify filter (SECCOMP_FILTER_FLAG_NEW_LISTENER) gets an EBUSY response from the kernel since only one such filter per process is allowed.
The problem does NOT occur in WSL kernel 5.15.79.1. In that kernel, PID 1 has no seccomp filter on it (as expected):
$ grep -i seccomp /proc/1/status
Seccomp: 0
Seccomp_filters: 0
Expected Behavior
A process running in a WSL Linux distro should be able to insert a seccomp notify filter (SECCOMP_FILTER_FLAG_NEW_LISTENER) without problem.
In addition, PID 1 in the WSL Linux distro should not have a seccomp filter attached to it by default.
Actual Behavior
Starting with WSL kernel 5.15.83.1, inserting seccomp filters that have the “notify” action (SECCOMP_FILTER_FLAG_NEW_LISTENER) returns EBUSY from the kernel.
PID 1 in the WSL distro has an unexpected seccomp filter attached to it by default:
wsl -d Ubuntu-22.04
$ grep -i seccomp /proc/1/status
Seccomp: 2
Seccomp_filters: 1 <<< HERE
Diagnostic Logs
No response
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 32 (1 by maintainers)
Issue still happens with WSL 2.5.1 (Linux 6.6.75).
Hi @CatalinFetoiu thanks for the response.
Sure; Docker (and possibly other runtimes too) sometimes use a seccomp notify filter to trap system calls inside a container.
The Linux kernel only allows one such filter per process. And filters are inherited by child processes.
Turns out that when
networkingMode=mirroredis active, apparently WSL inserts a seccomp notify filter on PID 1 of the WSL distro. That filter is inherited by all processes in the distro (since they are all descendants of PID 1), and therefore it’s not possible to insert seccomp notify filters from within the distro (doing son returns EBUSY).Ideally, we are hoping a WSL distro behaves much like a VM, where there are no seccomp filters on PID 1.
FYI we had this same problem in the past with WSL (original description of this PR), but the WSL developers were able to fix it and remove the seccomp notify filter from PID 1. However it appears to still be occurring when the mirrored networking mode is enabled unfortunately.
Hi @MrElectronics,
I am not able to repro on WSL (same version as yours). However, a user commented in this Sysbox issue that having
networkingMode=mirroredin their%USERPROFILE%\.wslconfigwas causing the problem for him.When the user removed
networkingMode=mirrored, then Sysbox was able to insert the seccomp-notify filter into the WSL kernel.Thanks @kelsey-steele! Let me try that tomorrow and get back to you.
Hi @kelsey-steele, thanks for the detailed instructions to upgrade the WSL kernel, super clear and easy to follow.
I updated my WSL kernel to 5.15.90.1, but unfortunately still hit the same issue:
As a result, when I try to run a container with Docker Desktop on WSL, using this new runtime that uses seccomp-notify, it fails with:
Could you double check on your side if
/proc/1/statuson your WSL kernel 5.15.90.1 shows a seccomp filter on it?Thanks!
@ctalledo thank you for the additional info!
The WSL2 kernel gets released on the WSL2 kernel repo first and then will be included in the next WSL release. Currently we’re in that stage where the new kernel is so far only released on the WSL2 kernel repo. Here’s the steps you can follow to boot with the 5.15.90 WSL kernel:
Clone the WSL2 Kernel Repo
Make sure you’re on the ‘linux-msft-wsl-5.15.y’ branch or checkout the ‘linux-msft-wsl-5.15.90.1’ tag
Follow the build instructions in the WSL2 kernel README
After building, you will find your new kernel image inside the WSL2 tree at ‘arch/x86/boot/bzImage’
copy this to your windows files for easy access. i.e. $ cp arch/x86/boot/bzImage /mnt/c/Users/$USERNAME/5.15.90.1-wsl
Add the new kernel to your .wslconfig file:
Run ‘wsl --shutdown’ inside powershell
Restart your WSL instance and verify new kernel is being used: $ uname -r
These are the same steps you’d use to boot with a custom or upstream kernel on x86 machines. Just make sure to build any kernel you want to use with the config file from WSL2 (can be found in the WSL2 tree under Microsoft/config-wsl).
Let me know if you have any questions or unable to take these steps. Hoping I’ll be able to reproduce on my side today so I can poke at things.