Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
03b77e1
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
progs
/
lru_bug.c
Blame
Blame
Latest commit
History
History
49 lines (41 loc) · 1007 Bytes
Breadcrumbs
linux
/
tools
/
testing
/
selftests
/
bpf
/
progs
/
lru_bug.c
Top
File metadata and controls
Code
Blame
49 lines (41 loc) · 1007 Bytes
Raw
// SPDX-License-Identifier: GPL-2.0 #include <vmlinux.h> #include <bpf/bpf_tracing.h> #include <bpf/bpf_helpers.h> struct map_value { struct task_struct __kptr_untrusted *ptr; }; struct { __uint(type, BPF_MAP_TYPE_LRU_HASH); __uint(max_entries, 1); __type(key, int); __type(value, struct map_value); } lru_map SEC(".maps"); int pid = 0; int result = 1; SEC("fentry/bpf_ktime_get_ns") int printk(void *ctx) { struct map_value v = {}; if (pid == bpf_get_current_task_btf()->pid) bpf_map_update_elem(&lru_map, &(int){0}, &v, 0); return 0; } SEC("fentry/do_nanosleep") int nanosleep(void *ctx) { struct map_value val = {}, *v; struct task_struct *current; bpf_map_update_elem(&lru_map, &(int){0}, &val, 0); v = bpf_map_lookup_elem(&lru_map, &(int){0}); if (!v) return 0; bpf_map_delete_elem(&lru_map, &(int){0}); current = bpf_get_current_task_btf(); v->ptr = current; pid = current->pid; bpf_ktime_get_ns(); result = !v->ptr; return 0; } char _license[] SEC("license") = "GPL";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
You can’t perform that action at this time.