rpms/kernel/F-8 linux-2.6.25-utrace-i386-syscall-trace.patch, NONE, 1.1 kernel.spec, 1.465, 1.466

Chuck Ebbert (cebbert) fedora-extras-commits at redhat.com
Thu Jun 12 20:34:47 UTC 2008


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv13805

Modified Files:
	kernel.spec 
Added Files:
	linux-2.6.25-utrace-i386-syscall-trace.patch 
Log Message:
* Thu Jun 12 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.6-26
- Fix UML breakage (#450501)


linux-2.6.25-utrace-i386-syscall-trace.patch:

--- NEW FILE linux-2.6.25-utrace-i386-syscall-trace.patch ---
--- linux-2.6.25.noarch/arch/x86/kernel/entry_32.S.syscall
+++ linux-2.6.25.noarch/arch/x86/kernel/entry_32.S
@@ -515,11 +515,7 @@ END(work_pending)
 syscall_trace_entry:
 	movl $-ENOSYS,PT_EAX(%esp)
 	movl %esp, %eax
-	xorl %edx,%edx
-	call do_syscall_trace
-	cmpl $0, %eax
-	jne resume_userspace		# ret != 0 -> running under PTRACE_SYSEMU,
-					# so must skip actual syscall
+	call syscall_trace_enter
 	movl PT_ORIG_EAX(%esp), %eax
 	cmpl $(nr_syscalls), %eax
 	jnae syscall_call
@@ -532,11 +528,10 @@ syscall_exit_work:
 	testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
 	jz work_pending
 	TRACE_IRQS_ON
-	ENABLE_INTERRUPTS(CLBR_ANY)	# could let do_syscall_trace() call
+	ENABLE_INTERRUPTS(CLBR_ANY)	# could let syscall_trace_leave() call
 					# schedule() instead
 	movl %esp, %eax
-	movl $1, %edx
-	call do_syscall_trace
+	call syscall_trace_leave
 	jmp resume_userspace
 END(syscall_exit_work)
 	CFI_ENDPROC
--- linux-2.6.25.noarch/arch/x86/kernel/ptrace.c.syscall
+++ linux-2.6.25.noarch/arch/x86/kernel/ptrace.c
@@ -1359,8 +1359,6 @@ const struct user_regset_view *task_user
 #endif
 }
 
-#ifdef CONFIG_X86_32
-
 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
 {
 	struct siginfo info;
@@ -1379,112 +1377,59 @@ void send_sigtrap(struct task_struct *ts
 	force_sig_info(SIGTRAP, &info, tsk);
 }
 
-/* notification of system call entry/exit
- * - triggered by current->work.syscall_trace
- */
-__attribute__((regparm(3)))
-int do_syscall_trace(struct pt_regs *regs, int entryexit)
-{
-	int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU);
-	/*
-	 * With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall
-	 * interception
-	 */
-	int is_singlestep = !is_sysemu && test_thread_flag(TIF_SINGLESTEP);
-	int ret = 0;
-
-	/* do the secure computing check first */
-	if (!entryexit)
-		secure_computing(regs->orig_ax);
-
-	if (unlikely(current->audit_context)) {
-		if (entryexit)
-			audit_syscall_exit(AUDITSC_RESULT(regs->ax),
-						regs->ax);
-		/* Debug traps, when using PTRACE_SINGLESTEP, must be sent only
-		 * on the syscall exit path. Normally, when TIF_SYSCALL_AUDIT is
-		 * not used, entry.S will call us only on syscall exit, not
-		 * entry; so when TIF_SYSCALL_AUDIT is used we must avoid
-		 * calling send_sigtrap() on syscall entry.
-		 *
-		 * Note that when PTRACE_SYSEMU_SINGLESTEP is used,
-		 * is_singlestep is false, despite his name, so we will still do
-		 * the correct thing.
-		 */
-		else if (is_singlestep)
-			goto out;
-	}
-
-	if (!tracehook_consider_fatal_signal(current, SIGTRAP, SIG_DFL))
-		goto out;
-
-	/* If a process stops on the 1st tracepoint with SYSCALL_TRACE
-	 * and then is resumed with SYSEMU_SINGLESTEP, it will come in
-	 * here. We have to check this and return */
-	if (is_sysemu && entryexit)
-		return 0;
-
-	/* Fake a debug trap */
-	if (is_singlestep)
-		send_sigtrap(current, regs, 0);
-
- 	if (!test_thread_flag(TIF_SYSCALL_TRACE) && !is_sysemu)
-		goto out;
-
-	if (!entryexit)
-		tracehook_report_syscall_entry(regs);
-	else
-		tracehook_report_syscall_exit(regs, 0);
-
-	ret = is_sysemu;
-out:
-	if (unlikely(current->audit_context) && !entryexit)
-		audit_syscall_entry(AUDIT_ARCH_I386, regs->orig_ax,
-				    regs->bx, regs->cx, regs->dx, regs->si);
-	if (ret == 0)
-		return 0;
-
-	regs->orig_ax = -1; /* force skip of syscall restarting */
-	if (unlikely(current->audit_context))
-		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
-	return 1;
-}
-
-#else  /* CONFIG_X86_64 */
+#ifdef CONFIG_X86_32
+# define IS_IA32	1
+#elif defined CONFIG_IA32_EMULATION
+# define IS_IA32	test_thread_flag(TIF_IA32)
+#else
+# define IS_IA32	0
+#endif
 
-asmlinkage void syscall_trace_enter(struct pt_regs *regs)
+asmregparm void syscall_trace_enter(struct pt_regs *regs)
 {
 	/* do the secure computing check first */
 	secure_computing(regs->orig_ax);
 
-	if (test_thread_flag(TIF_SYSCALL_TRACE))
+	if (test_thread_flag(TIF_SYSCALL_TRACE) ||
+	    unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
 		tracehook_report_syscall_entry(regs);
 
 	if (unlikely(current->audit_context)) {
-		if (test_thread_flag(TIF_IA32)) {
+		if (IS_IA32)
 			audit_syscall_entry(AUDIT_ARCH_I386,
 					    regs->orig_ax,
 					    regs->bx, regs->cx,
 					    regs->dx, regs->si);
-		} else {
+#ifdef CONFIG_X86_64
+		else
 			audit_syscall_entry(AUDIT_ARCH_X86_64,
 					    regs->orig_ax,
 					    regs->di, regs->si,
 					    regs->dx, regs->r10);
-		}
+#endif
 	}
+
+	if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
+		/*
+		 * Setting an invalid syscall number skips making the call
+		 * and leaves the registers as they are now (-ENOSYS in
+		 * regs->ax, or as just modified by ptrace).  This also
+		 * ensures that signal handling won't restart the call.
+		 * TIF_SYSCALL_AUDIT will still cause us to get into
+		 * syscall_trace_leave() after not making the call.
+		 */
+		regs->orig_ax = -1L;
 }
 
-asmlinkage void syscall_trace_leave(struct pt_regs *regs)
+asmregparm void syscall_trace_leave(struct pt_regs *regs)
 {
-	int step;
-
 	if (unlikely(current->audit_context))
 		audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
-	step = test_thread_flag(TIF_SINGLESTEP);
-	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
-		tracehook_report_syscall_exit(regs, step);
-}
+	if (test_thread_flag(TIF_SYSCALL_TRACE))
+		tracehook_report_syscall_exit(regs, 0);
 
-#endif	/* CONFIG_X86_32 */
+	if (test_thread_flag(TIF_SINGLESTEP) &&
+	    tracehook_consider_fatal_signal(current, SIGTRAP, SIG_DFL))
+		send_sigtrap(current, regs, 0);
+}
--- linux-2.6.25.noarch/include/asm-x86/ptrace-abi.h.syscall
+++ linux-2.6.25.noarch/include/asm-x86/ptrace-abi.h
@@ -73,11 +73,11 @@
 
 #ifdef __x86_64__
 # define PTRACE_ARCH_PRCTL	  30
-#else
-# define PTRACE_SYSEMU		  31
-# define PTRACE_SYSEMU_SINGLESTEP 32
 #endif
 
+#define PTRACE_SYSEMU		  31
+#define PTRACE_SYSEMU_SINGLESTEP  32
+
 #define PTRACE_SINGLEBLOCK	33	/* resume execution until next branch */
 
 #ifndef __ASSEMBLY__
--- linux-2.6.25.noarch/include/asm-x86/thread_info_64.h.syscall
+++ linux-2.6.25.noarch/include/asm-x86/thread_info_64.h
@@ -108,6 +108,7 @@ static inline struct thread_info *stack_
 #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 #define TIF_SINGLESTEP		4	/* reenable singlestep on user return*/
 #define TIF_IRET		5	/* force IRET */
+#define TIF_SYSCALL_EMU		6	/* syscall emulation active */
 #define TIF_SYSCALL_AUDIT	7	/* syscall auditing active */
 #define TIF_SECCOMP		8	/* secure computing */
 #define TIF_RESTORE_SIGMASK	9	/* restore signal mask in do_signal */
@@ -131,6 +132,7 @@ static inline struct thread_info *stack_
 #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 #define _TIF_IRET		(1<<TIF_IRET)
+#define _TIF_SYSCALL_EMU	(1<<TIF_SYSCALL_EMU)
 #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
--- linux-2.6.25.noarch/kernel/ptrace.c.syscall
+++ linux-2.6.25.noarch/kernel/ptrace.c
@@ -1675,25 +1675,36 @@ int ptrace_writedata(struct task_struct 
 	return copied;
 }
 
-#ifdef PTRACE_SINGLESTEP
-#define is_singlestep(request)		((request) == PTRACE_SINGLESTEP)
-#else
-#define is_singlestep(request)		0
+static inline int is_sysemu(long req)
+{
+#ifdef PTRACE_SYSEMU
+	if (req == PTRACE_SYSEMU || req == PTRACE_SYSEMU_SINGLESTEP)
+		return 1;
 #endif
+	return 0;
+}
 
-#ifdef PTRACE_SINGLEBLOCK
-#define is_singleblock(request)		((request) == PTRACE_SINGLEBLOCK)
-#else
-#define is_singleblock(request)		0
+static inline int is_singlestep(long req)
+{
+#ifdef PTRACE_SYSEMU_SINGLESTEP
+	if (req == PTRACE_SYSEMU_SINGLESTEP)
+		return 1;
 #endif
+#ifdef PTRACE_SINGLESTEP
+	if (req == PTRACE_SINGLESTEP)
+		return 1;
+#endif
+	return 0;
+}
 
-#ifdef PTRACE_SYSEMU
-#define is_sysemu(request)		((request) == PTRACE_SYSEMU)
-#define is_sysemu_singlestep(request)	((request) == PTRACE_SYSEMU_SINGLESTEP)
-#else
-#define is_sysemu(request)		0
-#define is_sysemu_singlestep(request)	0
+static inline int is_singleblock(long req)
+{
+#ifdef PTRACE_SINGLEBLOCK
+	if (req == PTRACE_SINGLEBLOCK)
+		return 1;
 #endif
+	return 0;
+}
 
 static int
 ptrace_common(long request, struct task_struct *child,


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-8/kernel.spec,v
retrieving revision 1.465
retrieving revision 1.466
diff -u -r1.465 -r1.466
--- kernel.spec	10 Jun 2008 20:45:42 -0000	1.465
+++ kernel.spec	12 Jun 2008 20:33:49 -0000	1.466
@@ -566,6 +566,7 @@
 
 Patch21: linux-2.6-utrace.patch
 Patch22: linux-2.6.25-utrace-bugon.patch
+Patch23: linux-2.6.25-utrace-i386-syscall-trace.patch
 
 Patch41: linux-2.6-sysrq-c.patch
 Patch60: linux-2.6-x86-tune-generic.patch
@@ -974,6 +975,7 @@
 # Roland's utrace ptrace replacement.
 ApplyPatch linux-2.6-utrace.patch
 ApplyPatch linux-2.6.25-utrace-bugon.patch
+ApplyPatch linux-2.6.25-utrace-i386-syscall-trace.patch
 
 # ALSA Thinkpad X300 support
 ApplyPatch linux-2.6-alsa-hda-codec-add-AD1884A.patch
@@ -1821,6 +1823,9 @@
 
 
 %changelog
+* Thu Jun 12 2008 Chuck Ebbert <cebbert at redhat.com> 2.6.25.6-26
+- Fix UML breakage (#450501)
+
 * Tue Jun 10 2008 John W. Linville <linville at redhat.com> 2.6.25.6-25
 - Upstream wireless fixes from 2008-06-09
   (http://marc.info/?l=linux-kernel&m=121304710726632&w=2)




More information about the fedora-extras-commits mailing list