xref: /linux/tools/testing/selftests/bpf/progs/test_attach_kprobe_sleepable.c (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
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