@@ -64,20 +64,13 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
6464}
6565
6666/*
67- * We can return 0 to resume the syscall or anything else to go to phase
68- * 2. If we resume the syscall, we need to put something appropriate in
69- * regs->orig_ax.
70- *
71- * NB: We don't have full pt_regs here, but regs->orig_ax and regs->ax
72- * are fully functional.
73- *
74- * For phase 2's benefit, our return value is:
75- * 0: resume the syscall
76- * 1: go to phase 2; no seccomp phase 2 needed
77- * anything else: go to phase 2; pass return value to seccomp
67+ * Returns the syscall nr to run (which should match regs->orig_ax) or -1
68+ * to skip the syscall.
7869 */
79- unsigned long syscall_trace_enter_phase1 (struct pt_regs * regs , u32 arch )
70+ static long syscall_trace_enter (struct pt_regs * regs )
8071{
72+ u32 arch = in_ia32_syscall () ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64 ;
73+
8174 struct thread_info * ti = pt_regs_to_thread_info (regs );
8275 unsigned long ret = 0 ;
8376 u32 work ;
@@ -118,59 +111,9 @@ unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch)
118111 sd .args [5 ] = regs -> bp ;
119112 }
120113
121- BUILD_BUG_ON (SECCOMP_PHASE1_OK != 0 );
122- BUILD_BUG_ON (SECCOMP_PHASE1_SKIP != 1 );
123-
124- ret = seccomp_phase1 (& sd );
125- if (ret == SECCOMP_PHASE1_SKIP ) {
126- regs -> orig_ax = -1 ;
127- ret = 0 ;
128- } else if (ret != SECCOMP_PHASE1_OK ) {
129- return ret ; /* Go directly to phase 2 */
130- }
131-
132- work &= ~_TIF_SECCOMP ;
133- }
134- #endif
135-
136- /* Do our best to finish without phase 2. */
137- if (work == 0 )
138- return ret ; /* seccomp and/or nohz only (ret == 0 here) */
139-
140- #ifdef CONFIG_AUDITSYSCALL
141- if (work == _TIF_SYSCALL_AUDIT ) {
142- /*
143- * If there is no more work to be done except auditing,
144- * then audit in phase 1. Phase 2 always audits, so, if
145- * we audit here, then we can't go on to phase 2.
146- */
147- do_audit_syscall_entry (regs , arch );
148- return 0 ;
149- }
150- #endif
151-
152- return 1 ; /* Something is enabled that we can't handle in phase 1 */
153- }
154-
155- /* Returns the syscall nr to run (which should match regs->orig_ax). */
156- long syscall_trace_enter_phase2 (struct pt_regs * regs , u32 arch ,
157- unsigned long phase1_result )
158- {
159- struct thread_info * ti = pt_regs_to_thread_info (regs );
160- long ret = 0 ;
161- u32 work = ACCESS_ONCE (ti -> flags ) & _TIF_WORK_SYSCALL_ENTRY ;
162-
163- if (IS_ENABLED (CONFIG_DEBUG_ENTRY ))
164- BUG_ON (regs != task_pt_regs (current ));
165-
166- #ifdef CONFIG_SECCOMP
167- /*
168- * Call seccomp_phase2 before running the other hooks so that
169- * they can see any changes made by a seccomp tracer.
170- */
171- if (phase1_result > 1 && seccomp_phase2 (phase1_result )) {
172- /* seccomp failures shouldn't expose any additional code. */
173- return -1 ;
114+ ret = __secure_computing (& sd );
115+ if (ret == -1 )
116+ return ret ;
174117 }
175118#endif
176119
@@ -189,17 +132,6 @@ long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch,
189132 return ret ?: regs -> orig_ax ;
190133}
191134
192- long syscall_trace_enter (struct pt_regs * regs )
193- {
194- u32 arch = in_ia32_syscall () ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64 ;
195- unsigned long phase1_result = syscall_trace_enter_phase1 (regs , arch );
196-
197- if (phase1_result == 0 )
198- return regs -> orig_ax ;
199- else
200- return syscall_trace_enter_phase2 (regs , arch , phase1_result );
201- }
202-
203135#define EXIT_TO_USERMODE_LOOP_FLAGS \
204136 (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
205137 _TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY)
0 commit comments