Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Jongy/bpf_get_stack_offset

Open more actions menu

Repository files navigation

get_stack_offset

This tiny BPF program & driver can be used to determine the offset of task_struct->stack in runtime, without using kernel headers.

This was a follow-up to https://github.com/Jongy/bpf_get_fs_offset.

How it works

The driver program calls write(2) with 2 magic values. Those values are kept in the pt_regs struct that is stored on the kernel thread's stack.

The BPF program is triggered by this write(2) call. It scans the current task_struct's memory for 16kb, and for each word, it tries to treat it as if it was the ->stack pointer, and checks if at the expcted offset from the stack base, the 2 magic values are found.

The driver then reports the found offset, or the error (none found / found more than 1 / bpf_probe_read error).

About

A tiny BPF program & driver to get task_struct.stack.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.