Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ebpf): use bpf_task_pt_regs when available #4238

Merged
merged 1 commit into from
Aug 11, 2024

Conversation

OriGlassman
Copy link
Collaborator

@OriGlassman OriGlassman commented Aug 8, 2024

Thanks @oshaked1 for writing this commit!

1. Explain what the PR does

Tracee's get_task_pt_regs function mimics the logic of this helper, but relies on assuming some values defined in the kernel. This commit changes this function to use the helper if it is available. This helper must receive a task_struct with BTF info obtained from bpf_get_current_task_btf. From my experimentation, the verifier cannot determine whether a task_struct contains BTF info if it was stored outside of the stack. This means that this function cannot acutally retrieve the registers of any task except for the current one. The function name was changed to reflect this requirement, and it no longer receives a task_struct as a parameter.

2. Explain how to test it

./tracee

3. Other comments

Closes #4239

Tracee's `get_task_pt_regs` function mimics the logic of this helper, but relies on assuming some values defined in the kernel.
This commit changes this function to use the helper if it is available.
This helper must receive a task_struct with BTF info obtained from `bpf_get_current_task_btf`.
From my experimentation, the verifier cannot determine whether a task_struct contains BTF info if it was stored outside of the stack.
This means that this function cannot acutally retrieve the registers of any task except for the current one.
The function name was changed to reflect this requirement, and it no longer receives a task_struct as a parameter.

Thanks @oshaked1 for writing this commit!
Copy link
Collaborator

@yanivagman yanivagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yanivagman yanivagman merged commit dccc3d9 into aquasecurity:main Aug 11, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use bpf_task_pt_regs when available
2 participants