Skip to content

bwrap: Bind-mount host /dev instead of creating fresh devtmpfs#2048

Merged
ckyrouac merged 1 commit intobootc-dev:mainfrom
ckyrouac:bwrap-fix
Mar 6, 2026
Merged

bwrap: Bind-mount host /dev instead of creating fresh devtmpfs#2048
ckyrouac merged 1 commit intobootc-dev:mainfrom
ckyrouac:bwrap-fix

Conversation

@ckyrouac
Copy link
Collaborator

@ckyrouac ckyrouac commented Mar 5, 2026

Replace --dev /dev with --dev-bind /dev /dev in the bwrap container setup so that lsblk inside the sandbox can properly enumerate partition children of block devices (e.g. loop devices).

The previous approach created a minimal devtmpfs that lacked complete device information, causing ESP partition discovery to fail inside the bwrap sandbox. With a full bind-mount of host /dev, the per-device bind_device() mechanism is no longer needed and is removed.

Additionally, bind-mount /run/udev into the sandbox when it exists so that lsblk and libblkid can read the udev database for partition type GUIDs and other device properties. Without this, tools that query device metadata (e.g. PARTTYPE) would get incomplete results even with /dev properly mounted.

Assisted-by: Claude Code (Opus 4)

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request changes how bwrap sets up the /dev directory in the sandbox, switching from a minimal devtmpfs to a bind mount of the host's /dev. While this change aims to improve device visibility and allow tools like lsblk to properly enumerate partition children, it significantly weakens the security isolation by granting full access to all host devices inside the sandbox, which is a regression in the security posture. Additionally, there is a suggestion to improve error handling when checking for the existence of /run/udev to make it more robust.

cgwalters
cgwalters previously approved these changes Mar 5, 2026
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gemini had a nit, but we can also fix it after if you want as part of other things

@cgwalters
Copy link
Collaborator

No SELinux label found for: "deploy/default/deploy/1fdbcca17fd068e449e98ec7129838c0520be8d8b2536bad13d4565e5a59cb84.0/run/udev"

Hmm that's concerning that looks like we're leaking content into the target deployment root. Ah yes I think we're missing --tmpfs /run

// can read partition type GUIDs and other device properties.
if Utf8Path::new("/run/udev").try_exists()? {
cmd.args(["--bind", "/run/udev", "/run/udev"]);
cmd.args(["--tmpfs", "/run"]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually on reflection I think it's probably better to just --bind /run /run - there's just too many things there that we may want; same as what we do when in podman.

(But even if we didn't take that path, we would need to always pass the --tmpfs /run unconditionally)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea - updated

Replace `--dev /dev` with `--dev-bind /dev /dev` in the bwrap
container setup so that lsblk inside the sandbox can properly
enumerate partition children of block devices (e.g. loop devices).

The previous approach created a minimal devtmpfs that lacked complete
device information, causing ESP partition discovery to fail inside
the bwrap sandbox. With a full bind-mount of host /dev, the
per-device bind_device() mechanism is no longer needed and is removed.

Additionally, bind-mount /run/udev into the sandbox when it exists
so that lsblk and libblkid can read the udev database for partition
type GUIDs and other device properties. Without this, tools that
query device metadata (e.g. PARTTYPE) would get incomplete results
even with /dev properly mounted.

Assisted-by: Claude Code (Opus 4)
Signed-off-by: ckyrouac <ckyrouac@redhat.com>
@ckyrouac ckyrouac enabled auto-merge (rebase) March 6, 2026 18:10
@ckyrouac ckyrouac merged commit 68e2010 into bootc-dev:main Mar 6, 2026
46 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.

2 participants