Skip to content

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
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