Skip to contentSkip to conversation

IA-32 emulation patch: ptrace get_FPREGS bug fix

PATCH Applied Pallipadi, Venkatesh 3 participants 3 messages May 31, 2003 – Jun 3, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IA-32 emulation patch: ptrace get_FPREGS bug fix

A bug-fix in IA-32 emulation ptrace code. The bug originally got introduced with the addition of FPXREGS support in ptrace.

The bug is in ptrace get/set FPREGS routine. gdb by default will not use FPREGS routines when FPXREGS routines are supported. So we may not see this bug during normal gdb operations. But, if gdb (or any other app) directly tries to get/set FPREGS (probably an old version of gdb), it will end with an segmentation fault due to this bug.

Attached patch fixes the issue. The patch is taken against 2.5.69. But it applies to 2.4 tree as well.

Please let me know, if you need any more information on this.

Thanks,
-Venkatesh

arch/ia64/ia32/sys_ia32.c +2 -2
diff -urN linux-2.5.69/arch/ia64/ia32/sys_ia32.c linux-2.5.69-fix/arch/ia64/ia32/sys_ia32.c
@@ -1860,7 +1860,7 @@
 	ptp = ia64_task_regs(tsk);
 	tos = (tsk->thread.fsr >> 11) & 7;
 	for (i = 0; i < 8; i++)
-		put_fpreg(i, (struct _fpreg_ia32 *)&save->st_space[4*i], ptp, swp, tos);
+		put_fpreg(i, &save->st_space[i], ptp, swp, tos);
 	return 0;
 }
 
@@ -1893,7 +1893,7 @@
 	ptp = ia64_task_regs(tsk);
 	tos = (tsk->thread.fsr >> 11) & 7;
 	for (i = 0; i < 8; i++)
-		get_fpreg(i, (struct _fpreg_ia32 *)&save->st_space[4*i], ptp, swp, tos);
+		get_fpreg(i, &save->st_space[i], ptp, swp, tos);
 	return 0;
 }
 
include/asm-ia64/ia32.h +2 -1
diff -urN linux-2.5.69/include/asm-ia64/ia32.h linux-2.5.69-fix/include/asm-ia64/ia32.h
@@ -108,7 +108,8 @@
 	int	fcs;
 	int	foo;
 	int	fos;
-	int	st_space[20];	/* 8*10 bytes for each FP-reg = 80 bytes */
+	/* 8*10 bytes for each FP-reg = 80 bytes */
+	struct _fpreg_ia32 	st_space[8];
 };
 
 struct ia32_user_fxsr_struct {
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Venkatesh

Venkatesh> A bug-fix in IA-32 emulation ptrace code. The bug Venkatesh> originally got introduced with the addition of FPXREGS Venkatesh> support in ptrace.

Applied, thanks.

	--david
#2 lore raw
In reply to Pallipadi, Venkatesh
Quoted 2 lines · Venkatesh

A bug-fix in IA-32 emulation ptrace code. The bug originally got introduced with the addition of FPXREGS support in ptrace.

I applied this for 2.4. Thanks!