rpms/kernel/devel linux-2.6-ia32-syscall-restart-ptrace64.patch, NONE, 1.1 kernel.spec, 1.483, 1.484

Roland McGrath (roland) fedora-extras-commits at redhat.com
Fri Mar 7 23:10:36 UTC 2008


Author: roland

Update of /cvs/pkgs/rpms/kernel/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31519

Modified Files:
	kernel.spec 
Added Files:
	linux-2.6-ia32-syscall-restart-ptrace64.patch 
Log Message:
x86_64: fix 32-bit process syscall restart via 64-bit ptrace (#436183)

linux-2.6-ia32-syscall-restart-ptrace64.patch:

--- NEW FILE linux-2.6-ia32-syscall-restart-ptrace64.patch ---
>From a5bf891054c4f8b2be0da8fc5fd3c91e1e0bd069 Mon Sep 17 00:00:00 2001
From: Roland McGrath <roland at redhat.com>
Date: Fri, 7 Mar 2008 14:44:09 -0800
Subject: [PATCH] x86_64 ptrace orig_ax on ia32 task

This makes 64-bit ptrace calls setting the 64-bit orig_ax field
for a 32-bit task sign-extend the low 32 bits up to 64.  This
matches what a 64-bit debugger expects when tracing a 32-bit task.

This follows on my "x86_64 ia32 syscall restart fix".
This didn't matter until that was fixed.

The debugger ignores or zeros the high half of every register slot it
sets (including the orig_rax pseudo-register) uniformly.  It expects
that the setting of the low 32 bits always has the same meaning as a
32-bit debugger setting those same 32 bits with native 32-bit
facilities.

This never arose before because the syscall restart check never
matched any -ERESTART* values due to lack of sign extension.  Before
that fix, even 32-bit ptrace setting orig_eax to -1 failed to trigger
the restart check anyway.  So this was never noticed as a regression
of 64-bit debuggers vs 32-bit debuggers on the same 64-bit kernel.

Signed-off-by: Roland McGrath <roland at redhat.com>
---
 arch/x86/kernel/ptrace.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index f8eed1b..92b44e1 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -322,6 +322,20 @@ static int putreg(struct task_struct *child,
 	case offsetof(struct user_regs_struct, flags):
 		return set_flags(child, value);
 
+#ifdef CONFIG_IA32_EMULATION
+	case offsetof(struct user_regs_struct, orig_ax):
+		/*
+		 * For a 32-bit task, setting only the low 32 bits and
+		 * leaving the high bits untouched (all 0) has the same
+		 * effect as setting those bits via 32-bit ptrace would.
+		 * This means sign-extending an orig_eax of -1, which
+		 * here is an orig_rax of (u32)-1.
+		 */
+		if (test_tsk_thread_flag(child, TIF_IA32))
+			value = (long) (s32) value;
+		break;
+#endif
+
 #ifdef CONFIG_X86_64
 	case offsetof(struct user_regs_struct,fs_base):
 		if (value >= TASK_SIZE_OF(child))
-- 
1.5.4.1



Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.483
retrieving revision 1.484
diff -u -r1.483 -r1.484
--- kernel.spec	7 Mar 2008 18:54:31 -0000	1.483
+++ kernel.spec	7 Mar 2008 23:10:01 -0000	1.484
@@ -248,7 +248,7 @@
 
 # no need to build headers again for these arches,
 # they can just use i386 and ppc64 headers
-%ifarch i586 i686 ppc64iseries 
+%ifarch i586 i686 ppc64iseries
 %define with_headers 0
 %endif
 
@@ -581,6 +581,7 @@
 Patch75: linux-2.6-x86-debug-boot.patch
 
 Patch80: linux-2.6-ia32-syscall-restart.patch
+Patch81: linux-2.6-ia32-syscall-restart-ptrace64.patch
 
 Patch123: linux-2.6-ppc-rtc.patch
 Patch140: linux-2.6-ps3-ehci-iso.patch
@@ -1013,6 +1014,7 @@
 ApplyPatch linux-2.6-x86-tune-generic.patch
 
 ApplyPatch linux-2.6-ia32-syscall-restart.patch
+ApplyPatch linux-2.6-ia32-syscall-restart-ptrace64.patch
 
 #
 # PowerPC
@@ -1204,7 +1206,7 @@
   echo "# $Arch" > configs/$i
   cat .config >> configs/$i
 done
-# end of kernel config 
+# end of kernel config
 %endif
 
 # get rid of unwanted files resulting from patch fuzz
@@ -1752,6 +1754,9 @@
 %kernel_variant_files -a /%{image_install_path}/xen*-%{KVERREL} -e /etc/ld.so.conf.d/kernelcap-%{KVERREL}.conf %{with_xen} xen
 
 %changelog
+* Fri Mar  7 2008 Roland McGrath <roland at redhat.com>
+- x86_64: fix 32-bit process syscall restart via 64-bit ptrace (#436183)
+
 * Fri Mar 07 2008 Dave Jones <davej at redhat.com>
 - Enable unused symbols.
 




More information about the fedora-extras-commits mailing list