bpf_binprm_set_flags(9)
π 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 ofenum bpf_binprm_flagsvalues, 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'sargv[0]πBPF_BINPRM_CREDENTIALSβ computes credentials from the binary π₯BPF_BINPRM_EXECFDβ hands the binary to the interpreter throughAT_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'sPT_INTERPand 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 β
0on success π-EINVALifflagscontains an unknown bit or an invalid combination π
π¦ SEE ALSO π¦
- Kernel file
./fs/binfmt_misc_bpf.c binfmt_misc_get_ops(9)bpf_binprm_set_interp(9)bpf_binprm_select_interp(9)bpf_binprm_set_interp_arg(9)
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 β pagebpf_binprm_set_flags(9), out π«‘β¨ no cap, read the flags before you ship it π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms