public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x32: Mask away the x32 syscall bit in the ptrace codepath
@ 2014-05-28 12:19 Philipp Kern
  2014-05-28 20:47 ` Andy Lutomirski
  0 siblings, 1 reply; 10+ messages in thread
From: Philipp Kern @ 2014-05-28 12:19 UTC (permalink / raw)
  To: hpa; +Cc: Philipp Kern, linux-kernel, H. J. Lu, Eric Paris

audit_filter_syscall uses the syscall number to reference into a
bitmask (e->rule.mask[word]). Not removing the x32 bit before passing
the number to this architecture independent codepath will fail to
lookup the proper audit bit. Furthermore it will cause an invalid memory
access in the kernel if the out of bound location is not mapped:

  BUG: unable to handle kernel paging request at ffff8800e5446630
  IP: [<ffffffff810fcdd0>] audit_filter_syscall+0x90/0xf0

Together with the entrypoint in entry_64.S this change causes x32
programs to pass in both AUDIT_ARCH_X86_64 and AUDIT_ARCH_I386 depending
on the syscall path.

Cc: linux-kernel@vger.kernel.org
Cc: H. J. Lu <hjl.tools@gmail.com>
Cc: Eric Paris <eparis@redhat.com>
Signed-off-by: Philipp Kern <pkern@google.com>
---
 arch/x86/kernel/ptrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 678c0ad..166a3c7 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1489,7 +1489,7 @@ long syscall_trace_enter(struct pt_regs *regs)
 
 	if (IS_IA32)
 		audit_syscall_entry(AUDIT_ARCH_I386,
-				    regs->orig_ax,
+				    regs->orig_ax & __SYSCALL_MASK,
 				    regs->bx, regs->cx,
 				    regs->dx, regs->si);
 #ifdef CONFIG_X86_64
-- 
1.9.1.423.g4596e3a


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-05-28 22:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-28 12:19 [PATCH] x32: Mask away the x32 syscall bit in the ptrace codepath Philipp Kern
2014-05-28 20:47 ` Andy Lutomirski
2014-05-28 20:58   ` Philipp Kern
2014-05-28 21:01   ` H. Peter Anvin
2014-05-28 21:15     ` Andy Lutomirski
2014-05-28 21:19       ` H. Peter Anvin
2014-05-28 21:43         ` Andy Lutomirski
2014-05-28 21:53           ` Philipp Kern
2014-05-28 21:55             ` Andy Lutomirski
2014-05-28 22:37             ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox