Re: [PATCH] powerpc: add little endian flag to syscall_get_arch()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2015-02-03 at 11:33 +0000, Luis Henriques wrote:
> On Thu, Jan 29, 2015 at 01:07:40AM +0000, Ben Hutchings wrote:
> > On Thu, 2015-01-29 at 11:27 +1100, Michael Ellerman wrote:
> > > On Wed, 2015-01-28 at 20:26 +0000, Ben Hutchings wrote:
> > > > On Tue, 2015-01-13 at 16:19 +1100, Michael Ellerman wrote:
> > > > > On Mon, 2015-01-12 at 04:20 -0800, Greg KH wrote:
> > > > > > On Mon, Jan 12, 2015 at 08:13:49PM +1100, Michael Ellerman wrote:
> > > > > > > From: Richard Guy Briggs <rgb@xxxxxxxxxx>
> > > > > > > 
> > > > > > > Commit 63f13448d81c910a284b096149411a719cbed501 upstream.
> > > > > > 
> > > > > > What stable kernel branch do you want this applied to?
> > > > > 
> > > > > Just 3.18 thanks.
> > > > 
> > > > Don't we need a similar fix to do_syscall_trace_enter() in earlier
> > > > versions?
> > > 
> > > Probably.
> > > 
> > > I'd convinced myself there weren't any stable versions that were a) still alive
> > > and b) had ppc64le support. But it looks like I was wrong, 3.14 longterm is
> > > still going and does contain ppc64le.
> > > 
> > > And maybe there are other "stable" branches out there that also need it?
> > 
> > There are the unofficial 3.13.11-ckt and 3.16.7-ckt branches.  There is
> > also a 3.12 longterm branch but I'm not clear whether ppc64le worked at
> > all in 3.12.
> > 
> 
> Is there a patch with this fix, or would this be a stable-specific
> patch?  I couldn't find anything commit but maybe I was looking at the
> wrong place.

I guess something like this (untested):

---
From: Richard Guy Briggs <rgb@xxxxxxxxxx>
Date: Tue, 9 Dec 2014 15:37:07 -0500
Subject: [PATCH] powerpc: add little endian flag to syscall_get_arch()

commit 63f13448d81c910a284b096149411a719cbed501 upstream.

Since both ppc and ppc64 have LE variants which are now reported by uname, add
that flag (__AUDIT_ARCH_LE) to syscall_get_arch() and add AUDIT_ARCH_PPC64LE
variant.

Without this,  perf trace and auditctl fail.

Mainline kernel reports ppc64le (per a058801) but there is no matching
AUDIT_ARCH_PPC64LE.

Since 32-bit PPC LE is not supported by audit, don't advertise it in
AUDIT_ARCH_PPC* variants.

See:
	https://www.redhat.com/archives/linux-audit/2014-August/msg00082.html
	https://www.redhat.com/archives/linux-audit/2014-December/msg00004.html

Signed-off-by: Richard Guy Briggs <rgb@xxxxxxxxxx>
Acked-by: Paul Moore <paul@xxxxxxxxxxxxxx>
Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
[bwh: Backported to 3.16: arch is passed in by do_syscall_trace_enter()
 rather than queried by calling syscall_get_arch()]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
 arch/powerpc/kernel/ptrace.c | 10 ++++++++--
 include/uapi/linux/audit.h   |  2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 2e3d2bf..665ff66 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -1769,6 +1769,7 @@ long arch_ptrace(struct task_struct *child, long request,
 long do_syscall_trace_enter(struct pt_regs *regs)
 {
 	long ret = 0;
+	int arch;
 
 	user_exit();
 
@@ -1786,15 +1787,20 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_sys_enter(regs, regs->gpr[0]);
 
+	arch = is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64;
+#ifdef __LITTLE_ENDIAN__
+	arch |= __AUDIT_ARCH_LE;
+#endif
+
 #ifdef CONFIG_PPC64
 	if (!is_32bit_task())
-		audit_syscall_entry(AUDIT_ARCH_PPC64,
+		audit_syscall_entry(arch,
 				    regs->gpr[0],
 				    regs->gpr[3], regs->gpr[4],
 				    regs->gpr[5], regs->gpr[6]);
 	else
 #endif
-		audit_syscall_entry(AUDIT_ARCH_PPC,
+		audit_syscall_entry(arch,
 				    regs->gpr[0],
 				    regs->gpr[3] & 0xffffffff,
 				    regs->gpr[4] & 0xffffffff,
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index cf67147..6f94bf3 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -363,7 +363,9 @@ enum {
 #define AUDIT_ARCH_PARISC	(EM_PARISC)
 #define AUDIT_ARCH_PARISC64	(EM_PARISC|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_PPC		(EM_PPC)
+/* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
 #define AUDIT_ARCH_PPC64	(EM_PPC64|__AUDIT_ARCH_64BIT)
+#define AUDIT_ARCH_PPC64LE	(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_S390		(EM_S390)
 #define AUDIT_ARCH_S390X	(EM_S390|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_SH		(EM_SH)


-- 
Ben Hutchings
Hoare's Law of Large Problems:
        Inside every large problem is a small problem struggling to get out.

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]