shmem_kernel_file_setup(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– shmem_kernel_file_setup(9) πŸ’–

okay so bestie, welcome to the Kernel API Manual ✨ this one's about shmem_kernel_file_setup, and it's lowkey a whole vibe. it hands you an unlinked file that lives in tmpfs, and here's the thing β€” it must be kernel internal. no cap.


🌸 NAME 🌸

shmem_kernel_file_setup β€” get an unlinked file living in tmpfs which must be kernel internal.

and listen, this part is important so pay attention 🫢 β€” there will be NO LSM permission checks against the underlying inode. none. zero. so anyone using this interface must do their LSM checks at a higher layer. the users are the big_key and shm implementations, and LSM checks are provided at the key or shm level rather than at the inode. periodt. πŸ’…

⚠️ bestie please internalise this β€” no inode-level LSM checks happen here, so if you're the caller, the responsibility is yours at a higher layer. don't skip it. πŸ’€

✨ SYNOPSIS ✨

struct file * shmem_kernel_file_setup (const char *name , loff_t size ,
vma_flags_t flags );

like, that's the whole signature. she's simple, she's iconic πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • name β€” name for dentry (to be seen in /proc/<pid>/maps) πŸ‘€ so yes, it's gonna show up in the maps file, that's the whole point.
  • size β€” size to be set for the file 🌸 that's your file size, set it, own it.
  • flags β€” VMA_NORESERVE_BIT suppresses pre-accounting of the entire object size πŸ’… that's the specific flag bit and the specific behaviour, fr fr.

πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./mm/shmem.c and honestly the whole shmem fam πŸ‘‘


πŸ’œ shoutout to ./mm for housing all of this, and this beauty is dated October 2026, filed under shmem_kernel_file_setup(9). mwah, go read the source bestie πŸ˜­πŸ’–
πŸ“¦ where this page comes from