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
92c6f8c
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
bpf
preload
iterators
.gitignore
Kconfig
Makefile
bpf_preload.h
bpf_preload_kern.c
Kconfig
Makefile
arena.c
arraymap.c
bloom_filter.c
bpf_cgrp_storage.c
bpf_inode_storage.c
bpf_iter.c
bpf_local_storage.c
bpf_lru_list.c
bpf_lru_list.h
bpf_lsm.c
bpf_struct_ops.c
bpf_task_storage.c
btf.c
btf_iter.c
btf_relocate.c
cgroup.c
cgroup_iter.c
core.c
cpumap.c
cpumask.c
crypto.c
devmap.c
disasm.c
disasm.h
dispatcher.c
hashtab.c
helpers.c
inode.c
link_iter.c
local_storage.c
log.c
lpm_trie.c
map_in_map.c
map_in_map.h
map_iter.c
memalloc.c
mmap_unlock_work.h
mprog.c
net_namespace.c
offload.c
percpu_freelist.c
percpu_freelist.h
prog_iter.c
queue_stack_maps.c
relo_core.c
reuseport_array.c
ringbuf.c
stackmap.c
syscall.c
sysfs_btf.c
task_iter.c
tcx.c
tnum.c
token.c
trampoline.c
verifier.c
cgroup
configs
debug
dma
entry
events
futex
gcov
irq
kcsan
livepatch
locking
module
power
printk
rcu
sched
time
trace
.gitignore
Kconfig.freezer
Kconfig.hz
Kconfig.kexec
Kconfig.locks
Kconfig.preempt
Makefile
acct.c
async.c
audit.c
audit.h
audit_fsnotify.c
audit_tree.c
audit_watch.c
auditfilter.c
auditsc.c
backtracetest.c
bounds.c
capability.c
cfi.c
compat.c
configs.c
context_tracking.c
cpu.c
cpu_pm.c
crash_core.c
crash_reserve.c
cred.c
delayacct.c
dma.c
elfcorehdr.c
exec_domain.c
exit.c
exit.h
extable.c
fail_function.c
fork.c
freezer.c
gen_kheaders.sh
groups.c
hung_task.c
iomem.c
irq_work.c
jump_label.c
kallsyms.c
kallsyms_internal.h
kallsyms_selftest.c
kallsyms_selftest.h
kcmp.c
kcov.c
kexec.c
kexec_core.c
kexec_elf.c
kexec_file.c
kexec_internal.h
kheaders.c
kprobes.c
ksyms_common.c
ksysfs.c
kthread.c
latencytop.c
module_signature.c
notifier.c
nsproxy.c
padata.c
panic.c
params.c
pid.c
pid_namespace.c
pid_sysctl.h
profile.c
ptrace.c
range.c
reboot.c
regset.c
relay.c
resource.c
resource_kunit.c
rseq.c
scftorture.c
scs.c
seccomp.c
signal.c
smp.c
smpboot.c
smpboot.h
softirq.c
stackleak.c
stacktrace.c
static_call.c
static_call_inline.c
stop_machine.c
sys.c
sys_ni.c
sysctl-test.c
sysctl.c
task_work.c
taskstats.c
torture.c
tracepoint.c
tsacct.c
ucount.c
uid16.c
uid16.h
umh.c
up.c
user-return-notifier.c
user.c
user_namespace.c
usermode_driver.c
utsname.c
utsname_sysctl.c
vhost_task.c
vmcore_info.c
watch_queue.c
watchdog.c
watchdog_buddy.c
watchdog_perf.c
workqueue.c
workqueue_internal.h
lib
mm
net
rust
samples
scripts
security
sound
tools
usr
virt
.clang-format
.clippy.toml
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
kernel
/
bpf
/
preload
/
bpf_preload_kern.c
Copy path
Blame
Blame
Latest commit
History
History
93 lines (84 loc) · 2.03 KB
Breadcrumbs
linux
/
kernel
/
bpf
/
preload
/
bpf_preload_kern.c
Top
File metadata and controls
Code
Blame
93 lines (84 loc) · 2.03 KB
Raw
// SPDX-License-Identifier: GPL-2.0 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/init.h> #include <linux/module.h> #include "bpf_preload.h" #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #include "iterators/iterators.lskel-little-endian.h" #else #include "iterators/iterators.lskel-big-endian.h" #endif static struct bpf_link *maps_link, *progs_link; static struct iterators_bpf *skel; static void free_links_and_skel(void) { if (!IS_ERR_OR_NULL(maps_link)) bpf_link_put(maps_link); if (!IS_ERR_OR_NULL(progs_link)) bpf_link_put(progs_link); iterators_bpf__destroy(skel); } static int preload(struct bpf_preload_info *obj) { strscpy(obj[0].link_name, "maps.debug", sizeof(obj[0].link_name)); obj[0].link = maps_link; strscpy(obj[1].link_name, "progs.debug", sizeof(obj[1].link_name)); obj[1].link = progs_link; return 0; } static struct bpf_preload_ops ops = { .preload = preload, .owner = THIS_MODULE, }; static int load_skel(void) { int err; skel = iterators_bpf__open(); if (!skel) return -ENOMEM; err = iterators_bpf__load(skel); if (err) goto out; err = iterators_bpf__attach(skel); if (err) goto out; maps_link = bpf_link_get_from_fd(skel->links.dump_bpf_map_fd); if (IS_ERR(maps_link)) { err = PTR_ERR(maps_link); goto out; } progs_link = bpf_link_get_from_fd(skel->links.dump_bpf_prog_fd); if (IS_ERR(progs_link)) { err = PTR_ERR(progs_link); goto out; } /* Avoid taking over stdin/stdout/stderr of init process. Zeroing out * makes skel_closenz() a no-op later in iterators_bpf__destroy(). */ close_fd(skel->links.dump_bpf_map_fd); skel->links.dump_bpf_map_fd = 0; close_fd(skel->links.dump_bpf_prog_fd); skel->links.dump_bpf_prog_fd = 0; return 0; out: free_links_and_skel(); return err; } static int __init load(void) { int err; err = load_skel(); if (err) return err; bpf_preload_ops = &ops; return err; } static void __exit fini(void) { bpf_preload_ops = NULL; free_links_and_skel(); } late_initcall(load); module_exit(fini); MODULE_IMPORT_NS(BPF_INTERNAL); MODULE_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
You can’t perform that action at this time.