-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inserting seccomp notify filter in WSL kernel 5.15.83.1 fails with EBUSY #9548
Comments
Another data point to help debug: In WSL kernel 5.15.83.1, I tried to dump the seccomp filter for PID 1 using the seccomp-tool, but the dump fails as follows:
Though it reports a permission error, the process doing the call has CAP_SYS_ADMIN (via sudo). The same occurs when trying to dump seccomp filters for any other process in the WSL distro (i.e., can't dump the seccomp filters). In constrast, in WSL kernel 5.15.79.1, there is no error (and no filters are reported since there are none on PID 1):
|
@kelsey-steele - do you have any idea what might be going on here? |
I don't at first glance, though I'll do some investigating. |
Thanks @kelsey-steele for the help. For context, I work at Docker and came across this while doing some development work on a container runtime that uses seccomp-notify, and which we hope to support on WSL. Things were working well with WSL kernel 5.15.79.1 but broke in 5.15.83.1. |
Thank you for all the information and I appreciate your patience @ctalledo! I didn't have luck reproducing this on my current machine running the 5.15.83 WSL kernel, though I am on Win11 and may have some other differences on my environment. I have on my queue to test with a Win10 instance tomorrow. Some questions that may help me reproduce: I did get a new WSL kernel release out on Friday (5.15.90.1). If you have the ability and time to test that kernel, let me know if the issue persists. Can always be hopeful this was something caused upstream and already fixed. :) |
Hi @kelsey-steele, thanks for taking a closer look, much appreciated.
x86.
NOTE: I used the Windows Insider program to download the latest WSL kernel (5.15.83.1) a couple of weeks ago.
I didn't go back to 5.15.79; rather, my Windows dev machine had 5.15.79.1 and things were working perfectly. I then upgraded to 5.15.83.1 and noticed the problem. I then tried on another Windows machine with 5.15.79.1 and things worked there too.
The issue is present in all distros on the machine where the WSL kernel is 5.15.83.1 (Ubuntu distro, docker-desktop's custom distro, etc.) I believe that's because it's a kernel level problem and all distros are sharing the same kernel.
Sure, let me give that a try and report. Thanks again! |
@kelsey-steele: how do I update the WSL kernel to that release? I tried |
@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:
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. |
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 Thanks! |
Thinking out loud, I wonder if the init process in the WSL distro (PID 1) is inserting that seccomp filter. I assume it's a custom init process for WSL, is the code for it available so I can take a look? I believe also that the init process is the same for all WSL distros correct? |
@ctalledo I was able to reproduce this. This requires WSL 1.1.0 or later to reproduce. I tested rolling the kernel back to 5.15.79.1 while on WSL 1.1.0 and 1.1.2 which did not resolve the problem. However, once I rolled the WSL version back to 1.0.3, the seccomp filter on PID 1 reports as expected (with 0) with each kernel (5.15.79.1 - 5.15.90.1) I believe your thinking is on the right path. I also believe the portion of code that needs to be examined is closed and needs to be checked on our side, though I very much appreciate all your help to debug! For the question if the init process is the same for all WSL distros, that escapes a bit out of my current knowledge. @benhillis do you have an answer for this? @benhillis I see in the WSL 1.1.0 release notes there is a change "Use seccomp in localhost relay". Can I get help investigating that patch to see if it's linked here? @ctalledo for a temporary fix, I'd advise rolling WSL back to 1.0.3:
edit: your distro installs should be ok throughout this process, though it's always smart to backup first just in case. You can use "wsl --export <Distro> <FileName>" to accomplish that. :) @benhillis if there's a more appropriate route for downgrading WSL, please correct me. :) |
Hi @kelsey-steele, thanks for the update, glad you were able to reproduce it.
Got it; I can confirm that my machine where it fails has WSL 1.1.2.0, while the machine where it passes has WSL 1.0.3.0.
Got it, thanks for letting me know. To help a bit more: The problem is that when installing a seccomp-notify filter into the WSL kernel we are getting back EBUSY. Per seccomp(2), this occurs when there is prior seccomp-notify filter already installed for the process:
I suspect that PID 1 in the WSL distros is already under such a filter (as evidenced by the output of
Thanks; this will work for me, but since we are planning to have Docker Desktop on WSL use seccomp-notify very soon, we are hoping for a fix so that our customers can get to use it without having to worry about what version of WSL they have. Thanks again for the help so far! |
@ctalledo appreciate the extra information! Sounds like the code that introduced this issue has been isolated and there should be a fix out soon. This is being handled on the WSL side (I'm kernel side), though I'll keep an eye on this and post back with updates. |
Perfect, thanks @kelsey-steele, much appreciated! |
Hi @ctalledo! A 1.1.3 WSL Pre-Release was put out yesterday. Can you please verify your issue is resolved with this version? You should be able to switch to it with an update if you're still on the windows pre-release channel or manually install the release with the same instructions a few comments back for rolling the WSL version back. |
Thanks @kelsey-steele! Let me try that tomorrow and get back to you. |
Hi @ctalledo! Following up to see if you were able to test the WSL 1.1.3 pre-release? |
Hi @kelsey-steele, was just about to report; yes, things work with WSL 1.1.3. I can see that in a WSL distro, PID 1 is no longer under a seccomp filter:
Moreover, the container runtime we are developing can now insert seccomp-notify filters in the WSL distro as expected? Thanks so much for the help with this! Should we mark this issue as resolved, or should we wait for WSL 1.1.3 to be formally released. BTW, do you know when that would be? Thanks again! |
Great news! I'll go ahead and close this. The release date depends on how testing is going on the latest pre-release, so I don't have a direct answer for that. Hopefully it's going well and we'll see the next release soon! :) |
Got it, thanks @kelsey-steele for all the help with this issue, much appreciated! |
Occurring again, could not re-open this issue, hence opened a new one: #11434 initially:
Running any container results into an error message:
Checking init process properties reveals the expected output:
Thanks for looking into this again. |
Hi @MrElectronics, I am not able to repro on WSL (same version as yours). However, a user commented in this Sysbox issue that having When the user removed |
I'm the user @ctalledo mentioned and I can reliably reproduce the problem, using latest WSL pre-release to date. I'm happy to provide any information necessary. |
Issue remains with WSL 2.3.11. ❯ uname -r
6.6.36.3-microsoft-standard-WSL2
❯ docker run --rm -it --runtime=sysbox-runc ghcr.io/felipecrs/devcontainer:2
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: container_linux.go:439: starting container process caused: init_linux.go:663: loading seccomp notification rules caused: error loading seccomp filter into kernel: error loading seccomp filter: device or resource busy: unknown. |
When investigating this last time, the fix was provided on the WSL side instead of the kernel. Removing my assignment here. @craigloewen-msft @benhillis pinging for attention and help here please. |
Hi @craigloewen-msft, @benhillis, This is Cesar Talledo from Docker. Wondering if there had been any more investigation into this issue, as a Docker Desktop customer that uses WSL with
The problem is caused by Docker Desktop trying to insert a seccomp-unotify filter into the Linux kernel in the WSL distro, but this fails because there's already a similar filter unexpectedly installed in the distro. For example, as soon as I start a new WSL distro (when using
That's unexpected, there should be no seccomp filters installed on a virgin WSL distro. If I remove the
Would really appreciate any insights into this, thanks! |
Hi @craigloewen-msft, @benhillis, sorry to bother but any feedback on my prior comment? Thanks! |
Issue still happens with WSL 2.5.1 (Linux 6.6.75). |
hello @ctalledo, sorry for the delay following up can you please share more details about the Docker scenario/s affected by this thanks |
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 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. |
Version
Microsoft Windows [Version 10.0.22621.1245]
WSL Version
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:
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):
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:
Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: