Repository navigation
gofer, overlay: Fail directory opens of bind-mounted files and magic links - #17520
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
test/cl1019703700
branch
6 times, most recently
from
November 15, 2026 13:45
65203e3 to
96f7222
Compare
…links Linux fails open(2) with ENOTDIR when the path ends at a file and has O_DIRECTORY or a trailing slash. Gofer and overlay skipped that check when the walk ended at its starting dentry, which happens at the root of a file bind mount and after a magic link like /proc/self/fd/N, so those opens succeeded. OpenAt now checks MustBeDir there too, as tmpfs, kernfs and erofs already do. I don't know of anything that hits this in practice, but container runtimes bind mount files like /etc/hostname into every container. Tested: the new mount and open tests fail on runsc without the fix and pass with it on native, ptrace, systrap, systrap_directfs and systrap_overlay, and make lint passes. Auto-fixed-by: [🤖] @EtiennePerot FUTURE_COPYBARA_INTEGRATE_REVIEW=#17249 from edaniels:gofer-overlay-mount-root-mustbedir 61027b3 PiperOrigin-RevId: 1019703700
copybara-service
Bot
force-pushed
the
test/cl1019703700
branch
from
November 15, 2026 18:39
96f7222 to
1542a9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gofer, overlay: Fail directory opens of bind-mounted files and magic links
Linux fails open(2) with ENOTDIR when the path ends at a file and has O_DIRECTORY or a trailing slash. Gofer and overlay skipped that check when the walk ended at its starting dentry, which happens at the root of a file bind mount and after a magic link like /proc/self/fd/N, so those opens succeeded. OpenAt now checks MustBeDir there too, as tmpfs, kernfs and erofs already do.
I don't know of anything that hits this in practice, but container runtimes bind mount files like /etc/hostname into every container.
Tested: the new mount and open tests fail on runsc without the fix and pass with it on native, ptrace, systrap, systrap_directfs and systrap_overlay, and make lint passes.
Auto-fixed-by: [🤖] @EtiennePerot
FUTURE_COPYBARA_INTEGRATE_REVIEW=#17249 from edaniels:gofer-overlay-mount-root-mustbedir 61027b3