Skip to content

libmount: keep AT_SECURE policy in mount tools - #4687

Merged
karelzak merged 1 commit into
util-linux:masterfrom
qiyuhuating:fix/libmount-restricted-at-secure-4636
Oct 14, 2026
Merged

karelzak merged 1 commit into
util-linux:masterfrom
qiyuhuating:fix/libmount-restricted-at-secure-4636

Conversation

@qiyuhuating

Copy link
Copy Markdown
Contributor

Fixes #4636.

Since v2.42, mnt_new_context() folds AT_SECURE into libmount's restricted-mode decision. That is safe for the mount/umount executables, but it is the wrong lifetime for a shared-library policy: AT_SECURE is fixed at exec time, while a setuid helper may later deliberately establish full root credentials before creating a libmount context.

This keeps the two concerns separate:

  • derive libmount's default restricted mode from the current real/effective UID again;
  • add mnt_context_set_restricted() so applications can explicitly impose a stricter policy;
  • have mount(8) and umount(8) force restricted mode when is_privileged_execution() reports an AT_SECURE execution;
  • keep mnt_context_force_unrestricted() as a compatibility wrapper around the new setter;
  • export/document the new API in the current MOUNT_2_43 symbol set;
  • add a libmount context regression subtest covering the default root state and explicit restricted/unrestricted transitions.

This preserves the exec-time hardening for the util-linux mount tools while avoiding the v2.42 regression for shared-library consumers that intentionally normalize their credentials before entering libmount.

Testing

A focused libmount/context subtest is included. I have not executed the test suite locally in this environment; upstream CI should provide build and regression coverage.

@karelzak
karelzak merged commit d427f58 into util-linux:master Oct 14, 2026
34 of 35 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.

libmount: restricted-mode check via AT_SECURE breaks setuid mount helpers

2 participants