summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-19 19:25:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-19 19:25:56 -0400
commitab074ade9c33b3585da86d62e87bcb3e897a3f54 (patch)
tree142b42182889c64813af997b8701707a3397e834 /arch
parent61ed53deb1c6a4386d8710dbbfcee8779c381931 (diff)
parent2991dd2b0117e864f394c826af6df144206ce0db (diff)
Merge git://git.infradead.org/users/eparis/audit
Pull audit updates from Eric Paris: "So this change across a whole bunch of arches really solves one basic problem. We want to audit when seccomp is killing a process. seccomp hooks in before the audit syscall entry code. audit_syscall_entry took as an argument the arch of the given syscall. Since the arch is part of what makes a syscall number meaningful it's an important part of the record, but it isn't available when seccomp shoots the syscall... For most arch's we have a better way to get the arch (syscall_get_arch) So the solution was two fold: Implement syscall_get_arch() everywhere there is audit which didn't have it. Use syscall_get_arch() in the seccomp audit code. Having syscall_get_arch() everywhere meant it was a useless flag on the stack and we could get rid of it for the typical syscall entry. The other changes inside the audit system aren't grand, fixed some records that had invalid spaces. Better locking around the task comm field. Removing some dead functions and structs. Make some things static. Really minor stuff" * git://git.infradead.org/users/eparis/audit: (31 commits) audit: rename audit_log_remove_rule to disambiguate for trees audit: cull redundancy in audit_rule_change audit: WARN if audit_rule_change called illegally audit: put rule existence check in canonical order next: openrisc: Fix build audit: get comm using lock to avoid race in string printing audit: remove open_arg() function that is never used audit: correct AUDIT_GET_FEATURE return message type audit: set nlmsg_len for multicast messages. audit: use union for audit_field values since they are mutually exclusive audit: invalid op= values for rules audit: use atomic_t to simplify audit_serial() kernel/audit.c: use ARRAY_SIZE instead of sizeof/sizeof[0] audit: reduce scope of audit_log_fcaps audit: reduce scope of audit_net_id audit: arm64: Remove the audit arch argument to audit_syscall_entry arm64: audit: Add audit hook in syscall_trace_enter/exit() audit: x86: drop arch from __audit_syscall_entry() interface sparc: implement is_32bit_task sparc: properly conditionalize use of TIF_32BIT ...
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/include/asm/syscall.h11
-rw-r--r--arch/alpha/kernel/ptrace.c2
-rw-r--r--arch/arm/kernel/ptrace.c4
-rw-r--r--arch/arm64/kernel/ptrace.c4
-rw-r--r--arch/ia64/include/asm/syscall.h6
-rw-r--r--arch/ia64/kernel/ptrace.c2
-rw-r--r--arch/microblaze/include/asm/syscall.h5
-rw-r--r--arch/microblaze/kernel/ptrace.c3
-rw-r--r--arch/mips/include/asm/syscall.h2
-rw-r--r--arch/mips/kernel/ptrace.c4
-rw-r--r--arch/openrisc/include/asm/syscall.h5
-rw-r--r--arch/openrisc/include/uapi/asm/elf.h3
-rw-r--r--arch/openrisc/kernel/ptrace.c3
-rw-r--r--arch/parisc/include/asm/syscall.h11
-rw-r--r--arch/parisc/kernel/ptrace.c9
-rw-r--r--arch/powerpc/include/asm/syscall.h6
-rw-r--r--arch/powerpc/kernel/ptrace.c7
-rw-r--r--arch/s390/kernel/ptrace.c4
-rw-r--r--arch/sh/include/asm/syscall_32.h10
-rw-r--r--arch/sh/include/asm/syscall_64.h14
-rw-r--r--arch/sh/kernel/ptrace_32.c14
-rw-r--r--arch/sh/kernel/ptrace_64.c17
-rw-r--r--arch/sparc/include/asm/syscall.h7
-rw-r--r--arch/sparc/include/asm/thread_info_32.h2
-rw-r--r--arch/sparc/include/asm/thread_info_64.h2
-rw-r--r--arch/sparc/kernel/ptrace_64.c9
-rw-r--r--arch/um/kernel/ptrace.c3
-rw-r--r--arch/x86/ia32/ia32entry.S12
-rw-r--r--arch/x86/kernel/entry_32.S11
-rw-r--r--arch/x86/kernel/ptrace.c4
-rw-r--r--arch/x86/um/asm/ptrace.h4
-rw-r--r--arch/x86/um/asm/syscall.h15
-rw-r--r--arch/xtensa/kernel/ptrace.c2
33 files changed, 130 insertions, 87 deletions
diff --git a/arch/alpha/include/asm/syscall.h b/arch/alpha/include/asm/syscall.h
new file mode 100644
index 000000000000..88d28eb2a566
--- /dev/null
+++ b/arch/alpha/include/asm/syscall.h
@@ -0,0 +1,11 @@
1#ifndef _ASM_ALPHA_SYSCALL_H
2#define _ASM_ALPHA_SYSCALL_H
3
4#include <uapi/linux/audit.h>
5
6static inline int syscall_get_arch(void)
7{
8 return AUDIT_ARCH_ALPHA;
9}
10
11#endif /* _ASM_ALPHA_SYSCALL_H */
diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
index 86d835157b54..d9ee81769899 100644
--- a/arch/alpha/kernel/ptrace.c
+++ b/arch/alpha/kernel/ptrace.c
@@ -321,7 +321,7 @@ asmlinkage unsigned long syscall_trace_enter(void)
321 if (test_thread_flag(TIF_SYSCALL_TRACE) && 321 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
322 tracehook_report_syscall_entry(current_pt_regs())) 322 tracehook_report_syscall_entry(current_pt_regs()))
323 ret = -1UL; 323 ret = -1UL;
324 audit_syscall_entry(AUDIT_ARCH_ALPHA, regs->r0, regs->r16, regs->r17, regs->r18, regs->r19); 324 audit_syscall_entry(regs->r0, regs->r16, regs->r17, regs->r18, regs->r19);
325 return ret ?: current_pt_regs()->r0; 325 return ret ?: current_pt_regs()->r0;
326} 326}
327 327
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 5e772a21ab97..ef9119f7462e 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -949,8 +949,8 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
949 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 949 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
950 trace_sys_enter(regs, scno); 950 trace_sys_enter(regs, scno);
951 951
952 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1, 952 audit_syscall_entry(scno, regs->ARM_r0, regs->ARM_r1, regs->ARM_r2,
953 regs->ARM_r2, regs->ARM_r3); 953 regs->ARM_r3);
954 954
955 return scno; 955 return scno;
956} 956}
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index fe63ac5e9bf5..8a4ae8e73213 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1120,8 +1120,8 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
1120 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 1120 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
1121 trace_sys_enter(regs, regs->syscallno); 1121 trace_sys_enter(regs, regs->syscallno);
1122 1122
1123 audit_syscall_entry(syscall_get_arch(), regs->syscallno, 1123 audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1],
1124 regs->orig_x0, regs->regs[1], regs->regs[2], regs->regs[3]); 1124 regs->regs[2], regs->regs[3]);
1125 1125
1126 return regs->syscallno; 1126 return regs->syscallno;
1127} 1127}
diff --git a/arch/ia64/include/asm/syscall.h b/arch/ia64/include/asm/syscall.h
index a7ff1c6ab068..1d0b875fec44 100644
--- a/arch/ia64/include/asm/syscall.h
+++ b/arch/ia64/include/asm/syscall.h
@@ -13,6 +13,7 @@
13#ifndef _ASM_SYSCALL_H 13#ifndef _ASM_SYSCALL_H
14#define _ASM_SYSCALL_H 1 14#define _ASM_SYSCALL_H 1
15 15
16#include <uapi/linux/audit.h>
16#include <linux/sched.h> 17#include <linux/sched.h>
17#include <linux/err.h> 18#include <linux/err.h>
18 19
@@ -79,4 +80,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
79 80
80 ia64_syscall_get_set_arguments(task, regs, i, n, args, 1); 81 ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
81} 82}
83
84static inline int syscall_get_arch(void)
85{
86 return AUDIT_ARCH_IA64;
87}
82#endif /* _ASM_SYSCALL_H */ 88#endif /* _ASM_SYSCALL_H */
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index b7a5fffe0924..6f54d511cc50 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -1219,7 +1219,7 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
1219 ia64_sync_krbs(); 1219 ia64_sync_krbs();
1220 1220
1221 1221
1222 audit_syscall_entry(AUDIT_ARCH_IA64, regs.r15, arg0, arg1, arg2, arg3); 1222 audit_syscall_entry(regs.r15, arg0, arg1, arg2, arg3);
1223 1223
1224 return 0; 1224 return 0;
1225} 1225}
diff --git a/arch/microblaze/include/asm/syscall.h b/arch/microblaze/include/asm/syscall.h
index 9bc431783105..53cfaf34c343 100644
--- a/arch/microblaze/include/asm/syscall.h
+++ b/arch/microblaze/include/asm/syscall.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_MICROBLAZE_SYSCALL_H 1#ifndef __ASM_MICROBLAZE_SYSCALL_H
2#define __ASM_MICROBLAZE_SYSCALL_H 2#define __ASM_MICROBLAZE_SYSCALL_H
3 3
4#include <uapi/linux/audit.h>
4#include <linux/kernel.h> 5#include <linux/kernel.h>
5#include <linux/sched.h> 6#include <linux/sched.h>
6#include <asm/ptrace.h> 7#include <asm/ptrace.h>
@@ -99,4 +100,8 @@ static inline void syscall_set_arguments(struct task_struct *task,
99asmlinkage long do_syscall_trace_enter(struct pt_regs *regs); 100asmlinkage long do_syscall_trace_enter(struct pt_regs *regs);
100asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); 101asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
101 102
103static inline int syscall_get_arch(void)
104{
105 return AUDIT_ARCH_MICROBLAZE;
106}
102#endif /* __ASM_MICROBLAZE_SYSCALL_H */ 107#endif /* __ASM_MICROBLAZE_SYSCALL_H */
diff --git a/arch/microblaze/kernel/ptrace.c b/arch/microblaze/kernel/ptrace.c
index 39cf50841f6d..bb10637ce688 100644
--- a/arch/microblaze/kernel/ptrace.c
+++ b/arch/microblaze/kernel/ptrace.c
@@ -147,8 +147,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
147 */ 147 */
148 ret = -1L; 148 ret = -1L;
149 149
150 audit_syscall_entry(EM_MICROBLAZE, regs->r12, regs->r5, regs->r6, 150 audit_syscall_entry(regs->r12, regs->r5, regs->r6, regs->r7, regs->r8);
151 regs->r7, regs->r8);
152 151
153 return ret ?: regs->r12; 152 return ret ?: regs->r12;
154} 153}
diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
index cdf68b33bd65..bb7963753730 100644
--- a/arch/mips/include/asm/syscall.h
+++ b/arch/mips/include/asm/syscall.h
@@ -129,7 +129,7 @@ extern const unsigned long sysn32_call_table[];
129 129
130static inline int syscall_get_arch(void) 130static inline int syscall_get_arch(void)
131{ 131{
132 int arch = EM_MIPS; 132 int arch = AUDIT_ARCH_MIPS;
133#ifdef CONFIG_64BIT 133#ifdef CONFIG_64BIT
134 if (!test_thread_flag(TIF_32BIT_REGS)) { 134 if (!test_thread_flag(TIF_32BIT_REGS)) {
135 arch |= __AUDIT_ARCH_64BIT; 135 arch |= __AUDIT_ARCH_64BIT;
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index f7aac5b57b4b..9d1487d83293 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -780,9 +780,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
780 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 780 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
781 trace_sys_enter(regs, regs->regs[2]); 781 trace_sys_enter(regs, regs->regs[2]);
782 782
783 audit_syscall_entry(syscall_get_arch(), 783 audit_syscall_entry(syscall, regs->regs[4], regs->regs[5],
784 syscall,
785 regs->regs[4], regs->regs[5],
786 regs->regs[6], regs->regs[7]); 784 regs->regs[6], regs->regs[7]);
787 return syscall; 785 return syscall;
788} 786}
diff --git a/arch/openrisc/include/asm/syscall.h b/arch/openrisc/include/asm/syscall.h
index b752bb67891d..2db9f1cf0694 100644
--- a/arch/openrisc/include/asm/syscall.h
+++ b/arch/openrisc/include/asm/syscall.h
@@ -19,6 +19,7 @@
19#ifndef __ASM_OPENRISC_SYSCALL_H__ 19#ifndef __ASM_OPENRISC_SYSCALL_H__
20#define __ASM_OPENRISC_SYSCALL_H__ 20#define __ASM_OPENRISC_SYSCALL_H__
21 21
22#include <uapi/linux/audit.h>
22#include <linux/err.h> 23#include <linux/err.h>
23#include <linux/sched.h> 24#include <linux/sched.h>
24 25
@@ -71,4 +72,8 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
71 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0])); 72 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
72} 73}
73 74
75static inline int syscall_get_arch(void)
76{
77 return AUDIT_ARCH_OPENRISC;
78}
74#endif 79#endif
diff --git a/arch/openrisc/include/uapi/asm/elf.h b/arch/openrisc/include/uapi/asm/elf.h
index f02ea5830420..88842760e66f 100644
--- a/arch/openrisc/include/uapi/asm/elf.h
+++ b/arch/openrisc/include/uapi/asm/elf.h
@@ -55,9 +55,8 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
55/* A placeholder; OR32 does not have fp support yes, so no fp regs for now. */ 55/* A placeholder; OR32 does not have fp support yes, so no fp regs for now. */
56typedef unsigned long elf_fpregset_t; 56typedef unsigned long elf_fpregset_t;
57 57
58/* This should be moved to include/linux/elf.h */ 58/* EM_OPENRISC is defined in linux/elf-em.h */
59#define EM_OR32 0x8472 59#define EM_OR32 0x8472
60#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
61 60
62/* 61/*
63 * These are used to set parameters in the core dumps. 62 * These are used to set parameters in the core dumps.
diff --git a/arch/openrisc/kernel/ptrace.c b/arch/openrisc/kernel/ptrace.c
index 71a2a0c34c65..4f59fa4e34e5 100644
--- a/arch/openrisc/kernel/ptrace.c
+++ b/arch/openrisc/kernel/ptrace.c
@@ -187,8 +187,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
187 */ 187 */
188 ret = -1L; 188 ret = -1L;
189 189
190 audit_syscall_entry(AUDIT_ARCH_OPENRISC, regs->gpr[11], 190 audit_syscall_entry(regs->gpr[11], regs->gpr[3], regs->gpr[4],
191 regs->gpr[3], regs->gpr[4],
192 regs->gpr[5], regs->gpr[6]); 191 regs->gpr[5], regs->gpr[6]);
193 192
194 return ret ? : regs->gpr[11]; 193 return ret ? : regs->gpr[11];
diff --git a/arch/parisc/include/asm/syscall.h b/arch/parisc/include/asm/syscall.h
index 8bdfd2c8c39f..a5eba95d87fe 100644
--- a/arch/parisc/include/asm/syscall.h
+++ b/arch/parisc/include/asm/syscall.h
@@ -3,6 +3,8 @@
3#ifndef _ASM_PARISC_SYSCALL_H_ 3#ifndef _ASM_PARISC_SYSCALL_H_
4#define _ASM_PARISC_SYSCALL_H_ 4#define _ASM_PARISC_SYSCALL_H_
5 5
6#include <uapi/linux/audit.h>
7#include <linux/compat.h>
6#include <linux/err.h> 8#include <linux/err.h>
7#include <asm/ptrace.h> 9#include <asm/ptrace.h>
8 10
@@ -37,4 +39,13 @@ static inline void syscall_get_arguments(struct task_struct *tsk,
37 } 39 }
38} 40}
39 41
42static 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}
40#endif /*_ASM_PARISC_SYSCALL_H_*/ 51#endif /*_ASM_PARISC_SYSCALL_H_*/
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index 92438c21d453..9585c81f755f 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -280,14 +280,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
280 280
281#ifdef CONFIG_64BIT 281#ifdef CONFIG_64BIT
282 if (!is_compat_task()) 282 if (!is_compat_task())
283 audit_syscall_entry(AUDIT_ARCH_PARISC64, 283 audit_syscall_entry(regs->gr[20], regs->gr[26], regs->gr[25],
284 regs->gr[20], 284 regs->gr[24], regs->gr[23]);
285 regs->gr[26], regs->gr[25],
286 regs->gr[24], regs->gr[23]);
287 else 285 else
288#endif 286#endif
289 audit_syscall_entry(AUDIT_ARCH_PARISC, 287 audit_syscall_entry(regs->gr[20] & 0xffffffff,
290 regs->gr[20] & 0xffffffff,
291 regs->gr[26] & 0xffffffff, 288 regs->gr[26] & 0xffffffff,
292 regs->gr[25] & 0xffffffff, 289 regs->gr[25] & 0xffffffff,
293 regs->gr[24] & 0xffffffff, 290 regs->gr[24] & 0xffffffff,
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index b54b2add07be..6fa2708da153 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -13,7 +13,9 @@
13#ifndef _ASM_SYSCALL_H 13#ifndef _ASM_SYSCALL_H
14#define _ASM_SYSCALL_H 1 14#define _ASM_SYSCALL_H 1
15 15
16#include <uapi/linux/audit.h>
16#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/thread_info.h>
17 19
18/* ftrace syscalls requires exporting the sys_call_table */ 20/* ftrace syscalls requires exporting the sys_call_table */
19#ifdef CONFIG_FTRACE_SYSCALLS 21#ifdef CONFIG_FTRACE_SYSCALLS
@@ -86,4 +88,8 @@ static inline void syscall_set_arguments(struct task_struct *task,
86 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0])); 88 memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
87} 89}
88 90
91static inline int syscall_get_arch(void)
92{
93 return is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64;
94}
89#endif /* _ASM_SYSCALL_H */ 95#endif /* _ASM_SYSCALL_H */
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index cdb404ea3468..f21897b42057 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -1788,14 +1788,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
1788 1788
1789#ifdef CONFIG_PPC64 1789#ifdef CONFIG_PPC64
1790 if (!is_32bit_task()) 1790 if (!is_32bit_task())
1791 audit_syscall_entry(AUDIT_ARCH_PPC64, 1791 audit_syscall_entry(regs->gpr[0], regs->gpr[3], regs->gpr[4],
1792 regs->gpr[0],
1793 regs->gpr[3], regs->gpr[4],
1794 regs->gpr[5], regs->gpr[6]); 1792 regs->gpr[5], regs->gpr[6]);
1795 else 1793 else
1796#endif 1794#endif
1797 audit_syscall_entry(AUDIT_ARCH_PPC, 1795 audit_syscall_entry(regs->gpr[0],
1798 regs->gpr[0],
1799 regs->gpr[3] & 0xffffffff, 1796 regs->gpr[3] & 0xffffffff,
1800 regs->gpr[4] & 0xffffffff, 1797 regs->gpr[4] & 0xffffffff,
1801 regs->gpr[5] & 0xffffffff, 1798 regs->gpr[5] & 0xffffffff,
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index f537e937a988..99a567b70d16 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -834,9 +834,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
834 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 834 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
835 trace_sys_enter(regs, regs->gprs[2]); 835 trace_sys_enter(regs, regs->gprs[2]);
836 836
837 audit_syscall_entry(is_compat_task() ? 837 audit_syscall_entry(regs->gprs[2], regs->orig_gpr2,
838 AUDIT_ARCH_S390 : AUDIT_ARCH_S390X,
839 regs->gprs[2], regs->orig_gpr2,
840 regs->gprs[3], regs->gprs[4], 838 regs->gprs[3], regs->gprs[4],
841 regs->gprs[5]); 839 regs->gprs[5]);
842out: 840out:
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 7d80df4f09cb..95be3b0ce0ac 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_SH_SYSCALL_32_H 1#ifndef __ASM_SH_SYSCALL_32_H
2#define __ASM_SH_SYSCALL_32_H 2#define __ASM_SH_SYSCALL_32_H
3 3
4#include <uapi/linux/audit.h>
4#include <linux/kernel.h> 5#include <linux/kernel.h>
5#include <linux/sched.h> 6#include <linux/sched.h>
6#include <linux/err.h> 7#include <linux/err.h>
@@ -93,4 +94,13 @@ static inline void syscall_set_arguments(struct task_struct *task,
93 } 94 }
94} 95}
95 96
97static inline int syscall_get_arch(void)
98{
99 int arch = AUDIT_ARCH_SH;
100
101#ifdef CONFIG_CPU_LITTLE_ENDIAN
102 arch |= __AUDIT_ARCH_LE;
103#endif
104 return arch;
105}
96#endif /* __ASM_SH_SYSCALL_32_H */ 106#endif /* __ASM_SH_SYSCALL_32_H */
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h
index c3561ca72bee..c6a797b90b80 100644
--- a/arch/sh/include/asm/syscall_64.h
+++ b/arch/sh/include/asm/syscall_64.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_SH_SYSCALL_64_H 1#ifndef __ASM_SH_SYSCALL_64_H
2#define __ASM_SH_SYSCALL_64_H 2#define __ASM_SH_SYSCALL_64_H
3 3
4#include <uapi/linux/audit.h>
4#include <linux/kernel.h> 5#include <linux/kernel.h>
5#include <linux/sched.h> 6#include <linux/sched.h>
6#include <asm/ptrace.h> 7#include <asm/ptrace.h>
@@ -61,4 +62,17 @@ static inline void syscall_set_arguments(struct task_struct *task,
61 memcpy(&regs->regs[2 + i], args, n * sizeof(args[0])); 62 memcpy(&regs->regs[2 + i], args, n * sizeof(args[0]));
62} 63}
63 64
65static inline int syscall_get_arch(void)
66{
67 int arch = AUDIT_ARCH_SH;
68
69#ifdef CONFIG_64BIT
70 arch |= __AUDIT_ARCH_64BIT;
71#endif
72#ifdef CONFIG_CPU_LITTLE_ENDIAN
73 arch |= __AUDIT_ARCH_LE;
74#endif
75
76 return arch;
77}
64#endif /* __ASM_SH_SYSCALL_64_H */ 78#endif /* __ASM_SH_SYSCALL_64_H */
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index 668c81631c08..c1a6b89bfe70 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -484,17 +484,6 @@ long arch_ptrace(struct task_struct *child, long request,
484 return ret; 484 return ret;
485} 485}
486 486
487static inline int audit_arch(void)
488{
489 int arch = EM_SH;
490
491#ifdef CONFIG_CPU_LITTLE_ENDIAN
492 arch |= __AUDIT_ARCH_LE;
493#endif
494
495 return arch;
496}
497
498asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) 487asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
499{ 488{
500 long ret = 0; 489 long ret = 0;
@@ -513,8 +502,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
513 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 502 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
514 trace_sys_enter(regs, regs->regs[0]); 503 trace_sys_enter(regs, regs->regs[0]);
515 504
516 audit_syscall_entry(audit_arch(), regs->regs[3], 505 audit_syscall_entry(regs->regs[3], regs->regs[4], regs->regs[5],
517 regs->regs[4], regs->regs[5],
518 regs->regs[6], regs->regs[7]); 506 regs->regs[6], regs->regs[7]);
519 507
520 return ret ?: regs->regs[0]; 508 return ret ?: regs->regs[0];
diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c
index af90339dadcd..5cea973a65b2 100644
--- a/arch/sh/kernel/ptrace_64.c
+++ b/arch/sh/kernel/ptrace_64.c
@@ -504,20 +504,6 @@ asmlinkage int sh64_ptrace(long request, long pid,
504 return sys_ptrace(request, pid, addr, data); 504 return sys_ptrace(request, pid, addr, data);
505} 505}
506 506
507static inline int audit_arch(void)
508{
509 int arch = EM_SH;
510
511#ifdef CONFIG_64BIT
512 arch |= __AUDIT_ARCH_64BIT;
513#endif
514#ifdef CONFIG_CPU_LITTLE_ENDIAN
515 arch |= __AUDIT_ARCH_LE;
516#endif
517
518 return arch;
519}
520
521asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs) 507asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs)
522{ 508{
523 long long ret = 0; 509 long long ret = 0;
@@ -536,8 +522,7 @@ asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs)
536 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 522 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
537 trace_sys_enter(regs, regs->regs[9]); 523 trace_sys_enter(regs, regs->regs[9]);
538 524
539 audit_syscall_entry(audit_arch(), regs->regs[1], 525 audit_syscall_entry(regs->regs[1], regs->regs[2], regs->regs[3],
540 regs->regs[2], regs->regs[3],
541 regs->regs[4], regs->regs[5]); 526 regs->regs[4], regs->regs[5]);
542 527
543 return ret ?: regs->regs[9]; 528 return ret ?: regs->regs[9];
diff --git a/arch/sparc/include/asm/syscall.h b/arch/sparc/include/asm/syscall.h
index 025a02ad2e31..49f71fd5b56e 100644
--- a/arch/sparc/include/asm/syscall.h
+++ b/arch/sparc/include/asm/syscall.h
@@ -1,9 +1,11 @@
1#ifndef __ASM_SPARC_SYSCALL_H 1#ifndef __ASM_SPARC_SYSCALL_H
2#define __ASM_SPARC_SYSCALL_H 2#define __ASM_SPARC_SYSCALL_H
3 3
4#include <uapi/linux/audit.h>
4#include <linux/kernel.h> 5#include <linux/kernel.h>
5#include <linux/sched.h> 6#include <linux/sched.h>
6#include <asm/ptrace.h> 7#include <asm/ptrace.h>
8#include <asm/thread_info.h>
7 9
8/* 10/*
9 * The syscall table always contains 32 bit pointers since we know that the 11 * The syscall table always contains 32 bit pointers since we know that the
@@ -124,4 +126,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
124 regs->u_regs[UREG_I0 + i + j] = args[j]; 126 regs->u_regs[UREG_I0 + i + j] = args[j];
125} 127}
126 128
129static inline int syscall_get_arch(void)
130{
131 return is_32bit_task() ? AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC64;
132}
133
127#endif /* __ASM_SPARC_SYSCALL_H */ 134#endif /* __ASM_SPARC_SYSCALL_H */
diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
index 96efa7adc223..025c98446b1e 100644
--- a/arch/sparc/include/asm/thread_info_32.h
+++ b/arch/sparc/include/asm/thread_info_32.h
@@ -130,6 +130,8 @@ register struct thread_info *current_thread_info_reg asm("g6");
130#define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | \ 130#define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | \
131 _TIF_SIGPENDING) 131 _TIF_SIGPENDING)
132 132
133#define is_32bit_task() (1)
134
133#endif /* __KERNEL__ */ 135#endif /* __KERNEL__ */
134 136
135#endif /* _ASM_THREAD_INFO_H */ 137#endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index cc6275c931a5..798f0279a4b5 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -221,6 +221,8 @@ register struct thread_info *current_thread_info_reg asm("g6");
221 _TIF_NEED_RESCHED) 221 _TIF_NEED_RESCHED)
222#define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING) 222#define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
223 223
224#define is_32bit_task() (test_thread_flag(TIF_32BIT))
225
224/* 226/*
225 * Thread-synchronous status. 227 * Thread-synchronous status.
226 * 228 *
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index c13c9f25d83a..9ddc4928a089 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -1076,13 +1076,8 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
1076 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 1076 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
1077 trace_sys_enter(regs, regs->u_regs[UREG_G1]); 1077 trace_sys_enter(regs, regs->u_regs[UREG_G1]);
1078 1078
1079 audit_syscall_entry((test_thread_flag(TIF_32BIT) ? 1079 audit_syscall_entry(regs->u_regs[UREG_G1], regs->u_regs[UREG_I0],
1080 AUDIT_ARCH_SPARC : 1080 regs->u_regs[UREG_I1], regs->u_regs[UREG_I2],
1081 AUDIT_ARCH_SPARC64),
1082 regs->u_regs[UREG_G1],
1083 regs->u_regs[UREG_I0],
1084 regs->u_regs[UREG_I1],
1085 regs->u_regs[UREG_I2],
1086 regs->u_regs[UREG_I3]); 1081 regs->u_regs[UREG_I3]);
1087 1082
1088 return ret; 1083 return ret;
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 694d551c8899..62435ef003d9 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -165,8 +165,7 @@ static void send_sigtrap(struct task_struct *tsk, struct uml_pt_regs *regs,
165 */ 165 */
166void syscall_trace_enter(struct pt_regs *regs) 166void syscall_trace_enter(struct pt_regs *regs)
167{ 167{
168 audit_syscall_entry(HOST_AUDIT_ARCH, 168 audit_syscall_entry(UPT_SYSCALL_NR(&regs->regs),
169 UPT_SYSCALL_NR(&regs->regs),
170 UPT_SYSCALL_ARG1(&regs->regs), 169 UPT_SYSCALL_ARG1(&regs->regs),
171 UPT_SYSCALL_ARG2(&regs->regs), 170 UPT_SYSCALL_ARG2(&regs->regs),
172 UPT_SYSCALL_ARG3(&regs->regs), 171 UPT_SYSCALL_ARG3(&regs->regs),
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 711de084ab57..8ffba18395c8 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -198,12 +198,12 @@ sysexit_from_sys_call:
198 198
199#ifdef CONFIG_AUDITSYSCALL 199#ifdef CONFIG_AUDITSYSCALL
200 .macro auditsys_entry_common 200 .macro auditsys_entry_common
201 movl %esi,%r9d /* 6th arg: 4th syscall arg */ 201 movl %esi,%r8d /* 5th arg: 4th syscall arg */
202 movl %edx,%r8d /* 5th arg: 3rd syscall arg */ 202 movl %ecx,%r9d /*swap with edx*/
203 /* (already in %ecx) 4th arg: 2nd syscall arg */ 203 movl %edx,%ecx /* 4th arg: 3rd syscall arg */
204 movl %ebx,%edx /* 3rd arg: 1st syscall arg */ 204 movl %r9d,%edx /* 3rd arg: 2nd syscall arg */
205 movl %eax,%esi /* 2nd arg: syscall number */ 205 movl %ebx,%esi /* 2nd arg: 1st syscall arg */
206 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */ 206 movl %eax,%edi /* 1st arg: syscall number */
207 call __audit_syscall_entry 207 call __audit_syscall_entry
208 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */ 208 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
209 cmpq $(IA32_NR_syscalls-1),%rax 209 cmpq $(IA32_NR_syscalls-1),%rax
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 4b0e1dfa2226..b553ed89e5f5 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -449,12 +449,11 @@ sysenter_audit:
449 jnz syscall_trace_entry 449 jnz syscall_trace_entry
450 addl $4,%esp 450 addl $4,%esp
451 CFI_ADJUST_CFA_OFFSET -4 451 CFI_ADJUST_CFA_OFFSET -4
452 /* %esi already in 8(%esp) 6th arg: 4th syscall arg */ 452 movl %esi,4(%esp) /* 5th arg: 4th syscall arg */
453 /* %edx already in 4(%esp) 5th arg: 3rd syscall arg */ 453 movl %edx,(%esp) /* 4th arg: 3rd syscall arg */
454 /* %ecx already in 0(%esp) 4th arg: 2nd syscall arg */ 454 /* %ecx already in %ecx 3rd arg: 2nd syscall arg */
455 movl %ebx,%ecx /* 3rd arg: 1st syscall arg */ 455 movl %ebx,%edx /* 2nd arg: 1st syscall arg */
456 movl %eax,%edx /* 2nd arg: syscall number */ 456 /* %eax already in %eax 1st arg: syscall number */
457 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
458 call __audit_syscall_entry 457 call __audit_syscall_entry
459 pushl_cfi %ebx 458 pushl_cfi %ebx
460 movl PT_EAX(%esp),%eax /* reload syscall number */ 459 movl PT_EAX(%esp),%eax /* reload syscall number */
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 29576c244699..749b0e423419 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1445,12 +1445,12 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
1445{ 1445{
1446#ifdef CONFIG_X86_64 1446#ifdef CONFIG_X86_64
1447 if (arch == AUDIT_ARCH_X86_64) { 1447 if (arch == AUDIT_ARCH_X86_64) {
1448 audit_syscall_entry(arch, regs->orig_ax, regs->di, 1448 audit_syscall_entry(regs->orig_ax, regs->di,
1449 regs->si, regs->dx, regs->r10); 1449 regs->si, regs->dx, regs->r10);
1450 } else 1450 } else
1451#endif 1451#endif
1452 { 1452 {
1453 audit_syscall_entry(arch, regs->orig_ax, regs->bx, 1453 audit_syscall_entry(regs->orig_ax, regs->bx,
1454 regs->cx, regs->dx, regs->si); 1454 regs->cx, regs->dx, regs->si);
1455 } 1455 }
1456} 1456}
diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h
index 54f8102ccde5..e59eef20647b 100644
--- a/arch/x86/um/asm/ptrace.h
+++ b/arch/x86/um/asm/ptrace.h
@@ -47,8 +47,6 @@ struct user_desc;
47 47
48#ifdef CONFIG_X86_32 48#ifdef CONFIG_X86_32
49 49
50#define HOST_AUDIT_ARCH AUDIT_ARCH_I386
51
52extern int ptrace_get_thread_area(struct task_struct *child, int idx, 50extern int ptrace_get_thread_area(struct task_struct *child, int idx,
53 struct user_desc __user *user_desc); 51 struct user_desc __user *user_desc);
54 52
@@ -57,8 +55,6 @@ extern int ptrace_set_thread_area(struct task_struct *child, int idx,
57 55
58#else 56#else
59 57
60#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64
61
62#define PT_REGS_R8(r) UPT_R8(&(r)->regs) 58#define PT_REGS_R8(r) UPT_R8(&(r)->regs)
63#define PT_REGS_R9(r) UPT_R9(&(r)->regs) 59#define PT_REGS_R9(r) UPT_R9(&(r)->regs)
64#define PT_REGS_R10(r) UPT_R10(&(r)->regs) 60#define PT_REGS_R10(r) UPT_R10(&(r)->regs)
diff --git a/arch/x86/um/asm/syscall.h b/arch/x86/um/asm/syscall.h
new file mode 100644
index 000000000000..9fe77b7b5a0e
--- /dev/null
+++ b/arch/x86/um/asm/syscall.h
@@ -0,0 +1,15 @@
1#ifndef __UM_ASM_SYSCALL_H
2#define __UM_ASM_SYSCALL_H
3
4#include <uapi/linux/audit.h>
5
6static inline int syscall_get_arch(void)
7{
8#ifdef CONFIG_X86_32
9 return AUDIT_ARCH_I386;
10#else
11 return AUDIT_ARCH_X86_64;
12#endif
13}
14
15#endif /* __UM_ASM_SYSCALL_H */
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
index 562fac664751..4d54b481123b 100644
--- a/arch/xtensa/kernel/ptrace.c
+++ b/arch/xtensa/kernel/ptrace.c
@@ -342,7 +342,7 @@ void do_syscall_trace_enter(struct pt_regs *regs)
342 do_syscall_trace(); 342 do_syscall_trace();
343 343
344#if 0 344#if 0
345 audit_syscall_entry(current, AUDIT_ARCH_XTENSA..); 345 audit_syscall_entry(...);
346#endif 346#endif
347} 347}
348 348