Skip to content

Commit

Permalink
LoongArch: try to fix ptrace syscall tampering
Browse files Browse the repository at this point in the history
see strace/strace#205

Suggested-by: Huacai Chen <chenhuacai@kernel.org>
Signed-off-by: WANG Xuerui <git@xen0n.name>
  • Loading branch information
xen0n committed Jan 8, 2022
1 parent 90f35b4 commit d748c0a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arch/loongarch/include/asm/entry-common.h
Expand Up @@ -5,9 +5,23 @@
#include <linux/sched.h>
#include <linux/processor.h>

#include <asm/syscall.h>

static inline bool on_thread_stack(void)
{
return !(((unsigned long)(current->stack) ^ current_stack_pointer) & ~(THREAD_SIZE - 1));
}

static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs)
{
int ret = tracehook_report_syscall_entry(regs);

if (ret)
syscall_set_return_value(current, current_pt_regs(), -ENOSYS, 0);

return ret;
}

#define arch_syscall_enter_tracehook arch_syscall_enter_tracehook

#endif

0 comments on commit d748c0a

Please sign in to comment.