xref: /linux/tools/testing/selftests/bpf/progs/test_attach_kprobe_sleepable.c (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2017 Facebook
3 
4 #include "vmlinux.h"
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_tracing.h>
7 #include <bpf/bpf_core_read.h>
8 #include "bpf_misc.h"
9 
10 int kprobe_res = 0;
11 
12 /**
13  * This program will be manually made sleepable on the userspace side
14  * and should thus be unattachable.
15  */
16 SEC("kprobe/" SYS_PREFIX "sys_nanosleep")
17 int handle_kprobe_sleepable(struct pt_regs *ctx)
18 {
19 	kprobe_res = 1;
20 	return 0;
21 }
22 
23 char _license[] SEC("license") = "GPL";
24