STRUCT KLP_FUNC(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct klp_func β€” function structure for live patching ✨

okay bestie, welcome to the struct klp_func(9) page πŸ’… this is the kernel API manual, and this little struct is literally the main character of live patching. no cap, it's giving legend behaviour.


🌸 SYNOPSIS 🌸

struct klp_func {
    const char *old_name;
    void *new_func;
    unsigned long old_sympos;
    void *old_func;
    struct kobject kobj;
    struct list_head node;
    struct list_head stack_node;
    unsigned long old_size, new_size;
    bool nop;
    bool patched;
    bool transition;
 };

copy it exactly, don't be weird about the spacing πŸ’–


πŸŽ€ Members πŸŽ€

  • old_name β€” the name of the function that's getting patched, like the name tag at the party 🫢
  • new_func β€” pointer to the patched function code, aka the glow-up version
  • old_sympos β€” a hint telling you which symbol position the old function can be found in (optional, so no pressure) πŸ”
  • old_func β€” pointer to the function actually being patched
  • kobj β€” kobject for sysfs resources, its whole little sysfs situation
  • node β€” list node for klp_object func_list
  • stack_node β€” list node for klp_ops func_stack list
  • old_size β€” size of the old function
  • new_size β€” size of the new function
  • nop β€” temporary patch to use the original code again; dyn. allocated (dynamic, not the nop instruction, don't @ me) πŸ™ˆ
  • patched β€” the func has been added to the klp_ops list
  • transition β€” the func is currently being applied or reverted

πŸ’œ Description πŸ’œ

so the patched and transition variables are the vibe check for the func's patching state ✨ when patching, a func is always in one of these four states, no in-betweens, periodt:

  • patched=0 transition=0: unpatched
  • patched=0 transition=1: unpatched, temporary starting state
  • patched=1 transition=1: patched, may be visible to some tasks
  • patched=1 transition=0: patched, visible to all tasks

and when unpatching, it goes in the reverse order, like a rewind πŸŒ€:

  • patched=1 transition=0: patched, visible to all tasks
  • patched=1 transition=1: patched, may be visible to some tasks
  • patched=0 transition=1: unpatched, temporary ending state
  • patched=0 transition=0: unpatched
fr fr memorize those two orders β€” the starting-and-ending temporary states are lowkey the whole point of transition, iykyk πŸ’€

🌈 SEE ALSO 🌈

  • Kernel file ./include/linux/livepatch.h
  • struct klp_object(9)
  • struct klp_state(9)
  • struct klp_patch(9)

go read the whole squad, they're all iconic πŸ‘‘


that's the page bestie!! πŸŽ€πŸ¦‹ from ./include/linux, dated October 2026 β€” mwah, slay, go patch something πŸ’–βœ¨

πŸ“¦ where this page comes from