Skip to content

Commit 6a68b6f

Browse files
wildea01Russell King
authored andcommitted
ARM: 7411/1: audit: fix treatment of saved ip register during syscall tracing
The ARM audit code incorrectly uses the saved application ip register value to infer syscall entry or exit. Additionally, the saved value will be clobbered if the current task is not being traced, which can lead to libc corruption if ip is live (apparently glibc uses it for the TLS pointer). This patch fixes the syscall tracing code so that the why parameter is used to infer the syscall direction and the saved ip is only updated if we know that we will be signalling a ptrace trap. Reported-and-Tested-by: Jon Masters <jcm@jonmasters.org> Cc: stable@vger.kernel.org Cc: Eric Paris <eparis@redhat.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent e787ec1 commit 6a68b6f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎arch/arm/kernel/ptrace.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -916,14 +916,7 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
916916
{
917917
unsigned long ip;
918918

919-
/*
920-
* Save IP. IP is used to denote syscall entry/exit:
921-
* IP = 0 -> entry, = 1 -> exit
922-
*/
923-
ip = regs->ARM_ip;
924-
regs->ARM_ip = why;
925-
926-
if (!ip)
919+
if (why)
927920
audit_syscall_exit(regs);
928921
else
929922
audit_syscall_entry(AUDIT_ARCH_NR, scno, regs->ARM_r0,
@@ -936,6 +929,13 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
936929

937930
current_thread_info()->syscall = scno;
938931

932+
/*
933+
* IP is used to denote syscall entry/exit:
934+
* IP = 0 -> entry, =1 -> exit
935+
*/
936+
ip = regs->ARM_ip;
937+
regs->ARM_ip = why;
938+
939939
/* the 0x80 provides a way for the tracing parent to distinguish
940940
between a syscall stop and SIGTRAP delivery */
941941
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)

0 commit comments

Comments
 (0)