| 1 | |
| 2 |
|
| 3 | #include <vmlinux.h>
|
| 4 | #include <bpf/bpf_helpers.h>
|
| 5 | #include "bpf_misc.h"
|
| 6 | #include "bpf_kfuncs.h"
|
| 7 | #include "../test_kmods/bpf_testmod_kfunc.h"
|
| 8 |
|
| 9 | SEC("tc")
|
| 10 | int kfunc_dynptr_nullable_test1(struct __sk_buff *skb)
|
| 11 | {
|
| 12 | struct bpf_dynptr data;
|
| 13 |
|
| 14 | bpf_dynptr_from_skb(skb, 0, &data);
|
| 15 | bpf_kfunc_dynptr_test(&data, NULL);
|
| 16 |
|
| 17 | return 0;
|
| 18 | }
|
| 19 |
|
| 20 | SEC("tc")
|
| 21 | int kfunc_dynptr_nullable_test2(struct __sk_buff *skb)
|
| 22 | {
|
| 23 | struct bpf_dynptr data;
|
| 24 |
|
| 25 | bpf_dynptr_from_skb(skb, 0, &data);
|
| 26 | bpf_kfunc_dynptr_test(&data, &data);
|
| 27 |
|
| 28 | return 0;
|
| 29 | }
|
| 30 |
|
| 31 | SEC("tc")
|
| 32 | __failure __msg("Possibly NULL pointer passed to trusted R1")
|
| 33 | int kfunc_dynptr_nullable_test3(struct __sk_buff *skb)
|
| 34 | {
|
| 35 | struct bpf_dynptr data;
|
| 36 |
|
| 37 | bpf_dynptr_from_skb(skb, 0, &data);
|
| 38 | bpf_kfunc_dynptr_test(NULL, &data);
|
| 39 |
|
| 40 | return 0;
|
| 41 | }
|
| 42 |
|
| 43 | char _license[] SEC("license") = "GPL";
|