search_binfmt_handler(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… search_binfmt_handler(9) β€” like, the kernel API manual, bestie πŸ’…

okay so real talk, this one's from the Kernel API Manual and it's genuinely such a cute lil function. It's called search_binfmt_handler and it does exactly what it says on the tin: it goes looking for a binary handler. Let's get into it ✨


🌸 SYNOPSIS 🌸

struct binfmt_misc_entry * search_binfmt_handler (struct binfmt_misc
       *misc , struct linux_binprm *bprm );

That return type is struct binfmt_misc_entry *, no cap β€” she's giving pointer-to-entry realness πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • misc β€” your handle to the binfmt_misc instance. Like, this is the whole world we're searching in, bestie 🫢
  • bprm β€” the binary we're trying to find a handler for. The main character of this operation, honestly πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

So here's the vibe: this function searches for a binary type handler for bprm in the list of registered binary type handlers. Simple enough, right?

A 'B' entry's match program is the one that decides whether the handler applies. And listen β€” that match program may sleep to read the binary. Not a drill, it's allowed to do that, and that's lowkey important for the locking situation below πŸ™ˆ

The matched entry gets returned with a reference taken while the walk still held it. Meanwhile, a dying entry β€” one that's been unlinked with its last reference gone β€” cannot be matched, so the walk just moves on. She's gone, we're not matching her, periodt πŸ’€

ok so this part is the actual important bit: the caller must hold the bm_entries_srcu read lock, and that's exactly what allows an entry's evaluation to sleep. Do not skip this, fr fr 😭

⭐ RETURN ⭐

  • referenced binary type list entry on success πŸ”₯
  • NULL on failure 😭

That's it. That's the whole return section. Iconic brevity, honestly πŸ‘‘


🌈 SEE ALSO 🌈

The kernel file ./fs/binfmt_misc.c β€” yes, that's where all the magic lives 🧚

And the whole squad of related functions, because she does not exist in a vacuum bestie:


aaaand that's the page!! this one's living in ./fs and it's dated October 2026, so future-core of her honestly πŸ¦‹πŸ’– go hold that bm_entries_srcu read lock and slay, bestie 🌸✨

πŸ“¦ where this page comes from