security_de...ate_files_as(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… security_dentry_create_files_as β€” Kernel API Manual

okay bestie, welcome to the Kernel API Manual ✨ β€” this one's from the <pink>security</pink> chapter of the kernel, aka the LSM (Linux Security Modules) glue layer, and it's lowkey one of the cutest little helper functions in ./security/security.c. it does dentry initialization, and yes it sounds intimidating but it's literally just "compute a context, stash it in creds, go create files". slay.


✨ NAME ✨

security_dentry_create_files_as β€” Perform dentry initialization πŸŽ€


🌸 SYNOPSIS 🌸

int security_dentry_create_files_as (struct dentry *dentry , int mode ,
const struct qstr *name , const struct cred *old , struct cred *new );

it's giving "one function, five arguments, zero chill". let's meet them all πŸ’–


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dentry β€” the dentry to initialize πŸͺ„ this is the little directory-entry baddie we're setting up.
  • mode β€” mode used to determine resource type πŸ‘‘ it's how we figure out what kind of resource we're dealing with.
  • name β€” name of the last path component 🌸 just the tail end of the path, the final boss of the path string.
  • old β€” creds to use for LSM context calculations 🧚 the credentials we read from when doing the math.
  • new β€” creds to modify πŸ’… the credentials we actually write into.

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea β˜• β€” Compute a context for a dentry as the inode is not yet available and set that context in passed in creds so that new files are created using that context. the inode hasn't been born yet 😭 (it's not available!), so we can't just ask the inode nicely. we do the vibe check early, on the dentry, and then we stash the result in the creds you handed us, so that when new files get created they get created with that context.

and the important detail, bestie, do not skip this one: Context is calculated using the passed in creds and not the creds of the caller. 🫢 so the math is done off of old-style passed-in creds β€” not whoever happened to be running at the time. iykyk, this matters fr fr.


⭐ RETURN ⭐

  • Returns 0 on success πŸŽ‰
  • error on failure πŸ’€

that's it. no cap. binary outcome, iconic.


πŸ‘€ SEE ALSO πŸ‘€

okay so this is the part where the manpage goes absolutely feral and links basically the entire LSM universe 🌈. Kernel file ./security/security.c β€” and then, in order:

bestie that's like the entire LSM roster in one SEE ALSO πŸ’€ the manpage really said "you will read the whole neighbourhood". respect.

and that's the whole page, no notes πŸ’– this lil gem lives under ./security in the tree, dated October 2026, and it's filed in the Kernel API Manual. go forth and initialize those dentries, queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from