Skip to content

Commit

Permalink
selftests/bpf: Add a test for ptr_to_map_value on stack for helper ac…
Browse files Browse the repository at this point in the history
…cess

commit b4b638c upstream

Change bpf_iter_task.c such that pointer to map_value may appear
on the stack for bpf_seq_printf() to access. Without previous
verifier patch, the bpf_iter test will fail.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20201210013350.943985-1-yhs@fb.com
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
yonghong-song authored and gregkh committed Aug 8, 2021
1 parent e2b7a4c commit 83bbf95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tools/testing/selftests/bpf/progs/bpf_iter_task.c
Expand Up @@ -11,9 +11,10 @@ int dump_task(struct bpf_iter__task *ctx)
{
struct seq_file *seq = ctx->meta->seq;
struct task_struct *task = ctx->task;
static char info[] = " === END ===";

if (task == (void *)0) {
BPF_SEQ_PRINTF(seq, " === END ===\n");
BPF_SEQ_PRINTF(seq, "%s\n", info);
return 0;
}

Expand Down
5 changes: 3 additions & 2 deletions tools/testing/selftests/bpf/verifier/unpriv.c
Expand Up @@ -108,8 +108,9 @@
BPF_EXIT_INSN(),
},
.fixup_map_hash_8b = { 3 },
.errstr = "invalid indirect read from stack off -8+0 size 8",
.result = REJECT,
.errstr_unpriv = "invalid indirect read from stack off -8+0 size 8",
.result_unpriv = REJECT,
.result = ACCEPT,
},
{
"unpriv: mangle pointer on stack 1",
Expand Down

0 comments on commit 83bbf95

Please sign in to comment.