Skip to content

libmount: be more restrictive#4393

Open
karelzak wants to merge 4 commits into
util-linux:masterfrom
karelzak:PR/libmount-more-restrict
Open

libmount: be more restrictive#4393
karelzak wants to merge 4 commits into
util-linux:masterfrom
karelzak:PR/libmount-more-restrict

Conversation

@karelzak
Copy link
Copy Markdown
Collaborator

@karelzak karelzak commented Jun 1, 2026

No description provided.

Non-root users should only specify mountpoints when calling umount.
Device names, tags (LABEL=, UUID=, etc.) and loop device resolution
are disabled for unprivileged users to avoid processing untrusted
input through tag resolution code paths before permission checks.

In umount.c, reject tag arguments and disable swapmatch for
restricted users. In libmount, skip source and loopdev swapmatch
lookups for restricted contexts as defense in depth.

Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak karelzak marked this pull request as ready for review June 2, 2026 10:32
karelzak added 3 commits June 2, 2026 12:38
Add blkid_evaluate_tag2() that accepts flags to control tag
evaluation behavior. The BLKID_EVALUATE_NOPROBE flag disables
low-level device scanning (evaluate_by_scan), while keeping
udev symlink-based evaluation (evaluate_by_udev) functional.

The original blkid_evaluate_tag() is now a thin wrapper around
the new function with flags=0.

Signed-off-by: Karel Zak <kzak@redhat.com>
Add noprobe flag to struct libmnt_cache that disables low-level
device probing via libblkid. When the mount context is restricted
(non-root user), the flag is set automatically on cache creation
and on externally provided caches.

With noprobe enabled:
 - read_from_blkid() is skipped (device I/O blocked)
 - mnt_resolve_tag() uses blkid_evaluate_tag2() with
   BLKID_EVALUATE_NOPROBE, so tags are resolved only via
   udev /dev/disk/by-* symlinks without device scanning

This minimizes the libblkid attack surface for suid mount/umount
binaries.

Signed-off-by: Karel Zak <kzak@redhat.com>
Non-root tag resolution (LABEL=, UUID=) in mount/umount depends on
udev support in libmount. Without it, suid mount/umount cannot
resolve tags for unprivileged users since direct device probing
is disabled for security reasons.

Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak karelzak force-pushed the PR/libmount-more-restrict branch from c5deed8 to 43a652a Compare June 2, 2026 10:38
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.

1 participant