-
Notifications
You must be signed in to change notification settings - Fork 242
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
--bind
can cause bwrap to fail during startup if it races with the mount table changing
#650
Comments
--bind
can cause bwrap to crash during startup if it races with the mount table changing--bind
can cause bwrap to fail during startup if it races with the mount table changing
Retitled because this is a graceful failure (inasmuch as anything bwrap does is ever graceful), not really a crash.
In principle yes, but we need to be careful with making bwrap more robust against unexpected situations, because when it's used as a sandboxing tool (a security boundary), it's better for it to fail to start than to start successfully but without the desired security properties. I'm not sure whether |
The hole recursive apply flags topic (which all drawbacks like #384) can be avoided on kernels with struct mount_attr attr = {
.attr_clr = 0,
.attr_set = MOUNT_ATTR_NODEV | MOUNT_ATTR_NOSUID | MOUNT_ATTR_NOEXEC,
};
mount_setattr(CWD, "/newroot/foobar", AT_RECURSIVE, &attr, sizeof(attr);
if (errno == ENOSYS)
recursive_remount() |
Please do send a pull request if you have a |
Unfortunately not. And my C skills are too limited. |
Yeah, that sounds totally reasonable; in this case though the specific error is that the mount point is just not found, which is hopefully different enough from "the mount point exists but we failed to mount it" that we can continue? I can see how this is tricky from the security standpoint if we cannot easily pinpoint the cause of the error. For my use case, I resorted to heuristically detecting this condition by parsing bwrap's stderr, which is obviously a sad hack. |
Yeah, sorry, if there is any doubt, we have to "fail closed". Sysadmins and users are trusting bubblewrap to provide the security boundary that was asked for. If you can put together a PR to handle this more gracefully (either by using |
Try running this in one terminal to cause the mount table to change frequently:
And run bwrap repeatedly in another terminal:
This likely happens because the
bind_mount
function grabs the current mount table (bubblewrap/bind-mount.c
Line 438 in 973fe36
--bind
works recursively but fails if any of the sub-mounts fail (bubblewrap/bind-mount.c
Line 472 in 973fe36
It already checks that
errno != EACCES
; perhaps this failure can be excluded in the same way.The text was updated successfully, but these errors were encountered: