xref: /linux/tools/testing/selftests/bpf/progs/test_tp_btf_nullable.c (revision ab93e0dd72c37d378dd936f031ffb83ff2bd87ce)
12060f07fSPhilo Lu // SPDX-License-Identifier: GPL-2.0
22060f07fSPhilo Lu 
32060f07fSPhilo Lu #include "vmlinux.h"
42060f07fSPhilo Lu #include <bpf/bpf_helpers.h>
52060f07fSPhilo Lu #include <bpf/bpf_tracing.h>
6d6212d82SToke Høiland-Jørgensen #include "../test_kmods/bpf_testmod.h"
72060f07fSPhilo Lu #include "bpf_misc.h"
82060f07fSPhilo Lu 
9*ac01fa73SSteven Rostedt SEC("tp_btf/bpf_testmod_test_nullable_bare_tp")
10c00d738eSKumar Kartikeya Dwivedi __failure __msg("R1 invalid mem access 'trusted_ptr_or_null_'")
BPF_PROG(handle_tp_btf_nullable_bare1,struct bpf_testmod_test_read_ctx * nullable_ctx)112060f07fSPhilo Lu int BPF_PROG(handle_tp_btf_nullable_bare1, struct bpf_testmod_test_read_ctx *nullable_ctx)
122060f07fSPhilo Lu {
132060f07fSPhilo Lu 	return nullable_ctx->len;
142060f07fSPhilo Lu }
152060f07fSPhilo Lu 
16*ac01fa73SSteven Rostedt SEC("tp_btf/bpf_testmod_test_nullable_bare_tp")
BPF_PROG(handle_tp_btf_nullable_bare2,struct bpf_testmod_test_read_ctx * nullable_ctx)172060f07fSPhilo Lu int BPF_PROG(handle_tp_btf_nullable_bare2, struct bpf_testmod_test_read_ctx *nullable_ctx)
182060f07fSPhilo Lu {
192060f07fSPhilo Lu 	if (nullable_ctx)
202060f07fSPhilo Lu 		return nullable_ctx->len;
212060f07fSPhilo Lu 	return 0;
222060f07fSPhilo Lu }
232060f07fSPhilo Lu 
242060f07fSPhilo Lu char _license[] SEC("license") = "GPL";
25