libmount: be more restrictive#4393
Open
karelzak wants to merge 4 commits into
Open
Conversation
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>
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>
c5deed8 to
43a652a
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.
No description provided.