xref: /linux/tools/testing/selftests/bpf/progs/livepatch_trampoline.c (revision cbba5d1b53fb82209feacb459edecb1ef8427119)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
3 
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_tracing.h>
7 
8 int fentry_hit;
9 int fexit_hit;
10 int my_pid;
11 
12 SEC("fentry/cmdline_proc_show")
BPF_PROG(fentry_cmdline)13 int BPF_PROG(fentry_cmdline)
14 {
15 	if (my_pid != (bpf_get_current_pid_tgid() >> 32))
16 		return 0;
17 
18 	fentry_hit = 1;
19 	return 0;
20 }
21 
22 SEC("fexit/cmdline_proc_show")
BPF_PROG(fexit_cmdline)23 int BPF_PROG(fexit_cmdline)
24 {
25 	if (my_pid != (bpf_get_current_pid_tgid() >> 32))
26 		return 0;
27 
28 	fexit_hit = 1;
29 	return 0;
30 }
31