| 1 |
# umount _____________________________________________________ |
| 2 |
# long sys_umount(char __user * name, int flags) |
| 3 |
# SYSCALL_DEFINE1(oldumount, char __user *, name) |
| 4 |
# |
| 5 |
|
| 6 |
@define _SYSCALL_UMOUNT_NAME |
| 7 |
%( |
| 8 |
name = "umount" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_UMOUNT_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, %s", target, flags_str) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_UMOUNT_REGARGS |
| 17 |
%( |
| 18 |
target = user_string_quoted(pointer_arg(1)) |
| 19 |
target_unquoted = user_string_nofault(pointer_arg(1)) |
| 20 |
flags = int_arg(2) |
| 21 |
flags_str = _umountflags_str(flags) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_UMOUNT_REGARGS_STORE |
| 25 |
%( |
| 26 |
if (@probewrite(target_unquoted)) |
| 27 |
set_user_string_arg(pointer_arg(1), target_unquoted) |
| 28 |
|
| 29 |
if (@probewrite(flags)) |
| 30 |
set_int_arg(2, flags) |
| 31 |
%) |
| 32 |
|
| 33 |
@define _SYSCALL_OLDUMOUNT_REGARGS |
| 34 |
%( |
| 35 |
target = user_string_quoted(pointer_arg(1)) |
| 36 |
target_unquoted = user_string_nofault(pointer_arg(1)) |
| 37 |
flags = 0 |
| 38 |
flags_str = _umountflags_str(0) |
| 39 |
%) |
| 40 |
|
| 41 |
@define _SYSCALL_OLDUMOUNT_REGARGS_STORE |
| 42 |
%( |
| 43 |
if (@probewrite(target_unquoted)) |
| 44 |
set_user_string_arg(pointer_arg(1), target_unquoted) |
| 45 |
%) |
| 46 |
|
| 47 |
probe syscall.umount = dw_syscall.umount !, nd_syscall.umount ? {} |
| 48 |
probe syscall.umount.return = dw_syscall.umount.return !, |
| 49 |
nd_syscall.umount.return ? {} |
| 50 |
|
| 51 |
# dw_umount _____________________________________________________ |
| 52 |
|
| 53 |
probe dw_syscall.umount = __syscall.umount, __syscall.oldumount ? |
| 54 |
{ |
| 55 |
@_SYSCALL_UMOUNT_NAME |
| 56 |
} |
| 57 |
probe __syscall.umount = kernel.function("sys_umount").call |
| 58 |
{ |
| 59 |
@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2")) |
| 60 |
target = user_string_quoted($name) |
| 61 |
flags = $flags |
| 62 |
flags_str = _umountflags_str($flags) |
| 63 |
@_SYSCALL_UMOUNT_ARGSTR |
| 64 |
} |
| 65 |
probe __syscall.oldumount = kernel.function("sys_oldumount").call ? |
| 66 |
{ |
| 67 |
target = user_string_quoted($name) |
| 68 |
flags = 0 |
| 69 |
flags_str = _umountflags_str(0) |
| 70 |
@_SYSCALL_UMOUNT_ARGSTR |
| 71 |
} |
| 72 |
probe dw_syscall.umount.return = __syscall.umount.return, |
| 73 |
kernel.function("sys_oldumount").return ? |
| 74 |
{ |
| 75 |
@_SYSCALL_UMOUNT_NAME |
| 76 |
@SYSC_RETVALSTR($return) |
| 77 |
} |
| 78 |
probe __syscall.umount.return = kernel.function("sys_umount").return |
| 79 |
{ |
| 80 |
@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2")) |
| 81 |
} |
| 82 |
|
| 83 |
# nd_umount _____________________________________________________ |
| 84 |
|
| 85 |
probe nd_syscall.umount = nd1_syscall.umount!, nd2_syscall.umount!, tp_syscall.umount |
| 86 |
{ } |
| 87 |
|
| 88 |
probe nd1_syscall.umount = __nd1_syscall.umount, __nd1_syscall.oldumount ? |
| 89 |
{ |
| 90 |
@_SYSCALL_UMOUNT_NAME |
| 91 |
} |
| 92 |
probe __nd1_syscall.umount = kprobe.function("sys_umount") |
| 93 |
{ |
| 94 |
@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2")) |
| 95 |
asmlinkage() |
| 96 |
@_SYSCALL_UMOUNT_REGARGS |
| 97 |
@_SYSCALL_UMOUNT_ARGSTR |
| 98 |
} |
| 99 |
probe __nd1_syscall.oldumount = kprobe.function("sys_oldumount") ? |
| 100 |
{ |
| 101 |
asmlinkage() |
| 102 |
@_SYSCALL_OLDUMOUNT_REGARGS |
| 103 |
@_SYSCALL_UMOUNT_ARGSTR |
| 104 |
} |
| 105 |
|
| 106 |
/* kernel 4.17+ */ |
| 107 |
probe nd2_syscall.umount = __nd2_syscall.umount, __nd2_syscall.oldumount ? |
| 108 |
{ |
| 109 |
@_SYSCALL_UMOUNT_NAME |
| 110 |
} |
| 111 |
probe __nd2_syscall.umount = kprobe.function(@arch_syscall_prefix "sys_umount") |
| 112 |
{ |
| 113 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 114 |
@_SYSCALL_UMOUNT_REGARGS |
| 115 |
@_SYSCALL_UMOUNT_ARGSTR |
| 116 |
}, |
| 117 |
{ |
| 118 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_UMOUNT_REGARGS_STORE %) |
| 119 |
} |
| 120 |
probe __nd2_syscall.oldumount = kprobe.function(@arch_syscall_prefix "sys_oldumount") ? |
| 121 |
{ |
| 122 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 123 |
@_SYSCALL_OLDUMOUNT_REGARGS |
| 124 |
@_SYSCALL_UMOUNT_ARGSTR |
| 125 |
}, |
| 126 |
{ |
| 127 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_OLDUMOUNT_REGARGS_STORE %) |
| 128 |
} |
| 129 |
|
| 130 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 131 |
probe tp_syscall.umount = __tp_syscall.umount, __tp_syscall.oldumount ? |
| 132 |
{ |
| 133 |
@_SYSCALL_UMOUNT_NAME |
| 134 |
} |
| 135 |
probe __tp_syscall.umount = kernel.trace("sys_enter") |
| 136 |
{ |
| 137 |
__set_syscall_pt_regs($regs) |
| 138 |
@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2")) |
| 139 |
@_SYSCALL_UMOUNT_REGARGS |
| 140 |
@_SYSCALL_UMOUNT_ARGSTR |
| 141 |
}, |
| 142 |
{ |
| 143 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_UMOUNT_REGARGS_STORE %) |
| 144 |
} |
| 145 |
probe __tp_syscall.oldumount = kernel.trace("sys_enter") |
| 146 |
{ |
| 147 |
__set_syscall_pt_regs($regs) |
| 148 |
@__syscall_compat_gate(@const("__NR_umount"), @const("__NR_compat_umount")) |
| 149 |
@_SYSCALL_OLDUMOUNT_REGARGS |
| 150 |
@_SYSCALL_UMOUNT_ARGSTR |
| 151 |
}, |
| 152 |
{ |
| 153 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_OLDUMOUNT_REGARGS_STORE %) |
| 154 |
} |
| 155 |
|
| 156 |
probe nd_syscall.umount.return = nd1_syscall.umount.return!, nd2_syscall.umount.return!, tp_syscall.umount.return |
| 157 |
{ } |
| 158 |
|
| 159 |
probe nd1_syscall.umount.return = __nd1_syscall.umount.return, |
| 160 |
kprobe.function("sys_oldumount").return ? |
| 161 |
{ |
| 162 |
@_SYSCALL_UMOUNT_NAME |
| 163 |
@SYSC_RETVALSTR(returnval()) |
| 164 |
} |
| 165 |
probe __nd1_syscall.umount.return = kprobe.function("sys_umount").return |
| 166 |
{ |
| 167 |
@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2")) |
| 168 |
} |
| 169 |
|
| 170 |
/* kernel 4.17+ */ |
| 171 |
probe nd2_syscall.umount.return = kprobe.function(@arch_syscall_prefix "sys_umount").return, |
| 172 |
kprobe.function(@arch_syscall_prefix "sys_oldumount").return ? |
| 173 |
{ |
| 174 |
@_SYSCALL_UMOUNT_NAME |
| 175 |
@SYSC_RETVALSTR(returnval()) |
| 176 |
} |
| 177 |
|
| 178 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 179 |
probe tp_syscall.umount.return = __tp_syscall.umount.return, __tp_syscall.oldumount.return ? |
| 180 |
{ |
| 181 |
__set_syscall_pt_regs($regs) |
| 182 |
@_SYSCALL_UMOUNT_NAME |
| 183 |
@SYSC_RETVALSTR($ret) |
| 184 |
} |
| 185 |
probe __tp_syscall.umount.return = kernel.trace("sys_exit") |
| 186 |
{ |
| 187 |
@__syscall_compat_gate(@const("__NR_umount2"), @const("__NR_compat_umount2")) |
| 188 |
} |
| 189 |
probe __tp_syscall.oldumount.return = kernel.trace("sys_exit") |
| 190 |
{ |
| 191 |
@__syscall_compat_gate(@const("__NR_umount"), @const("__NR_compat_umount")) |
| 192 |
} |