aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2014-03-11 13:29:28 -0400
committerEric Paris <eparis@redhat.com>2014-09-23 16:21:26 -0400
commit91397401bb5072f71e8ce8744ad0bdec3e875a91 (patch)
treea302a36a358ec001812ac495606fa6ced52a672e /arch
parentce5d112827e5c2e9864323d0efd7ec2a62c6dce0 (diff)
ARCH: AUDIT: audit_syscall_entry() should not require the arch
We have a function where the arch can be queried, syscall_get_arch(). So rather than have every single piece of arch specific code use and/or duplicate syscall_get_arch(), just have the audit code use the syscall_get_arch() code. Based-on-patch-by: Richard Briggs <rgb@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com> Cc: linux-alpha@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org 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: linux-s390@vger.kernel.org Cc: linux-sh@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: user-mode-linux-devel@lists.sourceforge.net Cc: linux-xtensa@linux-xtensa.org Cc: x86@kernel.org
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/ptrace.c2
-rw-r--r--arch/arm/kernel/ptrace.c4
-rw-r--r--arch/ia64/kernel/ptrace.c2
-rw-r--r--arch/microblaze/kernel/ptrace.c3
-rw-r--r--arch/mips/kernel/ptrace.c4
-rw-r--r--arch/openrisc/kernel/ptrace.c3
-rw-r--r--arch/parisc/kernel/ptrace.c9
-rw-r--r--arch/powerpc/kernel/ptrace.c7
-rw-r--r--arch/s390/kernel/ptrace.c4
-rw-r--r--arch/sh/kernel/ptrace_32.c14
-rw-r--r--arch/sh/kernel/ptrace_64.c17
-rw-r--r--arch/sparc/kernel/ptrace_64.c9
-rw-r--r--arch/um/kernel/ptrace.c3
-rw-r--r--arch/x86/kernel/ptrace.c8
-rw-r--r--arch/x86/um/asm/ptrace.h4
-rw-r--r--arch/xtensa/kernel/ptrace.c2
16 files changed, 21 insertions, 74 deletions
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 0c27ed6f3f23..6af95986fbf7 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -944,8 +944,8 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
944 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) 944 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
945 trace_sys_enter(regs, scno); 945 trace_sys_enter(regs, scno);
946 946
947 audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1, 947 audit_syscall_entry(scno, regs->ARM_r0, regs->ARM_r1, regs->ARM_r2,
948 regs->ARM_r2, regs->ARM_r3); 948 regs->ARM_r3);
949 949
950 return scno; 950 return scno;
951} 951}
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/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/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index f639ccd5060c..d8a76f97a053 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -649,9 +649,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
649 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 649 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
650 trace_sys_enter(regs, regs->regs[2]); 650 trace_sys_enter(regs, regs->regs[2]);
651 651
652 audit_syscall_entry(syscall_get_arch(), 652 audit_syscall_entry(syscall, regs->regs[4], regs->regs[5],
653 syscall,
654 regs->regs[4], regs->regs[5],
655 regs->regs[6], regs->regs[7]); 653 regs->regs[6], regs->regs[7]);
656 return syscall; 654 return syscall;
657} 655}
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/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index e842ee233db4..74814577e4b8 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -276,14 +276,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
276 276
277#ifdef CONFIG_64BIT 277#ifdef CONFIG_64BIT
278 if (!is_compat_task()) 278 if (!is_compat_task())
279 audit_syscall_entry(AUDIT_ARCH_PARISC64, 279 audit_syscall_entry(regs->gr[20], regs->gr[26], regs->gr[25],
280 regs->gr[20], 280 regs->gr[24], regs->gr[23]);
281 regs->gr[26], regs->gr[25],
282 regs->gr[24], regs->gr[23]);
283 else 281 else
284#endif 282#endif
285 audit_syscall_entry(AUDIT_ARCH_PARISC, 283 audit_syscall_entry(regs->gr[20] & 0xffffffff,
286 regs->gr[20] & 0xffffffff,
287 regs->gr[26] & 0xffffffff, 284 regs->gr[26] & 0xffffffff,
288 regs->gr[25] & 0xffffffff, 285 regs->gr[25] & 0xffffffff,
289 regs->gr[24] & 0xffffffff, 286 regs->gr[24] & 0xffffffff,
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 2e3d2bf536c5..524a943a33bb 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 5dc7ad9e2fbf..910f253b22bc 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -828,9 +828,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
828 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 828 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
829 trace_sys_enter(regs, regs->gprs[2]); 829 trace_sys_enter(regs, regs->gprs[2]);
830 830
831 audit_syscall_entry(is_compat_task() ? 831 audit_syscall_entry(regs->gprs[2], regs->orig_gpr2,
832 AUDIT_ARCH_S390 : AUDIT_ARCH_S390X,
833 regs->gprs[2], regs->orig_gpr2,
834 regs->gprs[3], regs->gprs[4], 832 regs->gprs[3], regs->gprs[4],
835 regs->gprs[5]); 833 regs->gprs[5]);
836out: 834out:
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/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/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 678c0ada3b3c..eb1c87f0b03b 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1488,15 +1488,11 @@ long syscall_trace_enter(struct pt_regs *regs)
1488 trace_sys_enter(regs, regs->orig_ax); 1488 trace_sys_enter(regs, regs->orig_ax);
1489 1489
1490 if (IS_IA32) 1490 if (IS_IA32)
1491 audit_syscall_entry(AUDIT_ARCH_I386, 1491 audit_syscall_entry(regs->orig_ax, regs->bx, regs->cx,
1492 regs->orig_ax,
1493 regs->bx, regs->cx,
1494 regs->dx, regs->si); 1492 regs->dx, regs->si);
1495#ifdef CONFIG_X86_64 1493#ifdef CONFIG_X86_64
1496 else 1494 else
1497 audit_syscall_entry(AUDIT_ARCH_X86_64, 1495 audit_syscall_entry(regs->orig_ax, regs->di, regs->si,
1498 regs->orig_ax,
1499 regs->di, regs->si,
1500 regs->dx, regs->r10); 1496 regs->dx, regs->r10);
1501#endif 1497#endif
1502 1498
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/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