Skip to content

Commit 5125430

Browse files
wildea01Russell King
authored andcommitted
ARM: 7455/1: audit: move syscall auditing until after ptrace SIGTRAP handling
When auditing system calls on ARM, the audit code is called before notifying the parent process in the case that the current task is being ptraced. At this point, the parent (debugger) may choose to change the system call being issued via the SET_SYSCALL ptrace request, causing the wrong system call to be reported to the audit tools. This patch moves the audit calls after the ptrace SIGTRAP handling code in the syscall tracing implementation. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 64284a9 commit 5125430

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎arch/arm/kernel/ptrace.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -911,14 +911,8 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
911911
{
912912
unsigned long ip;
913913

914-
if (why)
915-
audit_syscall_exit(regs);
916-
else
917-
audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0,
918-
regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);
919-
920914
if (!test_thread_flag(TIF_SYSCALL_TRACE))
921-
return scno;
915+
goto out_no_trace;
922916

923917
current_thread_info()->syscall = scno;
924918

@@ -935,6 +929,13 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
935929
current_thread_info()->syscall = -1;
936930

937931
regs->ARM_ip = ip;
932+
scno = current_thread_info()->syscall;
938933

939-
return current_thread_info()->syscall;
934+
out_no_trace:
935+
if (why)
936+
audit_syscall_exit(regs);
937+
else
938+
audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0,
939+
regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);
940+
return scno;
940941
}

0 commit comments

Comments
 (0)