diff options
| author | David S. Miller <[email protected]> | 2021-04-26 01:02:32 +0000 |
|---|---|---|
| committer | David S. Miller <[email protected]> | 2021-04-26 01:02:32 +0000 |
| commit | 5f6c2f536de648ac31564d8c413337ff4f7af93a (patch) | |
| tree | 37360317224f4d60619976d284b66aa7a9ddf08a /tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c | |
| parent | phy: nxp-c45-tja11xx: add interrupt support (diff) | |
| parent | bpf: Document the pahole release info related to libbpf in bpf_devel_QA.rst (diff) | |
| download | kernel-5f6c2f536de648ac31564d8c413337ff4f7af93a.tar.gz kernel-5f6c2f536de648ac31564d8c413337ff4f7af93a.zip | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Alexei Starovoitov says:
====================
pull-request: bpf-next 2021-04-23
The following pull-request contains BPF updates for your *net-next* tree.
We've added 69 non-merge commits during the last 22 day(s) which contain
a total of 69 files changed, 3141 insertions(+), 866 deletions(-).
The main changes are:
1) Add BPF static linker support for extern resolution of global, from Andrii.
2) Refine retval for bpf_get_task_stack helper, from Dave.
3) Add a bpf_snprintf helper, from Florent.
4) A bunch of miscellaneous improvements from many developers.
====================
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c index 50e59a2e142e..43c36f5f7649 100644 --- a/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c +++ b/tools/testing/selftests/bpf/progs/bpf_iter_task_stack.c @@ -35,3 +35,30 @@ int dump_task_stack(struct bpf_iter__task *ctx) return 0; } + +SEC("iter/task") +int get_task_user_stacks(struct bpf_iter__task *ctx) +{ + struct seq_file *seq = ctx->meta->seq; + struct task_struct *task = ctx->task; + uint64_t buf_sz = 0; + int64_t res; + + if (task == (void *)0) + return 0; + + res = bpf_get_task_stack(task, entries, + MAX_STACK_TRACE_DEPTH * SIZE_OF_ULONG, BPF_F_USER_STACK); + if (res <= 0) + return 0; + + buf_sz += res; + + /* If the verifier doesn't refine bpf_get_task_stack res, and instead + * assumes res is entirely unknown, this program will fail to load as + * the verifier will believe that max buf_sz value allows reading + * past the end of entries in bpf_seq_write call + */ + bpf_seq_write(seq, &entries, buf_sz); + return 0; +} |
