[-mm patch] ptrace: make {put,get}reg work again for gs and fs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 14, 2006 at 10:59:13PM -0800, Andrew Morton wrote:
> 	http://userweb.kernel.org/~akpm/2.6.20-rc1-mm1/
> 
Hi all,

Following the i386 pda patches, it's not possible to set gs or fs value
from gdb anymore. The following patch restores the old behaviour of
getting and setting thread.gs of thread.fs respectively.
Here's a gdb session *before* the patch:
(gdb) info reg
[...]
fs             0x33     51
gs             0x33     51
(gdb) set $fs=0xffff
(gdb) info reg
[...]
fs             0x33     51
gs             0x33     51
(gdb) set $gs=0xffffffff
(gdb) info reg
[...]
fs             0xffff   65535
gs             0x33     51

Another one *after* the patch:
(gdb) info reg
[...]
fs             0xd8     216
gs             0x33     51
(gdb) set $fs=0xffff
(gdb) info reg
[...]
fs             0xffff   65535
gs             0x33     51
(gdb) set $gs=0xffff
(gdb) info reg
[...]
fs             0xffff   65535
gs             0xffff   65535

Andrew, this goes on top of ptrace-fix-efl_offset-value-according-to-i386-pda-changes.patch
sent by Jeremy yesterday.

Regards,
Frederik

Signed-off-by: Frederik Deweerdt <[email protected]>

diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index a803a49..7af494e 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -94,9 +94,13 @@ static int putreg(struct task_struct *child,
 				return -EIO;
 			child->thread.fs = value;
 			return 0;
+		case GS:
+			if (value && (value & 3) != 3)
+				return -EIO;
+			child->thread.gs = value;
+			return 0;
 		case DS:
 		case ES:
-		case GS:
 			if (value && (value & 3) != 3)
 				return -EIO;
 			value &= 0xffff;
@@ -124,12 +128,14 @@ static unsigned long getreg(struct task_struct *child,
 	unsigned long retval = ~0UL;
 
 	switch (regno >> 2) {
+		case FS:
+			retval = child->thread.fs;
+			break;
 		case GS:
 			retval = child->thread.gs;
 			break;
 		case DS:
 		case ES:
-		case FS:
 		case SS:
 		case CS:
 			retval = 0xffff;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux