| 1 |
# personality ________________________________________________ |
| 2 |
# |
| 3 |
# asmlinkage long |
| 4 |
# sys_personality(unsigned int personality) |
| 5 |
# personality type changed from ulong to uint32 in upstream commit 485d5276 |
| 6 |
# (v2.6.35-rc2~25). But rhel6 distribution kernel has the backport in 2.6.32. |
| 7 |
# |
| 8 |
|
| 9 |
@define _SYSCALL_PERSONALITY_NAME |
| 10 |
%( |
| 11 |
name = "personality" |
| 12 |
%) |
| 13 |
|
| 14 |
@define _SYSCALL_PERSONALITY_ARGSTR |
| 15 |
%( |
| 16 |
argstr = sprintf("%#x", persona); |
| 17 |
%) |
| 18 |
|
| 19 |
@define _SYSCALL_PERSONALITY_REGARGS |
| 20 |
%( |
| 21 |
persona = uint_arg(1) |
| 22 |
%) |
| 23 |
|
| 24 |
@define _SYSCALL_PERSONALITY_REGARGS_STORE |
| 25 |
%( |
| 26 |
if (@probewrite(persona)) |
| 27 |
set_uint_arg(1, persona) |
| 28 |
%) |
| 29 |
|
| 30 |
probe syscall.personality = dw_syscall.personality !, nd_syscall.personality ? {} |
| 31 |
probe syscall.personality.return = dw_syscall.personality.return !, |
| 32 |
nd_syscall.personality.return ? {} |
| 33 |
|
| 34 |
# dw_personality _____________________________________________________ |
| 35 |
|
| 36 |
probe dw_syscall.personality = kernel.function("sys_personality").call |
| 37 |
{ |
| 38 |
@_SYSCALL_PERSONALITY_NAME |
| 39 |
persona = __uint32($personality) |
| 40 |
@_SYSCALL_PERSONALITY_ARGSTR |
| 41 |
} |
| 42 |
probe dw_syscall.personality.return = kernel.function("sys_personality").return |
| 43 |
{ |
| 44 |
@_SYSCALL_PERSONALITY_NAME |
| 45 |
@SYSC_RETVALSTR($return) |
| 46 |
} |
| 47 |
|
| 48 |
# nd_personality _____________________________________________________ |
| 49 |
|
| 50 |
probe nd_syscall.personality = nd1_syscall.personality!, nd2_syscall.personality!, tp_syscall.personality |
| 51 |
{ } |
| 52 |
|
| 53 |
probe nd1_syscall.personality = kprobe.function("sys_personality") ? |
| 54 |
{ |
| 55 |
@_SYSCALL_PERSONALITY_NAME |
| 56 |
asmlinkage() |
| 57 |
@_SYSCALL_PERSONALITY_REGARGS |
| 58 |
@_SYSCALL_PERSONALITY_ARGSTR |
| 59 |
} |
| 60 |
|
| 61 |
/* kernel 4.17+ */ |
| 62 |
probe nd2_syscall.personality = kprobe.function(@arch_syscall_prefix "sys_personality") ? |
| 63 |
{ |
| 64 |
__set_syscall_pt_regs(pointer_arg(1)) |
| 65 |
@_SYSCALL_PERSONALITY_NAME |
| 66 |
@_SYSCALL_PERSONALITY_REGARGS |
| 67 |
@_SYSCALL_PERSONALITY_ARGSTR |
| 68 |
}, |
| 69 |
{ |
| 70 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_PERSONALITY_REGARGS_STORE %) |
| 71 |
} |
| 72 |
|
| 73 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 74 |
probe tp_syscall.personality = kernel.trace("sys_enter") |
| 75 |
{ |
| 76 |
__set_syscall_pt_regs($regs) |
| 77 |
@__syscall_compat_gate(@const("__NR_personality"), @const("__NR_compat_personality")) |
| 78 |
@_SYSCALL_PERSONALITY_NAME |
| 79 |
@_SYSCALL_PERSONALITY_REGARGS |
| 80 |
@_SYSCALL_PERSONALITY_ARGSTR |
| 81 |
}, |
| 82 |
{ |
| 83 |
%( @_IS_SREG_KERNEL %? @_SYSCALL_PERSONALITY_REGARGS_STORE %) |
| 84 |
} |
| 85 |
|
| 86 |
probe nd_syscall.personality.return = nd1_syscall.personality.return!, nd2_syscall.personality.return!, tp_syscall.personality.return |
| 87 |
{ } |
| 88 |
|
| 89 |
probe nd1_syscall.personality.return = kprobe.function("sys_personality").return ? |
| 90 |
{ |
| 91 |
@_SYSCALL_PERSONALITY_NAME |
| 92 |
@SYSC_RETVALSTR(returnval()) |
| 93 |
} |
| 94 |
|
| 95 |
/* kernel 4.17+ */ |
| 96 |
probe nd2_syscall.personality.return = kprobe.function(@arch_syscall_prefix "sys_personality").return ? |
| 97 |
{ |
| 98 |
@_SYSCALL_PERSONALITY_NAME |
| 99 |
@SYSC_RETVALSTR(returnval()) |
| 100 |
} |
| 101 |
|
| 102 |
/* kernel 3.5+, but undesirable because it affects all syscalls */ |
| 103 |
probe tp_syscall.personality.return = kernel.trace("sys_exit") |
| 104 |
{ |
| 105 |
__set_syscall_pt_regs($regs) |
| 106 |
@__syscall_compat_gate(@const("__NR_personality"), @const("__NR_compat_personality")) |
| 107 |
@_SYSCALL_PERSONALITY_NAME |
| 108 |
@SYSC_RETVALSTR($ret) |
| 109 |
} |