| 1 |
# reboot _____________________________________________________ |
| 2 |
# |
| 3 |
# long sys_reboot(int magic1, |
| 4 |
# int magic2, |
| 5 |
# unsigned int cmd, |
| 6 |
# void __user * arg) |
| 7 |
# |
| 8 |
|
| 9 |
@define _SYSCALL_REBOOT_NAME |
| 10 |
%( |
| 11 |
name = "reboot" |
| 12 |
%) |
| 13 |
|
| 14 |
@define _SYSCALL_REBOOT_ARGSTR |
| 15 |
%( |
| 16 |
argstr = sprintf("%s, %s, %s, %p", magic_str, magic2_str, flag_str, arg_uaddr) |
| 17 |
%) |
| 18 |
|
| 19 |
@define _SYSCALL_REBOOT_REGARGS |
| 20 |
%( |
| 21 |
magic = int_arg(1) |
| 22 |
magic_str = _reboot_magic_str(magic) |
| 23 |
magic2 = int_arg(2) |
| 24 |
magic2_str =_reboot_magic_str(magic2) |
| 25 |
flag = uint_arg(3) |
| 26 |
flag_str = _reboot_flag_str(flag) |
| 27 |
arg_uaddr = pointer_arg(4) |
| 28 |
%) |
| 29 |
|
| 30 |
@define _SYSCALL_REBOOT_REGARGS_STORE |
| 31 |
%( |
| 32 |
if (@probewrite(magic)) |
| 33 |
set_int_arg(1, magic) |
| 34 |
|
| 35 |
if (@probewrite(magic2)) |
| 36 |
set_int_arg(2, magic2) |
| 37 |
|
| 38 |
if (@probewrite(flag)) |
| 39 |
set_uint_arg(3, flag) |
| 40 |
|
| 41 |
if (@probewrite(arg_uaddr)) |
| 42 |
set_pointer_arg(4, arg_uaddr) |
| 43 |
%) |
| 44 |
|
| 45 |
probe syscall.reboot = dw_syscall.reboot !, nd_syscall.reboot ? {} |
| 46 |
probe syscall.reboot.return = dw_syscall.reboot.return !, |
| 47 |
nd_syscall.reboot.return ? {} |
| 48 |
|
| 49 |
# dw_reboot _____________________________________________________ |
| 50 |
|
| 51 |
probe dw_syscall.reboot = kernel.function("sys_reboot").call |
| 52 |
{ |
| 53 |
@_SYSCALL_REBOOT_NAME |
| 54 |
magic = __int32($magic1) |
| 55 |
magic_str = _reboot_magic_str(__int32($magic1)) |
| 56 |
magic2 = __int32($magic2) |
| 57 |
magic2_str =_reboot_magic_str(__int32($magic2)) |
| 58 |
flag = __uint32($cmd) |
| 59 |
flag_str = _reboot_flag_str(__uint32($cmd)) |
| 60 |
arg_uaddr = $arg |
| 61 |
@_SYSCALL_REBOOT_ARGSTR |
| 62 |
} |
| 63 |
probe dw_syscall.reboot.return = kernel.function("sys_reboot").return |
| 64 |
{ |
| 65 |
@_SYSCALL_REBOOT_NAME |
| 66 |
@SYSC_RETVALSTR($return) |
| 67 |
} |
| 68 |
|
| 69 |
# nd_reboot _____________________________________________________ |
| 70 |
|
| 71 |
probe nd_syscall.reboot = nd1_syscall.reboot!, nd2_syscall.reboot!, tp_syscall.reboot |
| 72 |
{ } |
| 73 |
|
| 74 |
probe nd1_syscall.reboot = kprobe.function("sys_reboot") ? |
| 75 |
{ |
| 76 |
@_SYSCALL_REBOOT_NAME |
| 77 |
asmlinkage() |
| 78 |
@_SYSCALL_REBOOT_REGARGS |
| 79 |
@_SYSCALL_REBOOT_ARGSTR |
| 80 |
} |
| 81 |
|
| 82 |
/* kernel 4.17+ */ |
| 83 |
probe nd2_syscall.reboot = kprobe.function(@arch_syscall_prefix "sys_reboot") ? |
| 84 |
{ |
| 85 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 86 |
@_SYSCALL_REBOOT_NAME |
| 87 |
@_SYSCALL_REBOOT_REGARGS |
| 88 |
@_SYSCALL_REBOOT_ARGSTR |
| 89 |
}, |
| 90 |
{ |
| 91 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_REBOOT_REGARGS_STORE %) |
| 92 |
} |
| 93 |
|
| 94 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 95 |
probe tp_syscall.reboot = kernel.trace("sys_enter") |
| 96 |
{ |
| 97 |
__set_syscall_pt_regs($regs) |
| 98 |
@__syscall_compat_gate(@const("__NR_reboot"), @const("__NR_compat_reboot")) |
| 99 |
@_SYSCALL_REBOOT_NAME |
| 100 |
@_SYSCALL_REBOOT_REGARGS |
| 101 |
@_SYSCALL_REBOOT_ARGSTR |
| 102 |
}, |
| 103 |
{ |
| 104 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_REBOOT_REGARGS_STORE %) |
| 105 |
} |
| 106 |
|
| 107 |
probe nd_syscall.reboot.return = nd1_syscall.reboot.return!, nd2_syscall.reboot.return!, tp_syscall.reboot.return |
| 108 |
{ } |
| 109 |
|
| 110 |
probe nd1_syscall.reboot.return = kprobe.function("sys_reboot").return ? |
| 111 |
{ |
| 112 |
@_SYSCALL_REBOOT_NAME |
| 113 |
@SYSC_RETVALSTR(returnval()) |
| 114 |
} |
| 115 |
|
| 116 |
/* kernel 4.17+ */ |
| 117 |
probe nd2_syscall.reboot.return = kprobe.function(@arch_syscall_prefix "sys_reboot").return ? |
| 118 |
{ |
| 119 |
@_SYSCALL_REBOOT_NAME |
| 120 |
@SYSC_RETVALSTR(returnval()) |
| 121 |
} |
| 122 |
|
| 123 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 124 |
probe tp_syscall.reboot.return = kernel.trace("sys_exit") |
| 125 |
{ |
| 126 |
__set_syscall_pt_regs($regs) |
| 127 |
@__syscall_compat_gate(@const("__NR_reboot"), @const("__NR_compat_reboot")) |
| 128 |
@_SYSCALL_REBOOT_NAME |
| 129 |
@SYSC_RETVALSTR($ret) |
| 130 |
} |