| 1 |
# chown16 ___________________________________________________ |
| 2 |
# long sys_chown16(const char __user * filename, old_uid_t user, |
| 3 |
# old_gid_t group) |
| 4 |
# |
| 5 |
|
| 6 |
@define _SYSCALL_CHOWN16_NAME |
| 7 |
%( |
| 8 |
name = "chown16" |
| 9 |
%) |
| 10 |
|
| 11 |
@define _SYSCALL_CHOWN16_ARGSTR |
| 12 |
%( |
| 13 |
argstr = sprintf("%s, %d, %d", path, owner, group) |
| 14 |
%) |
| 15 |
|
| 16 |
@define _SYSCALL_CHOWN16_REGARGS |
| 17 |
%( |
| 18 |
path = user_string_quoted(pointer_arg(1)) |
| 19 |
path_unquoted = user_string_nofault(pointer_arg(1)) |
| 20 |
owner = __short(uint_arg(2)) |
| 21 |
group = __short(uint_arg(3)) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_CHOWN16_REGARGS_STORE |
| 25 |
%( |
| 26 |
if (@probewrite(path_unquoted)) |
| 27 |
set_user_string_arg(pointer_arg(1), path_unquoted) |
| 28 |
|
| 29 |
if (@probewrite(owner)) |
| 30 |
set_uint_arg(2, __short(owner)) |
| 31 |
|
| 32 |
if (@probewrite(group)) |
| 33 |
set_uint_arg(3, __short(group)) |
| 34 |
%) |
| 35 |
|
| 36 |
probe syscall.chown16 = dw_syscall.chown16 !, nd_syscall.chown16 ? {} |
| 37 |
probe syscall.chown16.return = dw_syscall.chown16.return !, nd_syscall.chown16.return ? {} |
| 38 |
|
| 39 |
# dw_chown16 _____________________________________________________ |
| 40 |
|
| 41 |
probe dw_syscall.chown16 = kernel.function("sys_chown16").call ? |
| 42 |
{ |
| 43 |
@_SYSCALL_CHOWN16_NAME |
| 44 |
path = user_string_quoted($filename) |
| 45 |
owner = __short($user) |
| 46 |
group = __short($group) |
| 47 |
@_SYSCALL_CHOWN16_ARGSTR |
| 48 |
} |
| 49 |
probe dw_syscall.chown16.return = kernel.function("sys_chown16").return ? |
| 50 |
{ |
| 51 |
@_SYSCALL_CHOWN16_NAME |
| 52 |
@SYSC_RETVALSTR($return) |
| 53 |
} |
| 54 |
|
| 55 |
# nd_chown16 _____________________________________________________ |
| 56 |
|
| 57 |
probe nd_syscall.chown16 = nd1_syscall.chown16!, nd2_syscall.chown16!, tp_syscall.chown16 |
| 58 |
{ } |
| 59 |
|
| 60 |
probe nd1_syscall.chown16 = kprobe.function("sys_chown16") ? |
| 61 |
{ |
| 62 |
@_SYSCALL_CHOWN16_NAME |
| 63 |
asmlinkage() |
| 64 |
@_SYSCALL_CHOWN16_REGARGS |
| 65 |
@_SYSCALL_CHOWN16_ARGSTR |
| 66 |
} |
| 67 |
|
| 68 |
/* kernel 4.17+ */ |
| 69 |
probe nd2_syscall.chown16 = kprobe.function(@arch_syscall_prefix "sys_chown16") ? |
| 70 |
{ |
| 71 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 72 |
@_SYSCALL_CHOWN16_NAME |
| 73 |
@_SYSCALL_CHOWN16_REGARGS |
| 74 |
@_SYSCALL_CHOWN16_ARGSTR |
| 75 |
}, |
| 76 |
{ |
| 77 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_CHOWN16_REGARGS_STORE %) |
| 78 |
} |
| 79 |
|
| 80 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 81 |
probe tp_syscall.chown16 = kernel.trace("sys_enter") |
| 82 |
{ |
| 83 |
__set_syscall_pt_regs($regs) |
| 84 |
%( CONFIG_64BIT == "y" %? |
| 85 |
@__compat_syscall_gate(@const("__NR_compat_chown")) |
| 86 |
%: |
| 87 |
@__syscall_gate(@const("__NR_chown")) |
| 88 |
%) |
| 89 |
@_SYSCALL_CHOWN16_NAME |
| 90 |
@_SYSCALL_CHOWN16_REGARGS |
| 91 |
@_SYSCALL_CHOWN16_ARGSTR |
| 92 |
}, |
| 93 |
{ |
| 94 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_CHOWN16_REGARGS_STORE %) |
| 95 |
} |
| 96 |
|
| 97 |
probe nd_syscall.chown16.return = nd1_syscall.chown16.return!, nd2_syscall.chown16.return!, tp_syscall.chown16.return |
| 98 |
{ } |
| 99 |
|
| 100 |
probe nd1_syscall.chown16.return = kprobe.function("sys_chown16").return ? |
| 101 |
{ |
| 102 |
@_SYSCALL_CHOWN16_NAME |
| 103 |
@SYSC_RETVALSTR(returnval()) |
| 104 |
} |
| 105 |
|
| 106 |
/* kernel 4.17+ */ |
| 107 |
probe nd2_syscall.chown16.return = kprobe.function(@arch_syscall_prefix "sys_chown16").return ? |
| 108 |
{ |
| 109 |
@_SYSCALL_CHOWN16_NAME |
| 110 |
@SYSC_RETVALSTR(returnval()) |
| 111 |
} |
| 112 |
|
| 113 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 114 |
probe tp_syscall.chown16.return = kernel.trace("sys_exit") |
| 115 |
{ |
| 116 |
__set_syscall_pt_regs($regs) |
| 117 |
%( CONFIG_64BIT == "y" %? |
| 118 |
@__compat_syscall_gate(@const("__NR_compat_chown")) |
| 119 |
%: |
| 120 |
@__syscall_gate(@const("__NR_chown")) |
| 121 |
%) |
| 122 |
@_SYSCALL_CHOWN16_NAME |
| 123 |
@SYSC_RETVALSTR($ret) |
| 124 |
} |