-
Notifications
You must be signed in to change notification settings - Fork 68
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
Bubblewrap not working in strata other than init #245
Comments
Hmm, a quick look at the
This appears to be a security feature, likely to prevent unprivileged users from using user namespaces to escape chroots. Since Bedrock uses chroots to run non-init strata, this prevents creating user namespaces outside of the init strata. This check also doesn't appear to have any exceptions. It might be possible to work around it by creating a new mount namespace when switching strata, but 1) I'm not 100% sure that would work and 2) if Bedrock did that by default, it would probably break things. |
I agree that In the immediate future, work-arounds include:
Bedrock 0.7.x relies on the common mount namespace pervasively. A ready example is The design of the upcoming 0.8.x is still somewhat fluid. I can try to incorporate per-stratum mount namespaces into it, although I can't make any promises. Off the top of my head it may introduce some design regressions:
While in principle having |
While not the main focus of this issue, I should point out that neither querying for the current shell then running a command like so:
nor specifying a shell then running a command like so:
are guaranteed to get the command from the shell's stratum. Consider what happens in both those cases if $ strat debian
$ brl which
debian
$ grep "^NAME" /etc/os-release
NAME="Debian GNU/Linux"
$ pacman --help | head -n1
usage: pacman <operation> [...] Keep in mind that, despite the discussion around namespaces and chroot, Bedrock is not containers. Rather, I recommend either querying specifically about the command in question (rather than the shell): $ brl which bwrap # if I run `bwrap` in this context, which stratum provides it?
debian
$ bwrap | head -n1
usage: bwrap [OPTIONS...] [--] COMMAND [ARGS...]
$ strat test-strat
$ brl which bwrap # if I run `bwrap` in this context, which stratum provides it?
test-strat
$ bwrap | head -n1
usage: bwrap [OPTIONS...] [--] COMMAND [ARGS...] or just explicitly specifying which stratum's instance is desired: $ strat debian bwrap | head -n1
usage: bwrap [OPTIONS...] [--] COMMAND [ARGS...]
$ strat test-strat bwrap | head -n1
usage: bwrap [OPTIONS...] [--] COMMAND [ARGS...] |
I've spent some time exploring the possibility of per-stratum mount namespaces. I think I've confirmed that this fixes the issue in a local hacky test. I also think I've found a way forward. Enabling a stratum should:
In some hacky tests, I think I've confirmed we can do this by:
We also need some system to track the mount namespaces, associate them with strata, and a way for
Sadly this retains most of the regressions I was worried about earlier; I couldn't find ways around them. However, as a bonus, it might improve the system shutdown experience. I think the kernel automatically handles unmounting mount points in namespaces with no processes/tracking-mounts/file-descriptors (https://unix.stackexchange.com/questions/212172/what-happens-if-the-last-process-in-a-namespace-exits). This will likely both slightly improve shutdown time and resolve this issue. |
After thinking about this even more, I think per-stratum namespaces would also help with:
The trade-off seems more and more in favor of per-stratum namespaces. I'm going to start planning a big refactor of the 0.8 efforts in this direction. |
Bubblewrap errors when run in a stratum other than the stratum that provides init. Error message is at the bottom of the steps to reproduce. It's not clear to me why this is happening, though looking at the output of
strace
, it seems I'm gettingEPERM
on aclone
syscall withflags=CLONE_NEWNS|CLONE_NEWUSER|SIGCHLD
, which makes sense given the error message.To reproduce:
In my case, my init strat is named
debian
, using Debian stable, and I've also createdtest-strat
, also Debian stable. Both havebubblewrap
installed.The text was updated successfully, but these errors were encountered: