Skip to content

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

Closed

Description

@nadzyah

Since v2.42, setuid mount helpers are treated as "restricted" even when they hold full root credentials. libmount then requires an /etc/fstab entry, and the mount fails. This is a regression from v2.41.3

Reproducer, with squashfs-mount (setuid root), as a non-root user:

mkdir folder && echo "Hello there" > folder/hello.txt
mksquashfs folder image.sqfs -quiet -noappend
mkdir mnt
squashfs-mount image.sqfs:mnt -- cat mnt/hello.txt

On 2.41.3 this prints Hello there. On 2.42.x it fails with mnt: can't find in /etc/fstab, which is misleading, as no fstab entry was ever needed for this mount.

The cause is in libmount/src/context.c:80:

/* v2.41.3 */
cxt->restricted = (uid_t) 0 == ruid && ruid == euid              ? 0 : 1;
/* v2.42+ */
cxt->restricted = (uid_t) 0 == ruid && !is_privileged_execution() ? 0 : 1;

is_privileged_execution() is getauxval(AT_SECURE) != 0. The two checks are not equivalent, as ruid == euid reflects current credentials, so a helper that raises its real uid to 0 before calling libmount is correctly seen as unrestricted. AT_SECURE is latched by the kernel at exec and never cleared, so the same helper now stays restricted forever. mnt_context_apply_fstab() then sets MNT_OMODE_USER, the fstab lookup misses, and the failure is flattened to MNT_ERR_NOFSTAB.

Introduced by b36add0 and 78914c8, both released in v2.42

Activity

  1. karelzak commented on Sep 17, 2026

    @karelzak
    Collaborator

    It's a good point that for a shared library, AT_SECURE is a bad choice.

    The best would be to have mnt_contect_set_restricted(cxt, is_privileged_execution() ); in tools like /bin/mount rather than in the library, which has to be more portable.

  2. added
    BLOCKER
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BLOCKER

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions