xref: /linux/tools/testing/selftests/bpf/progs/lsm_tailcall.c (revision 5a4332062e9e71de8e78dc1b389d21e0dd44848b)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2024 Huawei Technologies Co., Ltd */
3 
4 #include "vmlinux.h"
5 #include <errno.h>
6 #include <bpf/bpf_helpers.h>
7 
8 char _license[] SEC("license") = "GPL";
9 
10 struct {
11 	__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
12 	__uint(max_entries, 1);
13 	__uint(key_size, sizeof(__u32));
14 	__uint(value_size, sizeof(__u32));
15 } jmp_table SEC(".maps");
16 
17 SEC("lsm/file_permission")
18 int lsm_file_permission_prog(void *ctx)
19 {
20 	return 0;
21 }
22 
23 SEC("lsm/file_alloc_security")
24 int lsm_file_alloc_security_prog(void *ctx)
25 {
26 	return 0;
27 }
28 
29 SEC("lsm/file_alloc_security")
30 int lsm_file_alloc_security_entry(void *ctx)
31 {
32 	bpf_tail_call_static(ctx, &jmp_table, 0);
33 	return 0;
34 }
35