Repository navigation
Conversation
Add a nosymfollow entry to decode_mountoptions so the flag is not dropped on a fixup remount. Added a regression test, binding a `nosymfollow` tmpfs read-only (therefore forcing a fixup remount) that fails if symlink is followed. Signed-off-by: Tomas Junnonen <tomas1@gmail.com>
1ab2a54 to
3579e14
Compare
|
This should be partially solved already by #756: if I understand correctly, we'll now preserve |
|
To force the test onto the fallback code path, you could do it twice, with and without Because of the way you've structured the test, if bubblewrap is compiled to require a modern kernel and not fall back if |
Those PRs have now both been merged (and will be part of bubblewrap 0.13.0). You could rebase this if you are still interested in the case where
|
|
I'd misremembered which kernels have which features. We need 5.12 for |
| ok "--symlink doesn't overwrite a conflicting symlink" | ||
|
|
||
| # A nosymfollow source must stay nosymfollow across the fixup remount | ||
| if unshare -rm sh -c 'mount -t tmpfs -o nosymfollow tmpfs /tmp && : >/tmp/x && ln -s x /tmp/l && '"$BWRAP"' --ro-bind / / cat /tmp/l' 2>/dev/null; then |
There was a problem hiding this comment.
The test can pass without exercising the regression: a failure in unshare, mount, or Bubblewrap setup also falls through to ok. I reproduced the fallback regression against current main (1fb0aa2), built with assume_kernel=5.11.0, using the same local mount-setup adaptations for both comparisons: The normal path already preserves nosymfollow; the forced fallback reproduces the remaining regression.
| Path | Without fix | With fix |
|---|---|---|
| Normal mount_setattr() | ELOOP | ELOOP |
| Forced fallback (--debug-opt=force-mount-setattr-fallback) | Symlink followed | ELOOP |
When bubblewrap binds a host mount that was mounted
nosymfollow(for example systemd credential mounts), the flag is silently cleared inside the sandbox whenever the bind triggers bubblewrap's flag-fixup remount.Example:
Expected: the sandbox refuses to follow the symlink (
ELOOP), just like the host.Actual: the sandbox prints
secret, asnosymfollowwas dropped.This happens because
decode_mountoptionsparses the mount's flags from/proc/self/mountinfothrough a table that has nonosymfollowentry. The fixup remount then passes only the decoded flags andnosymfollowis cleared. The fix is to add the table entry. A test entry for the case is also added to test-run.sh for good measure.