Skip to content

fix(dracut-install): Keep SUID/SGID when using FICLONE - #2840

Open
cjriches wants to merge 1 commit into
dracut-ng:mainfrom
cjriches:ntnx
Open

cjriches wants to merge 1 commit into
dracut-ng:mainfrom
cjriches:ntnx

Conversation

@cjriches

Copy link
Copy Markdown
Contributor

The FICLONE path (taken on filesystems which support it, e.g. XFS and BTRFS) does a manual fchown operation after cloning the data. This causes the kernel to drop SUID and SGID bits, even when the caller is root or the ownership is already correct. Thus, binaries that typically have these bits (e.g. /usr/bin/mount) lose them when being installed into the initramfs on these filesystems.

Reapply the original mode after chowning to prevent this.

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

@cjriches
cjriches requested a review from a team as a code owner November 23, 2026 11:51
@github-actions github-actions Bot added c dracut-install Issues related to dracut install labels Nov 23, 2026
The FICLONE path (taken on filesystems which support it, e.g. XFS and
BTRFS) does a manual fchown operation after cloning the data. This
causes the kernel to drop SUID and SGID bits, even when the caller is
root or the ownership is already correct. Thus, binaries that typically
have these bits (e.g. /usr/bin/mount) lose them when being installed
into the initramfs on these filesystems.

Reapply the original mode after chowning to prevent this.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Because the change affects preservation of privileged SUID/SGID bits in initramfs files without a focused dracut-install clone-mode test, filesystem and privilege behavior still requires human validation.

No open issues 🎉

What changed in this PR

This PR preserves SUID and SGID permission bits when dracut-install uses the FICLONE path, preventing cloned executables from losing their special modes after ownership changes.

Changes:

  • Reapply the source file’s mode with fchmod() after fchown().
  • Log fchmod() failures with the existing privilege-aware severity distinction.
File Description
src/​install/​dracut-install.c Restores the cloned file’s original permission mode, including SUID/SGID bits, after ownership updates.

Review effort: Lite

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c dracut-install Issues related to dracut install

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants