Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.5 51 lines 1.0 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2// Copyright (c) 2017 Facebook 3 4#include <linux/ptrace.h> 5#include <linux/bpf.h> 6#include "bpf_helpers.h" 7 8struct { 9 __uint(type, BPF_MAP_TYPE_ARRAY); 10 __uint(max_entries, 4); 11 __type(key, int); 12 __type(value, int); 13} results_map SEC(".maps"); 14 15SEC("kprobe/sys_nanosleep") 16int handle_sys_nanosleep_entry(struct pt_regs *ctx) 17{ 18 const int key = 0, value = 1; 19 20 bpf_map_update_elem(&results_map, &key, &value, 0); 21 return 0; 22} 23 24SEC("kretprobe/sys_nanosleep") 25int handle_sys_getpid_return(struct pt_regs *ctx) 26{ 27 const int key = 1, value = 2; 28 29 bpf_map_update_elem(&results_map, &key, &value, 0); 30 return 0; 31} 32 33SEC("uprobe/trigger_func") 34int handle_uprobe_entry(struct pt_regs *ctx) 35{ 36 const int key = 2, value = 3; 37 38 bpf_map_update_elem(&results_map, &key, &value, 0); 39 return 0; 40} 41 42SEC("uretprobe/trigger_func") 43int handle_uprobe_return(struct pt_regs *ctx) 44{ 45 const int key = 3, value = 4; 46 47 bpf_map_update_elem(&results_map, &key, &value, 0); 48 return 0; 49} 50 51char _license[] SEC("license") = "GPL";