may_create_in_sticky(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… may_create_in_sticky(9) πŸ’…

okay so this is a page from the Kernel API Manual (yes, the kernel has lore, and yes, it's iconic) β€” and it's about the bouncer at the door of your sticky directories πŸŽ€


✨ NAME ✨

may_create_in_sticky β€” bestie, this is the little function that decides whether an O_CREAT open in a sticky directory should be allowed, or not, on files that already exist. vibe check for file creation, basically πŸ’…


🌸 SYNOPSIS 🌸

int may_create_in_sticky (struct mnt_idmap *idmap , struct nameidata *nd
, struct inode *const inode );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • idmap β€” the idmap of the mount the inode was found from 🫢
  • nd β€” the nameidata pathwalk data, i.e. all the path-walking lore
  • inode β€” the inode of the file to open, the main character of this whole situation

πŸ‘‘ DESCRIPTION πŸ‘‘

so the way this works is it blocks an O_CREAT open of a FIFO (or a regular file) when all of these are true, no cap:

  • sysctl_protected_fifos (or sysctl_protected_regular) is enabled ⭐
  • the file already exists
  • we are in a sticky directory πŸ“
  • we don't own the file
  • the owner of the directory doesn't own the file
  • the directory is world writable

and here's the plot twist πŸ™ˆ β€” if sysctl_protected_fifos (or sysctl_protected_regular) is set to 2, the directory doesn't have to be world writable: being group writable will be enough. noted, periodt.

also, if the inode has been found through an idmapped mount, the idmap of the vfsmount must be passed through idmap. this function will then take care to map the inode according to idmap before checking permissions, which is honestly so thoughtful of it πŸ’–. on non-idmapped mounts, or if permission checking is to be performed on the raw inode, simply pass nop_mnt_idmap.

returns 0 if the open is allowed, -ve on error. that's it, that's the return πŸ’€

πŸ’œ SEE ALSO πŸ’œ

Kernel file ./fs/namei.c β€” and here's the whole friend group, all of them, in order, because we don't leave anyone out 🫢:


and that's the page, bestie ✨ it came from ./fs, dated October 2026 β€” so yeah, technically from the future, which is very main character energy of it πŸ‘‘πŸ’–

πŸ“¦ where this page comes from