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
[BUG] rm -r of a symlink that points at a direct-bind root deletes the bound host directory #385
As in bash: test -L is 0, rm -r /tmp/lb removes only the link, and /tmp/ia on the host is untouched.
Actual Behavior
test -L prints 1. rm -r /tmp/lb exits 0, the link /tmp/lb is still there (readlink prints /b), and the host directory /tmp/ia is gone with everything in it (ls: cannot access '/tmp/ia').
In the file-bind variant rm /tmp/lhf exits 0, deletes the host file /tmp/ib/hf, and leaves the link.
Everything deleted is inside the bind, so this is not a containment escape, but it is silent loss of the bound host data from a command that should only remove a link.
Additional Context
The exact-match branch of VfsKernel::resolve_host (src/vfs_kernel.rs:55) calls vfs.resolve(abs_path, true), which follows an in-memory symlink to the HostDir/HostFile inode. lstat, remove_file and remove_dir all go through it, so they see and act on the bind root rather than the link. A link to a path below the bind root (ln -s /b/d /tmp/x; rm -r /tmp/x) is fine.
Found while reviewing #377. That PR fixes host symlinks inside a bind; this case (an in-memory link pointing at the bind) behaves the same with and without it, except that with #377 the removal no longer stops at host links inside the tree.
Possible Solution
In lstat, remove_file and remove_dir, resolve the in-memory path without following the last component first (vfs.resolve(&abs, false)), and only take the host path when that inode is itself the HostDir/HostFile, not a symlink to it.
Activity