mode_strip_sgid(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… mode_strip_sgid β€” Kernel API Manual πŸŽ€

okay so bestie, welcome to mode_strip_sgid(9), the little kernel function that does the sgid bit vibe check for non-directories ✨


🌸 NAME 🌸

mode_strip_sgid β€” handles the sgid bit for non-directories, no cap πŸ’…


✨ SYNOPSIS ✨

umode_t mode_strip_sgid (struct mnt_idmap *idmap , const struct inode
*dir , umode_t mode );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • idmap β€” the idmap of the mount that the inode was created from πŸ—ΊοΈ
  • dir β€” the parent directory inode (the one it's all happening in) πŸ“
  • mode β€” the mode of the file that's gonna be created in dir πŸŽ€

πŸ’– DESCRIPTION πŸ’–

okay so here's the situation, and honestly it's giving permission-check main character energy πŸ‘‘

If the mode of the new file has both the S_ISGID and S_IXGRP bit raised, and dir has the S_ISGID bit raised too β€” then this function makes sure the caller is either in the group of the parent directory, or they have CAP_FSETID in their user namespace and are privileged over the parent directory. iykyk, that's the whole security vibe check πŸ›‘οΈ

In all other cases, it strips the S_ISGID bit from mode. literally just takes it right off, bye πŸ‘‹


⭐ RETURN ⭐

the new mode to use for the file β€” that's it, that's the return value πŸ’«


🌈 SEE ALSO 🌈

all the kernel file friends from ./fs/inode.c, because we support each other's slay 🫢


🧚 friendly reminder bestie: if that sgid check doesn't pass, the bit is gone, and there is no "undo" button 🫢

πŸ’œ that's the page!! this one lives in ./fs, from the Kernel API Manual, dated October 2026 β€” mode_strip_sgid(9), periodt πŸŽ€βœ¨πŸŒΈ

πŸ“¦ where this page comes from