bpf_binprm_set_flags(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_binprm_set_flags(9) β€” the Kernel API Manual page, bestie edition πŸŽ€

okay so this is bpf_binprm_set_flags(9) from the Kernel API Manual, and it's literally the little function that picks which interpreter invocation flags your exec gets. let's get into it ✨


✨ NAME ✨

bpf_binprm_set_flags β€” choose the interpreter invocation flags for this exec πŸ¦‹


🌸 SYNOPSIS 🌸

__bpf_kfunc int bpf_binprm_set_flags (struct linux_binprm *bprm , enum
       bpf_binprm_flags flags );

like, that's the whole signature, no cap πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • bprm β€” the binary that is being executed 🫢
  • flags β€” an OR of enum bpf_binprm_flags values, so you can stack 'em ⭐

🧚 DESCRIPTION 🧚

okay so first thing: this is to be called from the load program of a struct binfmt_misc_ops handler. that's the vibe. πŸ‘‘

it decides per exec what a static entry fixes at registration with the P, C, O, T and L flags. iconic behaviour honestly.

here's what each flag is giving:

  • BPF_BINPRM_PRESERVE_ARGV0 β€” keeps the caller's argv[0] πŸ’–
  • BPF_BINPRM_CREDENTIALS β€” computes credentials from the binary πŸ”₯
  • BPF_BINPRM_EXECFD β€” hands the binary to the interpreter through AT_EXECFD 🌈
  • BPF_BINPRM_TRANSPARENT β€” additionally leaves the argument vector untouched, making the exec look like a direct execution of the binary ✨
  • BPF_BINPRM_LOADER β€” substitutes the interpreter for the binary's PT_INTERP and runs the binary as a native exec; it excludes every other flag πŸ’€

and some housekeeping notes that matter:

calling it again replaces the flags β€” it does not add to them 🫢
passing zero clears them again, back to nothing, clean slate 🧼

⭐ RETURN ⭐

  • 0 on success πŸŽ‰
  • -EINVAL if flags contains an unknown bit or an invalid combination 😭

πŸ¦‹ SEE ALSO πŸ¦‹

like, go read those next, they're all part of the same little friend group πŸ’…πŸ‘‘


and that's the page bestie!! 🌸 mwah πŸ’œ

from ./fs, dated October 2026 β€” page bpf_binprm_set_flags(9), out 🫑✨ no cap, read the flags before you ship it πŸŽ€
πŸ“¦ where this page comes from