Skip to content

Use O_PATH when opening parent directories - #807

Merged
smcv merged 2 commits into
containers:mainfrom
smcv:issue806
Sep 25, 2026
Merged

smcv merged 2 commits into
containers:mainfrom
smcv:issue806

Conversation

@smcv

@smcv smcv commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator
  • Use O_PATH when opening parent directories

    Otherwise we need read permission on every path component from the root
    to the mount point. This isn't available if we are mounting onto the
    $TMPDIR created by pam_tmpdir or pam_mktemp, which create a
    root-owned directory with a+x but not a+r permission, and then a
    per-uid directory inside that.

    Resolves: 0.12.0 regression?: Can't bind-mount a directory whose parent is unreadable #806
    Resolves: Regression for users of pam_tmpdir or pam_mktemp ValveSoftware/steam-runtime#855

  • Also add O_CLOEXEC while I'm changing these lines already

    In this case it has no functional effect, because we close these fds
    with cleanup_fd before exec'ing anything (either within this function
    or in its only caller), but it's good to get into a habit of making
    all fds be close-on-exec except for the few that we specifically want
    to allow child processes to inherit.

cc @ao2

Otherwise we need read permission on every path component from the root
to the mount point. This isn't available if we are mounting onto the
`$TMPDIR` created by `pam_tmpdir` or `pam_mktemp`, which create a
root-owned directory with `a+x` but not `a+r` permission, and then a
per-uid directory inside that.

Fixes: c77dd38 "setup: Use O_PATH fds and disalllow symlink targest"
Resolves: containers#806
Resolves: ValveSoftware/steam-runtime#855
Signed-off-by: Simon McVittie <smcv@collabora.com>
In this case it has no functional effect, because we close these fds
with `cleanup_fd` before exec'ing anything (either within this function
or in its only caller), but it's good to get into a habit of making
all fds be close-on-exec except for the few that we specifically want
to allow child processes to inherit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
@ao2

ao2 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

The changes look good to me, I cannot approve formally because I am not a reviewer of this PR.

@smcv

smcv commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

I'll merge this based on my colleague @ao2's review if there's no response from other maintainers for a while.

(I suspect that in practice this mainly affects the Steam Runtime, in which we use a local build of bubblewrap and have cherry-picked these changes.)

@smcv
smcv merged commit 0f8073d into containers:main Sep 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression for users of pam_tmpdir or pam_mktemp 0.12.0 regression?: Can't bind-mount a directory whose parent is unreadable

3 participants