# munlockall _________________________________________________
# long sys_munlockall(void)

@define _SYSCALL_MUNLOCKALL_NAME
%(
	name = "munlockall"
%)

@define _SYSCALL_MUNLOCKALL_ARGSTR
%(
	argstr = ""
%)

probe syscall.munlockall = dw_syscall.munlockall !, nd_syscall.munlockall ? {}
probe syscall.munlockall.return = dw_syscall.munlockall.return !,
                                  nd_syscall.munlockall.return ? {}

# dw_munlockall _____________________________________________________

probe dw_syscall.munlockall = kernel.function("sys_munlockall").call ?
{
	@_SYSCALL_MUNLOCKALL_NAME
	@_SYSCALL_MUNLOCKALL_ARGSTR
}
probe dw_syscall.munlockall.return = kernel.function("sys_munlockall").return ?
{
	@_SYSCALL_MUNLOCKALL_NAME
	@SYSC_RETVALSTR($return)
}

# nd_munlockall _____________________________________________________

probe nd_syscall.munlockall = nd1_syscall.munlockall!, nd2_syscall.munlockall!, tp_syscall.munlockall
  { }

probe nd1_syscall.munlockall = kprobe.function("sys_munlockall") ?
{
	@_SYSCALL_MUNLOCKALL_NAME
	@_SYSCALL_MUNLOCKALL_ARGSTR
}

/* kernel 4.17+ */
probe nd2_syscall.munlockall = kprobe.function(@arch_syscall0_prefix "sys_munlockall") ?
{
	__set_syscall_pt_regs(pointer_arg(1))
	@_SYSCALL_MUNLOCKALL_NAME
	@_SYSCALL_MUNLOCKALL_ARGSTR
}

/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.munlockall = kernel.trace("sys_enter")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_munlockall"), @const("__NR_compat_munlockall"))
	@_SYSCALL_MUNLOCKALL_NAME
	@_SYSCALL_MUNLOCKALL_ARGSTR
}

probe nd_syscall.munlockall.return = nd1_syscall.munlockall.return!, nd2_syscall.munlockall.return!, tp_syscall.munlockall.return
  { }
  
probe nd1_syscall.munlockall.return = kprobe.function("sys_munlockall").return ?
{
	@_SYSCALL_MUNLOCKALL_NAME
	@SYSC_RETVALSTR(returnval())
}

/* kernel 4.17+ */
probe nd2_syscall.munlockall.return = kprobe.function(@arch_syscall0_prefix "sys_munlockall").return ?
{
	@_SYSCALL_MUNLOCKALL_NAME
	@SYSC_RETVALSTR(returnval())
}
 
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.munlockall.return = kernel.trace("sys_exit")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_munlockall"), @const("__NR_compat_munlockall"))
	@_SYSCALL_MUNLOCKALL_NAME
	@SYSC_RETVALSTR($ret)
}
