From: jcm@jonmasters.org (Jon Masters)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: Fix restoration of IP scratch register when auditing syscalls
Date: Sun, 29 Apr 2012 02:38:24 -0400 [thread overview]
Message-ID: <1335681504-4609-2-git-send-email-jcm@jonmasters.org> (raw)
In-Reply-To: <1335681504-4609-1-git-send-email-jcm@jonmasters.org>
The audit subsystem builds upon ptrace to record system calls. This is done
in a couple of places (on return from fork into a new task, on exit from
the SWI vector), using calls to syscall_trace. The latter function abuses
the userspace intra-procedure scratch register (regs->ARM_ip, aka r12),
and intends to restore it prior to return to userspace. Unfortunately,
there are cases where we will return to userspace without restoring.
If we are in fact not ptracing but are merely auditing calls, we will
happily trash the content of ip but will exit to userspace without
restoring the value. It just so happens that GLIBC uses ip as a
storage for the TLS thread pointer info, and bad things result.
The fix is simply to have an additional out when not ptracing.
Signed-off-by: Jon Masters <jcm@jonmasters.org>
---
arch/arm/kernel/ptrace.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index ede6443..7b05b6e 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -928,10 +928,10 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
audit_syscall_entry(AUDIT_ARCH_NR, scno, regs->ARM_r0,
regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);
- if (!test_thread_flag(TIF_SYSCALL_TRACE))
- return scno;
+ if (!test_thread_flag(TIF_SYSCALL_TRACE))
+ goto out_no_ptrace;
if (!(current->ptrace & PT_PTRACED))
- return scno;
+ goto out_no_ptrace;
current_thread_info()->syscall = scno;
@@ -951,4 +951,8 @@ asmlinkage int syscall_trace(int why, struct pt_regs *regs, int scno)
regs->ARM_ip = ip;
return current_thread_info()->syscall;
+
+out_no_ptrace:
+ regs->ARM_ip = ip;
+ return scno;
}
--
1.7.7.4
next prev parent reply other threads:[~2012-04-29 6:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-29 6:38 Fixing audit on ARM Jon Masters
2012-04-29 6:38 ` Jon Masters [this message]
2012-04-30 10:07 ` [PATCH] ARM: Fix restoration of IP scratch register when auditing syscalls Will Deacon
2012-04-30 18:55 ` Jon Masters
2012-05-01 11:07 ` Will Deacon
2012-05-01 11:37 ` Russell King - ARM Linux
2012-05-01 16:52 ` Jon Masters
2012-05-02 6:27 ` Jon Masters
2012-05-02 8:58 ` Will Deacon
2012-05-02 14:10 ` Jon Masters
2012-05-02 14:48 ` Eric Paris
2012-05-02 15:39 ` Will Deacon
2012-05-02 17:37 ` Jon Masters
2012-04-30 19:00 ` Russell King - ARM Linux
2012-05-03 2:59 ` Jon Masters
2012-05-03 3:03 ` Al Viro
2012-05-03 8:55 ` Will Deacon
2012-05-03 7:34 ` Russell King - ARM Linux
2012-05-02 6:22 ` Jon Masters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335681504-4609-2-git-send-email-jcm@jonmasters.org \
--to=jcm@jonmasters.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).