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

bpf: add crosstask check to __bpf_get_stack #644

Open
wants to merge 1 commit into
base: bpf-next_base
Choose a base branch
from

Conversation

danielocfb
Copy link
Owner

Pull request for series with
subject: bpf: add crosstask check to __bpf_get_stack
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648

@danielocfb
Copy link
Owner Author

Upstream branch: b4e59c1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: b4e59c1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb danielocfb force-pushed the series/799648=>bpf-next branch from 2dc0f36 to 66ec86e Compare November 9, 2023 17:58
@danielocfb danielocfb force-pushed the bpf-next_base branch 2 times, most recently from 902178a to bc1b833 Compare November 9, 2023 18:41
@danielocfb
Copy link
Owner Author

Upstream branch: 3815f89
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb danielocfb force-pushed the series/799648=>bpf-next branch from 66ec86e to 1007cf8 Compare November 9, 2023 18:42
@danielocfb danielocfb force-pushed the bpf-next_base branch 2 times, most recently from 0fbe9f3 to b0d20d2 Compare November 9, 2023 19:02
@danielocfb
Copy link
Owner Author

Upstream branch: 6f101db
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: 6f101db
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: e80742d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: e80742d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: e80742d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: e80742d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: 155addf
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb
Copy link
Owner Author

Upstream branch: 689b097
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

Currently get_perf_callchain only supports user stack walking for
the current task. Passing the correct *crosstask* param will return
0 frames if the task passed to __bpf_get_stack isn't the current
one instead of a single incorrect frame/address. This change
passes the correct *crosstask* param but also does a preemptive
check in __bpf_get_stack if the task is current and returns
-EOPNOTSUPP if it is not.

This issue was found using bpf_get_task_stack inside a BPF
iterator ("iter/task"), which iterates over all tasks.
bpf_get_task_stack works fine for fetching kernel stacks
but because get_perf_callchain relies on the caller to know
if the requested *task* is the current one (via *crosstask*)
it was failing in a confusing way.

It might be possible to get user stacks for all tasks utilizing
something like access_process_vm but that requires the bpf
program calling bpf_get_task_stack to be sleepable and would
therefore be a breaking change.

Fixes: fa28dcb ("bpf: Introduce helper bpf_get_task_stack()")
Signed-off-by: Jordan Rome <[email protected]>
@danielocfb
Copy link
Owner Author

Upstream branch: 9241176
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=799648
version: 2

@danielocfb danielocfb force-pushed the series/799648=>bpf-next branch from 74aad25 to 9903328 Compare November 10, 2023 17:08
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.

2 participants