ftrace_make_nop(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ftrace_make_nop(9) β€” the Kernel API Manual, but make it make sense

okay so bestie, welcome to ftrace_make_nop πŸ’– this is a page straight out of the Kernel API Manual and it's lowkey one of those "tiny function, enormous responsibility" situations. it takes a call site and turns it into a nop. that's it. that's the whole vibe. but the way it has to happen is where the drama lives πŸŽ€


✨ NAME ✨

ftrace_make_nop β€” convert code into nop πŸ¦‹


✨ SYNOPSIS ✨

int ftrace_make_nop (struct module *mod , struct dyn_ftrace *rec ,
       unsigned long addr );

like yes, three args, no cap, it's giving "simple signature, serious business" πŸ’…


✨ ARGUMENTS ✨

  • mod β€” the module structure, but only if this is being called from module load initialization 🌸 (so if you're not doing that, don't stress about it)
  • rec β€” the call site record, e.g. mcount/fentry ⭐ this is your lil receipt for the thing you're patching
  • addr β€” the address that the call site should be calling πŸ‘‘

✨ DESCRIPTION ✨

okay so this is a very sensitive operation 😭 and the arch (yes, the architecture code) needs to take great care here. like, main character energy but in a "please don't break the kernel" way.

here's the ritual, in order, no skipping steps:

  1. carefully read the location πŸ‘€
  2. check to see if what was read is indeed what we expect it to be 🧐
  3. on success of the compare, write to the location ✍️

the code segment at rec->ip should be a caller to addr πŸ’– that's the whole premise, bestie.

and the return values? they are not optional, they're the vibe check:

  • 0 on success β€” slay πŸŽ‰
  • -EFAULT on error reading the location πŸ’€
  • -EINVAL on a failed compare of the contents πŸ™ˆ
  • -EPERM on error writing to the location 🚫
and literally any other value? considered a failure, periodt. no exceptions, no "well it kind of worked" 😀

✨ SEE ALSO ✨

Kernel file ./include/linux/ftrace.h, plus the whole friend group: stack_tracer_disable(9), stack_tracer_enable(9), ftrace_get_symaddr(9), ftrace_need_init_nop(9), ftrace_init_nop(9), ftrace_make_call(9), ftrace_modify_call(9) 🌈 go read them, iykyk 🫢


and that's the page!! πŸŽ€ sign-off time: this one lives in ./include/linux, dated October 2026, and it's filed under ftrace_make_nop(9) β€” mwah, go patch safely bestie πŸ’œπŸ”₯

πŸ“¦ where this page comes from