You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failing (and invisible in strace) clone syscall related to privileged namespaces and chrome's setuid sandbox #2242
We already knew that chromium couldn't be launched with its usual sandbox due to the fact that user namespaces aren't implemented. I assumed privileged namespaces were not completely implemented either, though I had heard some of the devs say that privileged namespaces as a concept already exist in the underlying native NT context.
Chromium also includes a setuid sandbox implementation for kernels that don't implement user namespaces (notably Arch, though I used a clean Ubuntu Xenial image to do this test), and you can launch chromium in this way with the flag --disable-namespace-sandbox, which disables the user namespace sandbox but enables the classic setuid sandbox.
In the user namespace sandbox case, we also get a line in between that actually shows the failing syscall:
we get (among other errors, I know) that there is a clone syscall receiving an invalid parameter or option.
But when you look into the strace, there's no EINVAL on a Clone syscall, so somewhere some clone syscall is failing on unimplemented surface but is also failing to be picked up in the strace, unlike in the namespace sandbox case.
or is it just reporting a clone problem incorrectly?
Maybe. But probably not. That error message to stderr didn't come from divine intervention. But either way that particular execve succeeds on Real Linux and fails on WSL.
Note chrome goes out of it's way to thwart strace when running sandboxed (either kind), so what you could be seeing is a successful execve when not under strace on WSL, and then a subsequent clone fail, for reasons. As I mentioned, bog standard suid proper works on WSL, as far as it goes. The arguments passed to clone calls preceding the execve don't look that noteworthy from an EINVAL standpoint, AFAICT.
All of which would be noteworthy if I thought Stephen actually put chrome in play.
Oh, by the way, an update: I contacted the chromium security team, and they confirmed that the setuid sandbox will continue to be included for the foreseeable future, but they have no plans to patch it. It will be removed probably when it accumulates enough bugs or breakages or security flaws as to become counterproductive (unless someone wants to take up the responsibility of maintaining patches for it).
I haven't yet forwarded the email I received to the Arch kernel and chromium maintainers (real life intervened and I forgot), but I can probably get an answer back in the next week or so to find out what they're going to do. If they plan to stick with the setuid sandbox also for the foreseeable future, WSL supporting it should keep WSL compatible with chromium (by reporting from the kernel that user namespaces are disabled and therefore letting chromium fall back gracefully to the setuid sandbox).
The security-focused guys (like the maintainer of the linux-hardened package for Arch) have told me that they feel that user namespaces are insecure by design (and indeed they have been exploited a few times in the past two years).
I'll ping the WSL team with the conclusion of my investigation once I get an answer from the Arch people.
Amusingly enough Ben Hillis (@benhillis)' work on #962 moved this forward. 16251 now gets over the execve(). Actually if I was a little quicker on the uptake I would have thought of #962 when I saw the EPERM. Same mode of failure.
Having missed that, I did get the "subsequent clone()" failure hypothesis right. Child stack of zero Actually it was CLONE_FS. Don't think I have seen that before.
Since I am here, I have to underline this ticket has nada to do with "namespaces", even though the word is used 18 times in this thread so far including in the issue title (so says ctrl-f). The whole point of --disable-namespace-sandbox is you are on a kernel without them. Eye on the ball.
therealkenc I'm not sure how the suid sandbox works exactly on-the-nose, but my (possibly incorrect) understanding is that it makes explicit use of the privileged namespace functionality to construct a secure chroot in which the renderer process runs.
CLONE_NEWPID method
The sandbox does three things to restrict the authority of a sandboxed process. The SUID helper is responsible for the first two:
The SUID helper chroots the process. This takes away access to the filesystem namespace.
The SUID helper puts the process in a PID namespace using the CLONE_NEWPID option to clone(). This stops the sandboxed process from being able to ptrace() or kill() unsandboxed processes.
In addition:
The Linux Zygote startup code sets the process to be undumpable using prctl(). This stops sandboxed processes from being able to ptrace() each other. More specifically, it stops the sandboxed process from being ptrace()'d by any other process. This can be switched off with the --allow-sandbox-debugging option.
So in particular, what I was asking was if privileged namespaces were the problem (in this case, I guess, the PID namespace).
Oh I see what you mean. Yeah that counts, and "nada" is clearly overstated. It would be more correct to say "the problem right now is not related to namespaces". So apologies for that.
[n.b. I just didn't want to see this ticket go down the same path as #1962, which is a mount -t drvfs bug/limitation. An otherwise useful ticket with an actionable problem was lost because an unrelated four letter acronym was repeated two dozen times.]
All I know about the User Namespace functionality is that it could conceptually make sandboxes/containers easier to construct and work with, but also that they have already been escaped/exploited numerous times in the past 3-4 years and have been one of the largest sources of Linux Kernel CVEs. I've spoken with some of the Linux-Hardened patchset (the successor to grsecurity) maintainers, and they have argued that User Namespaces will continue to be insecure because they are conceptually flawed, rather than flawed in implementation. I don't know myself, but that seems to be the opinion of security-minded people.
Anyway, quick question: Does WSL support PID namespaces? I could have sworn you commented recently to Ben that it's not and should probably be as part of the requirements to support systemd.
I didn't thinkCLONE_NEWPID was supported. Now I'm not so sure. If you open a SUSE distro and a Ubuntu distro (installed from the Store) at the same time, you get two isolated PID 1 processes. Because of course you do. For all intents, they're containers. Looking into it.
Haha that's super cool. I also noticed on that page there's a launch flag to start up the suid sandbox in a way that allows it to be ptraced, so if I try to trace it again in the new build, I'll turn that on too.
So if they wanted to add nspawn/rkt support, I looked into it:
They need the multiple devpts mount support, network namespace support as part of the base systemd requirements, and the following additional namespaces:
UTS
PID
mount
IPC
From your research here it looks like PID and mount namespaces are implemented. How about UTS, IPC, and Network namespaces?
CLONE_NEWUTS, CLONE_NEWIPC, CLONE_NEWPID, CLONE_NEWNS all work. I am actually a little embarrassed I didn't notice. I have not tried CLONE_NEWNET because it is academic in the context of WSL.
Need some more bits for systemd though. I did a short run at it last night but my heart wasn't in it. But take that over to #994.
From your first post, the issue here was and remains:
Haha! That's pretty cool! So maybe I should close this thread, and you could just open a new issue for just that CLONE_FS|SIGCHLD pattern, which is much more specific.
PS does unshare()ing those other kernel namespaces work as expected as well?
therealkenc - I liked your idea of stubbing netlink support so I decided to see what would happen if I allowed creation of NETLINK_KOBJECT_UEVENT netlink sockets that will never receive any messages. With that change and the CLONE_FS change I above I'm able to launch chromium without any workarounds.
Unfortunately I can't do a similar think for all netlink families. For example, allowing creation of NETLINK_AUDIT sockets but don't actually support the messages opens worms (sudo, adduser, passwd all start failing).
I'm submitting a CR for this change now.
Reacted by fpqc, Sunil Muthuswamy, therealkenc and Eddie Carswell
...above I'm able to launch chromium without any workarounds.
Most excellent. But you forgot the PulseAudio .deb you installed. Which to fix, you need to stub priority futexes per #1006 (message) to behave like the normal kind. I am pretty sure user space won't tell the difference. I know Pulse doesn't anyway, because that's what the .deb you installed does.
That's the end of the hard blockers though. The rest of the messages you see in the console is one soft fail, plus configuration problems that would manifest on real Linux (including OpenGL).
therealkenc - I did not have to apply the pulseaudio .deb to get chrome to launch. Chrome launches but per your assertion I'm assuming remote audio will not work without said futex change?
Ben Hillis (@benhillis)
It is in your screencap. The postinstall script failed but I I am pretty sure (but can't prove) that unpacking libpulse0:amd64 (1:8.0-0ubuntu3.2ppa1) over (1:10.0-1ubunut2) took and swapped out libpulse. The dependency problems are because your Ubuntu distro has been upgraded since I put up that .deb in May. I quietly (without announcement) updated the PPA on July 7. Instructions to install it 'properly' here. Unless you moved on to Ubuntu 17.04. You see the problem.
It isn't 'remote audio' per se. The problem (IMO Google bug) is that chrome faceplants on #486 whether you want to hear noises from your webpages or not. Contrast Firefox which recovers. You don't need the server side up and running. You just need to get past the futex() call that libpulse (the client) makes.
therealkenc - You're correct my screencap was from a machine that I was testing some things on 17.04 in parallel. However my assertion that google-chrome launches without workarounds was based on trying this on a 16.04 install with none of your workarounds:
I am seeing the FUTEX_CMP_REQUEUE errors in the strace but chrome seems to be handling it OK.
Okay understood. It is possible (probable, even) that Google fixed it along the way and I never noticed because I've had the libpulse PPA sitting there (not making actual sounds) for all these months. The only reason I did the PPA was to get over the futex() hard fail. I say declare victory and go home.
[edit] Or Stephen fixed futex() and didn't tell anyone (laugh).
How hard can it be. I have been thinking at least faking it should be possible since Sept 2016 (message).
I just put up some theoretic install instructions for chrome (theoretic, because I have never run them in sequence). But if you pick out the OpenGL and dbus session setup good bits, you should be at console warning parity with Real Linux. "Should be", with the singular exception of #1353 (zombies). But oddly I am not seeing that (soft) fail in your screencap either. Typically it looks like:
[2644:2677:0803/125126.647021:ERROR:process_posix.cc(194)] Not implemented reached in bool (anonymous namespace)::WaitForExitWithTimeoutImpl(base::ProcessHandle, int *, base::TimeDelta)
[2644:2673:0803/125126.766243:ERROR:process_posix.cc(194)] Not implemented reached in bool (anonymous namespace)::WaitForExitWithTimeoutImpl(base::ProcessHandle, int *, base::TimeDelta)
Activity
therealkenc commentedon Jun 21, 2017
This is the fail:
I didn't track it very far. Takes on Real Linux natch. Running suid binaries on WSL works as far as it goes.
In any case, the suid sandbox is nearly dead. Still be valuable (on its own merits) looking into why the
execvegoes south.therealkenc commentedon Jun 21, 2017
Oh yeah, repro:
fpqc commentedon Jun 22, 2017
Yeah, I was mainly interested to see if privileged namespace functionality was working at all.
So is this a clone problem, or is it just reportinga clone problem incorrectly?
therealkenc commentedon Jun 22, 2017
Maybe. But probably not. That error message to
stderrdidn't come from divine intervention. But either way that particularexecvesucceeds on Real Linux and fails on WSL.Note chrome goes out of it's way to thwart
stracewhen running sandboxed (either kind), so what you could be seeing is a successfulexecvewhen not understraceon WSL, and then a subsequent clone fail, for reasons. As I mentioned, bog standard suid proper works on WSL, as far as it goes. The arguments passed toclonecalls preceding theexecvedon't look that noteworthy from anEINVALstandpoint, AFAICT.All of which would be noteworthy if I thought Stephen actually put chrome in play.
fpqc commentedon Jul 14, 2017
Oh, by the way, an update: I contacted the chromium security team, and they confirmed that the setuid sandbox will continue to be included for the foreseeable future, but they have no plans to patch it. It will be removed probably when it accumulates enough bugs or breakages or security flaws as to become counterproductive (unless someone wants to take up the responsibility of maintaining patches for it).
I haven't yet forwarded the email I received to the Arch kernel and chromium maintainers (real life intervened and I forgot), but I can probably get an answer back in the next week or so to find out what they're going to do. If they plan to stick with the setuid sandbox also for the foreseeable future, WSL supporting it should keep WSL compatible with chromium (by reporting from the kernel that user namespaces are disabled and therefore letting chromium fall back gracefully to the setuid sandbox).
The security-focused guys (like the maintainer of the linux-hardened package for Arch) have told me that they feel that user namespaces are insecure by design (and indeed they have been exploited a few times in the past two years).
I'll ping the WSL team with the conclusion of my investigation once I get an answer from the Arch people.
therealkenc commentedon Jul 27, 2017
Amusingly enough Ben Hillis (@benhillis)' work on #962 moved this forward. 16251 now gets over the
execve(). Actually if I was a little quicker on the uptake I would have thought of #962 when I saw theEPERM. Same mode of failure.Having missed that, I did get the "subsequent
clone()" failure hypothesis right.Child stack of zeroActually it wasCLONE_FS. Don't think I have seen that before.So fpqc now ya know.
Since I am here, I have to underline this ticket has nada to do with "namespaces", even though the word is used 18 times in this thread so far including in the issue title (so says
ctrl-f). The whole point of--disable-namespace-sandboxis you are on a kernel without them. Eye on the ball.fpqc commentedon Jul 27, 2017
therealkenc I'm not sure how the suid sandbox works exactly on-the-nose, but my (possibly incorrect) understanding is that it makes explicit use of the privileged namespace functionality to construct a secure chroot in which the renderer process runs.
In particular, from the suid sandbox page
So in particular, what I was asking was if privileged namespaces were the problem (in this case, I guess, the PID namespace).
therealkenc commentedon Jul 28, 2017
Oh I see what you mean. Yeah that counts, and "nada" is clearly overstated. It would be more correct to say "the problem right now is not related to namespaces". So apologies for that.
[n.b. I just didn't want to see this ticket go down the same path as #1962, which is a
mount -t drvfsbug/limitation. An otherwise useful ticket with an actionable problem was lost because an unrelated four letter acronym was repeated two dozen times.]fpqc commentedon Jul 28, 2017
All I know about the User Namespace functionality is that it could conceptually make sandboxes/containers easier to construct and work with, but also that they have already been escaped/exploited numerous times in the past 3-4 years and have been one of the largest sources of Linux Kernel CVEs. I've spoken with some of the Linux-Hardened patchset (the successor to grsecurity) maintainers, and they have argued that User Namespaces will continue to be insecure because they are conceptually flawed, rather than flawed in implementation. I don't know myself, but that seems to be the opinion of security-minded people.
Anyway, quick question: Does WSL support PID namespaces? I could have sworn you commented recently to Ben that it's not and should probably be as part of the requirements to support systemd.
therealkenc commentedon Jul 28, 2017
I didn't think
CLONE_NEWPIDwas supported. Now I'm not so sure. If you open a SUSE distro and a Ubuntu distro (installed from the Store) at the same time, you get two isolated PID 1 processes. Because of course you do. For all intents, they're containers. Looking into it.therealkenc commentedon Jul 28, 2017
Yep. Funny thing, I think maybe it's been there for a while. And to answer your next question, I'm looking into it.
fpqc commentedon Jul 29, 2017
Haha that's super cool. I also noticed on that page there's a launch flag to start up the suid sandbox in a way that allows it to be ptraced, so if I try to trace it again in the new build, I'll turn that on too.
fpqc commentedon Jul 29, 2017
therealkenc
So if they wanted to add nspawn/rkt support, I looked into it:
They need the multiple devpts mount support, network namespace support as part of the base systemd requirements, and the following additional namespaces:
UTS
PID
mount
IPC
From your research here it looks like PID and mount namespaces are implemented. How about UTS, IPC, and Network namespaces?
therealkenc commentedon Jul 29, 2017
CLONE_NEWUTS,CLONE_NEWIPC,CLONE_NEWPID,CLONE_NEWNSall work. I am actually a little embarrassed I didn't notice. I have not triedCLONE_NEWNETbecause it is academic in the context of WSL.Need some more bits for
systemdthough. I did a short run at it last night but my heart wasn't in it. But take that over to #994.From your first post, the issue here was and remains:
...full stop...
fpqc commentedon Jul 30, 2017
Haha! That's pretty cool! So maybe I should close this thread, and you could just open a new issue for just that CLONE_FS|SIGCHLD pattern, which is much more specific.
PS does unshare()ing those other kernel namespaces work as expected as well?
12 remaining items
fpqc commentedon Aug 2, 2017
Ah, neat!
benhillis commentedon Aug 2, 2017
therealkenc - I liked your idea of stubbing netlink support so I decided to see what would happen if I allowed creation of NETLINK_KOBJECT_UEVENT netlink sockets that will never receive any messages. With that change and the CLONE_FS change I above I'm able to launch chromium without any workarounds.
Unfortunately I can't do a similar think for all netlink families. For example, allowing creation of NETLINK_AUDIT sockets but don't actually support the messages opens worms (sudo, adduser, passwd all start failing).
I'm submitting a CR for this change now.
therealkenc commentedon Aug 3, 2017
Most excellent. But you forgot the PulseAudio
.debyou installed. Which to fix, you need to stub priority futexes per #1006 (message) to behave like the normal kind. I am pretty sure user space won't tell the difference. I know Pulse doesn't anyway, because that's what the.debyou installed does.That's the end of the hard blockers though. The rest of the messages you see in the console is one soft fail, plus configuration problems that would manifest on real Linux (including OpenGL).
benhillis commentedon Aug 3, 2017
therealkenc - I did not have to apply the pulseaudio .deb to get chrome to launch. Chrome launches but per your assertion I'm assuming remote audio will not work without said futex change?
therealkenc commentedon Aug 3, 2017
Ben Hillis (@benhillis)
It is in your screencap. The postinstall script failed but I I am pretty sure (but can't prove) that
unpacking libpulse0:amd64 (1:8.0-0ubuntu3.2ppa1) over (1:10.0-1ubunut2)took and swapped outlibpulse. The dependency problems are because your Ubuntu distro has been upgraded since I put up that.debin May. I quietly (without announcement) updated the PPA on July 7. Instructions to install it 'properly' here. Unless you moved on to Ubuntu 17.04. You see the problem.It isn't 'remote audio' per se. The problem (IMO Google bug) is that chrome faceplants on #486 whether you want to hear noises from your webpages or not. Contrast Firefox which recovers. You don't need the server side up and running. You just need to get past the
futex()call thatlibpulse(the client) makes.benhillis commentedon Aug 3, 2017
therealkenc - You're correct my screencap was from a machine that I was testing some things on 17.04 in parallel. However my assertion that google-chrome launches without workarounds was based on trying this on a 16.04 install with none of your workarounds:

I am seeing the FUTEX_CMP_REQUEUE errors in the strace but chrome seems to be handling it OK.
therealkenc commentedon Aug 3, 2017
Okay understood. It is possible (probable, even) that Google fixed it along the way and I never noticed because I've had the
libpulsePPA sitting there (not making actual sounds) for all these months. The only reason I did the PPA was to get over thefutex()hard fail. I say declare victory and go home.[edit] Or Stephen fixed
futex()and didn't tell anyone (laugh).benhillis commentedon Aug 3, 2017
I'm taking a stab at implementing the futex requeue options, doesn't look like it should be too bad (famous last words).
therealkenc commentedon Aug 3, 2017
How hard can it be. I have been thinking at least faking it should be possible since Sept 2016 (message).
I just put up some theoretic install instructions for chrome (theoretic, because I have never run them in sequence). But if you pick out the OpenGL and dbus session setup good bits, you should be at console warning parity with Real Linux. "Should be", with the singular exception of #1353 (zombies). But oddly I am not seeing that (soft) fail in your screencap either. Typically it looks like:
So you are ahead of the game on a few fronts.
fpqc commentedon Aug 24, 2017
Ben Hillis (@benhillis) should be good to close up shop on this thread as well with a fixedininsiders flag
benhillis commentedon Aug 24, 2017
fpqc - will do, thanks!