Skip to content

Keep /proc mounted in initramfs root may fix a "supplementary group member denied" permission issue #6

Description

@shunf4

Hi, it's me again. Still, I'm using Debian, so my findings may be inapplicable, or need additional adjustment/adaptation for your guide in this repository.

Recently I found my rootfs-in-subdirectory-on-ntfs Debian had a serious permission issue: when current user (actually, current process) belongs to a supplementary group (cdrom, gid 24, for example), and a directory's group is this supplementary group, the mode is group-writable (e.g. 0775), this user still couldn't write (like, create files in) this directory, with error message "permission denied".

An example, as my main user in cdrom group: sudo rm -rfi ./abc; sudo mkdir -m 0775 abc; sudo chown root:cdrom abc; touch abc/d. Failed "permission denied" on my NTFS Debian, but succeeded on other systems, or on non-ntfs mounts on the same system (like /tmp etc.)

The solution:

--- /usr/share/initramfs-tools/init.orig        2025-02-11 18:40:14.432944700 +0800
+++ /usr/share/initramfs-tools/init     2025-02-11 18:40:24.061295100 +0800
@@ -317,17 +317,17 @@
 unset resume
 unset resume_offset
 unset noresume
 unset fastboot
 unset forcefsck
 unset fsckfix
 unset starttime

 # Move virtual filesystems over to the real filesystem
-mount -n -o move /sys ${rootmnt}/sys
-mount -n -o move /proc ${rootmnt}/proc
+mount -n -o bind /sys ${rootmnt}/sys
+mount -n -o bind /proc ${rootmnt}/proc

 # Chain to real filesystem
 # shellcheck disable=SC2086,SC2094
 exec run-init ${drop_caps} "${rootmnt}" "${init}" "$@" <"${rootmnt}/dev/console" >"${rootmnt}/dev/console" 2>&1
 echo "Something went badly wrong in the initramfs."
 panic "Please file a bug on initramfs-tools."

(Of course an update-initramfs -u is needed.)

This ensures the mount.ntfs-3g process still have access to /proc starting from its / direntry, and the supplementary group permission check is functional again. Possibly related code here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions