Skip to content

Commit ce5d112

Browse files
committed
ARCH: AUDIT: implement syscall_get_arch for all arches
For all arches which support audit implement syscall_get_arch() They are all pretty easy and straight forward, stolen from how the call to audit_syscall_entry() determines the arch. Based-on-patch-by: Richard Briggs <rgb@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com> Cc: linux-ia64@vger.kernel.org Cc: microblaze-uclinux@itee.uq.edu.au Cc: linux-mips@linux-mips.org Cc: linux@lists.openrisc.net Cc: linux-parisc@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: sparclinux@vger.kernel.org
1 parent 0451623 commit ce5d112

8 files changed

Lines changed: 49 additions & 1 deletion

File tree

‎arch/ia64/include/asm/syscall.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef _ASM_SYSCALL_H
1414
#define _ASM_SYSCALL_H 1
1515

16+
#include <uapi/linux/audit.h>
1617
#include <linux/sched.h>
1718
#include <linux/err.h>
1819

@@ -79,4 +80,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
7980

8081
ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
8182
}
83+
84+
static inline int syscall_get_arch(void)
85+
{
86+
return AUDIT_ARCH_IA64;
87+
}
8288
#endif /* _ASM_SYSCALL_H */

‎arch/microblaze/include/asm/syscall.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef __ASM_MICROBLAZE_SYSCALL_H
22
#define __ASM_MICROBLAZE_SYSCALL_H
33

4+
#include <uapi/linux/audit.h>
45
#include <linux/kernel.h>
56
#include <linux/sched.h>
67
#include <asm/ptrace.h>
@@ -99,4 +100,8 @@ static inline void syscall_set_arguments(struct task_struct *task,
99100
asmlinkage long do_syscall_trace_enter(struct pt_regs *regs);
100101
asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
101102

103+
static inline int syscall_get_arch(void)
104+
{
105+
return AUDIT_ARCH_MICROBLAZE;
106+
}
102107
#endif /* __ASM_MICROBLAZE_SYSCALL_H */

‎arch/mips/include/asm/syscall.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ extern const unsigned long sysn32_call_table[];
129129

130130
static inline int syscall_get_arch(void)
131131
{
132-
int arch = EM_MIPS;
132+
int arch = AUDIT_ARCH_MIPS;
133133
#ifdef CONFIG_64BIT
134134
if (!test_thread_flag(TIF_32BIT_REGS))
135135
arch |= __AUDIT_ARCH_64BIT;

‎arch/openrisc/include/asm/syscall.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef __ASM_OPENRISC_SYSCALL_H__
2020
#define __ASM_OPENRISC_SYSCALL_H__
2121

22+
#include <uapi/linux/audit.h>
2223
#include <linux/err.h>
2324
#include <linux/sched.h>
2425

@@ -71,4 +72,8 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
7172
memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
7273
}
7374

75+
static inline int syscall_get_arch(void)
76+
{
77+
return AUDIT_ARCH_OPENRISC;
78+
}
7479
#endif

‎arch/parisc/include/asm/syscall.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#ifndef _ASM_PARISC_SYSCALL_H_
44
#define _ASM_PARISC_SYSCALL_H_
55

6+
#include <uapi/linux/audit.h>
7+
#include <linux/compat.h>
68
#include <linux/err.h>
79
#include <asm/ptrace.h>
810

@@ -37,4 +39,13 @@ static inline void syscall_get_arguments(struct task_struct *tsk,
3739
}
3840
}
3941

42+
static inline int syscall_get_arch(void)
43+
{
44+
int arch = AUDIT_ARCH_PARISC;
45+
#ifdef CONFIG_64BIT
46+
if (!is_compat_task())
47+
arch = AUDIT_ARCH_PARISC64;
48+
#endif
49+
return arch;
50+
}
4051
#endif /*_ASM_PARISC_SYSCALL_H_*/

‎arch/powerpc/include/asm/syscall.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef _ASM_SYSCALL_H
1414
#define _ASM_SYSCALL_H 1
1515

16+
#include <uapi/linux/audit.h>
17+
#include <linux/compat.h>
1618
#include <linux/sched.h>
1719

1820
/* ftrace syscalls requires exporting the sys_call_table */
@@ -86,4 +88,14 @@ static inline void syscall_set_arguments(struct task_struct *task,
8688
memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
8789
}
8890

91+
static inline int syscall_get_arch(void)
92+
{
93+
int arch = AUDIT_ARCH_PPC;
94+
95+
#ifdef CONFIG_PPC64
96+
if (!is_32bit_task())
97+
arch = AUDIT_ARCH_PPC64;
98+
#endif
99+
return arch;
100+
}
89101
#endif /* _ASM_SYSCALL_H */

‎arch/sparc/include/asm/syscall.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#ifndef __ASM_SPARC_SYSCALL_H
22
#define __ASM_SPARC_SYSCALL_H
33

4+
#include <uapi/linux/audit.h>
45
#include <linux/kernel.h>
56
#include <linux/sched.h>
67
#include <asm/ptrace.h>
8+
#include <asm/thread_info.h>
79

810
/*
911
* The syscall table always contains 32 bit pointers since we know that the
@@ -124,4 +126,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
124126
regs->u_regs[UREG_I0 + i + j] = args[j];
125127
}
126128

129+
static inline int syscall_get_arch(void)
130+
{
131+
return test_thread_flag(TIF_32BIT) ? AUDIT_ARCH_SPARC
132+
: AUDIT_ARCH_SPARC64;
133+
}
134+
127135
#endif /* __ASM_SPARC_SYSCALL_H */

‎include/uapi/linux/audit.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ enum {
351351
#define AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
352352
#define AUDIT_ARCH_M32R (EM_M32R)
353353
#define AUDIT_ARCH_M68K (EM_68K)
354+
#define AUDIT_ARCH_MICROBLAZE (EM_MICROBLAZE)
354355
#define AUDIT_ARCH_MIPS (EM_MIPS)
355356
#define AUDIT_ARCH_MIPSEL (EM_MIPS|__AUDIT_ARCH_LE)
356357
#define AUDIT_ARCH_MIPS64 (EM_MIPS|__AUDIT_ARCH_64BIT)

0 commit comments

Comments
 (0)