Skip to content

Commit c5f638a

Browse files
amlutoIngo Molnar
authored andcommitted
x86/entry/64/compat: Remove audit optimizations
These audit optimizations are messy and hard to maintain. We'll get a similar effect from opportunistic sysret when fast compat system calls are re-implemented. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/0bcca79ac7ff835d0e5a38725298865b01347a82.1444091584.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent e62a254 commit c5f638a

File tree

1 file changed

+2
-96
lines changed

1 file changed

+2
-96
lines changed

arch/x86/entry/entry_64_compat.S

Lines changed: 2 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616
#include <linux/linkage.h>
1717
#include <linux/err.h>
1818

19-
/* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
20-
#include <linux/elf-em.h>
21-
#define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE)
22-
#define __AUDIT_ARCH_LE 0x40000000
23-
24-
#ifndef CONFIG_AUDITSYSCALL
25-
# define sysexit_audit ia32_ret_from_sys_call_irqs_off
26-
# define sysretl_audit ia32_ret_from_sys_call_irqs_off
27-
#endif
28-
2919
.section .entry.text, "ax"
3020

3121
#ifdef CONFIG_PARAVIRT
@@ -148,7 +138,7 @@ sysenter_dispatch:
148138
DISABLE_INTERRUPTS(CLBR_NONE)
149139
TRACE_IRQS_OFF
150140
testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
151-
jnz sysexit_audit
141+
jnz ia32_ret_from_sys_call_irqs_off
152142
sysexit_from_sys_call:
153143
/*
154144
* NB: SYSEXIT is not obviously safe for 64-bit kernels -- an
@@ -200,81 +190,12 @@ sysexit_from_sys_call:
200190
*/
201191
USERGS_SYSRET32
202192

203-
#ifdef CONFIG_AUDITSYSCALL
204-
.macro auditsys_entry_common
205-
/*
206-
* At this point, registers hold syscall args in the 32-bit syscall ABI:
207-
* EAX is syscall number, the 6 args are in EBX,ECX,EDX,ESI,EDI,EBP.
208-
*
209-
* We want to pass them to __audit_syscall_entry(), which is a 64-bit
210-
* C function with 5 parameters, so shuffle them to match what
211-
* the function expects: RDI,RSI,RDX,RCX,R8.
212-
*/
213-
movl %esi, %r8d /* arg5 (R8 ) <= 4th syscall arg (ESI) */
214-
xchg %ecx, %edx /* arg4 (RCX) <= 3rd syscall arg (EDX) */
215-
/* arg3 (RDX) <= 2nd syscall arg (ECX) */
216-
movl %ebx, %esi /* arg2 (RSI) <= 1st syscall arg (EBX) */
217-
movl %eax, %edi /* arg1 (RDI) <= syscall number (EAX) */
218-
call __audit_syscall_entry
219-
220-
/*
221-
* We are going to jump back to the syscall dispatch code.
222-
* Prepare syscall args as required by the 64-bit C ABI.
223-
* Registers clobbered by __audit_syscall_entry() are
224-
* loaded from pt_regs on stack:
225-
*/
226-
movl ORIG_RAX(%rsp), %eax /* syscall number */
227-
movl %ebx, %edi /* arg1 */
228-
movl RCX(%rsp), %esi /* arg2 */
229-
movl RDX(%rsp), %edx /* arg3 */
230-
movl RSI(%rsp), %ecx /* arg4 */
231-
movl RDI(%rsp), %r8d /* arg5 */
232-
.endm
233-
234-
.macro auditsys_exit exit
235-
TRACE_IRQS_ON
236-
ENABLE_INTERRUPTS(CLBR_NONE)
237-
testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
238-
jnz ia32_ret_from_sys_call
239-
movl %eax, %esi /* second arg, syscall return value */
240-
cmpl $-MAX_ERRNO, %eax /* is it an error ? */
241-
jbe 1f
242-
movslq %eax, %rsi /* if error sign extend to 64 bits */
243-
1: setbe %al /* 1 if error, 0 if not */
244-
movzbl %al, %edi /* zero-extend that into %edi */
245-
call __audit_syscall_exit
246-
movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), %edi
247-
DISABLE_INTERRUPTS(CLBR_NONE)
248-
TRACE_IRQS_OFF
249-
testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
250-
jz \exit
251-
xorl %eax, %eax /* Do not leak kernel information */
252-
movq %rax, R11(%rsp)
253-
movq %rax, R10(%rsp)
254-
movq %rax, R9(%rsp)
255-
movq %rax, R8(%rsp)
256-
jmp int_ret_from_sys_call_irqs_off
257-
.endm
258-
259-
sysenter_auditsys:
260-
auditsys_entry_common
261-
movl %ebp, %r9d /* reload 6th syscall arg */
262-
jmp sysenter_dispatch
263-
264-
sysexit_audit:
265-
auditsys_exit sysexit_from_sys_call
266-
#endif
267-
268193
sysenter_fix_flags:
269194
pushq $X86_EFLAGS_FIXED
270195
popfq
271196
jmp sysenter_flags_fixed
272197

273198
sysenter_tracesys:
274-
#ifdef CONFIG_AUDITSYSCALL
275-
testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
276-
jz sysenter_auditsys
277-
#endif
278199
SAVE_EXTRA_REGS
279200
xorl %eax, %eax /* Do not leak kernel information */
280201
movq %rax, R11(%rsp)
@@ -389,7 +310,7 @@ cstar_dispatch:
389310
DISABLE_INTERRUPTS(CLBR_NONE)
390311
TRACE_IRQS_OFF
391312
testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
392-
jnz sysretl_audit
313+
jnz ia32_ret_from_sys_call_irqs_off
393314

394315
sysretl_from_sys_call:
395316
andl $~TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
@@ -420,22 +341,7 @@ sysretl_from_sys_call:
420341
*/
421342
USERGS_SYSRET32
422343

423-
#ifdef CONFIG_AUDITSYSCALL
424-
cstar_auditsys:
425-
movl %r9d, R9(%rsp) /* register to be clobbered by call */
426-
auditsys_entry_common
427-
movl R9(%rsp), %r9d /* reload 6th syscall arg */
428-
jmp cstar_dispatch
429-
430-
sysretl_audit:
431-
auditsys_exit sysretl_from_sys_call
432-
#endif
433-
434344
cstar_tracesys:
435-
#ifdef CONFIG_AUDITSYSCALL
436-
testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
437-
jz cstar_auditsys
438-
#endif
439345
xchgl %r9d, %ebp
440346
SAVE_EXTRA_REGS
441347
xorl %eax, %eax /* Do not leak kernel information */

0 commit comments

Comments
 (0)