Skip to content

Commit e435b04

Browse files
Tengda Wuborkmann
authored andcommitted
selftests/bpf: Test for null-pointer-deref bugfix in resolve_prog_type()
This test verifies that resolve_prog_type() works as expected when `attach_prog_fd` is not passed in. `prog->aux->dst_prog` in resolve_prog_type() is assigned by `attach_prog_fd`, and would be NULL if `attach_prog_fd` is not provided. Loading EXT prog with bpf_dynptr_from_skb() kfunc call in this way will lead to null-pointer-deref. Verify that the null-pointer-deref bug in resolve_prog_type() is fixed. Signed-off-by: Tengda Wu <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent f7866c3 commit e435b04

File tree

1 file changed

+13
-0
lines changed
  • tools/testing/selftests/bpf/verifier

1 file changed

+13
-0
lines changed

tools/testing/selftests/bpf/verifier/calls.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,19 @@
275275
.result_unpriv = REJECT,
276276
.result = ACCEPT,
277277
},
278+
{
279+
"calls: invalid kfunc call: must provide (attach_prog_fd, btf_id) pair when freplace",
280+
.insns = {
281+
BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
282+
BPF_EXIT_INSN(),
283+
},
284+
.prog_type = BPF_PROG_TYPE_EXT,
285+
.result = REJECT,
286+
.errstr = "Tracing programs must provide btf_id",
287+
.fixup_kfunc_btf_id = {
288+
{ "bpf_dynptr_from_skb", 0 },
289+
},
290+
},
278291
{
279292
"calls: basic sanity",
280293
.insns = {

0 commit comments

Comments
 (0)