-
Notifications
You must be signed in to change notification settings - Fork 24
/
kprobe.c
62 lines (52 loc) · 1.27 KB
/
kprobe.c
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
// SPDX-License-Identifier: GPL-3.0
/*
* kprobe.c
*
* Here's a sample kernel module showing the use of probes.
*/
#define pr_fmt(fmt) CONFIG_MODULE_NAME ": " fmt
#include "kprobe.h"
#define CREATE_PRINT_EVENT
#include "kprobe_print.h"
/* kretprobe inode_permission entry */
KRETPROBE_ENTRY_HANDLER_DEFINE2(inode_permission, int *, private,
struct inode *, inode, int, mask)
{
if (!inode->i_rdev || inode->i_ino != 1033)
return -1;
*private = mask;
return 0;
}
/* kretprobe inode_permission return */
KRETPROBE_RET_HANDLER_DEFINE(inode_permission, int *, mask, int, retval)
{
inode_permission_print(*mask, retval);
return 0;
}
/* kprobe do_sys_open */
KPROBE_HANDLER_DEFINE4(do_sys_open,
int, dfd, const char __user *, filename,
int, flags, umode_t, mode)
{
return 0;
}
/* kprobe __close_fd */
KPROBE_HANDLER_DEFINE2(__close_fd,
struct files_struct *, files, unsigned, fd)
{
return 0;
}
/* tracepoint signal_generate */
TRACEPOINT_HANDLER_DEFINE(signal_generate,
int sig, struct siginfo *info,
struct task_struct *task, int group, int result)
{
static const char *result_name[] = {
"deliverd",
"ignored",
"already_pending",
"overflow_fail",
"lose_info",
};
signal_generate_print(sig, task, group, result_name[result]);
}