rethook_find_ret_addr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… rethook_find_ret_addr β€” Kernel API Manual, bestie edition

Okay so we're deep in the kernel manual pages today and this one is literally called rethook_find_ret_addr from the Kernel API Manual, and it does exactly what it says on the tin: it finds the correct return address that a rethook went and modified. Let's get into it 🫢


✨ NAME ✨

rethook_find_ret_addr β€” find the correct return address modified by rethook

No cap, that's the whole vibe. It finds the real return address after a rethook has done its little makeover on it πŸ’…


🌸 SYNOPSIS 🌸

unsigned long rethook_find_ret_addr (struct task_struct *tsk , unsigned
long frame , struct llist_node **cur );

Three args, one unsigned long coming back at you. Slay.


πŸŽ€ ARGUMENTS πŸŽ€

  • tsk β€” the target task. The one we're snooping the return address for πŸ‘€
  • frame β€” a frame pointer. It's your little hint for locating the address.
  • cur β€” a storage of the loop cursor llist_node pointer, so the next call knows where to pick up. It's giving bookmark energy πŸ”–

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea: this function finds the correct return address modified by a rethook on tsk, and it hands it back to you as an unsigned long. ✨

Now, the important bits β€” read these twice, bestie, because this is where people trip:

The tsk must be 'current' or a task which is not running. That's a hard requirement, not a suggestion πŸ’€

frame is a hint to get the correct return address β€” which is compared with the rethook::frame field. And cur is a loop cursor for searching the kretprobe return addresses on the tsk.

And the bit everyone gets wrong, okay, listen:

The '*cur' should be NULL at the first call, but 'cur' itself must NOT be NULL. Two very different things, don't mix them up πŸ™ˆ

Returns the found address value, or zero if not found. Zero = not found, periodt ⭐


πŸ”₯ SEE ALSO πŸ”₯

Go read the whole rethook friend group, they're all iconic πŸ‘‘


Alright bestie, that's the page! This one lives in ./kernel/trace and it's the October 2026 edition of rethook_find_ret_addr(9) β€” go find those return addresses, iykyk πŸ’–πŸ§šβœ¨

πŸ“¦ where this page comes from