OSDN Git Service

[PATCH] Fix canonical checking for segment registers in ptrace
authorAndi Kleen <ak@suse.de>
Tue, 28 Jun 2005 13:18:17 +0000 (15:18 +0200)
committerMarcelo Tosatti <marcelo.tosatti@cyclades.com>
Wed, 29 Jun 2005 13:50:00 +0000 (10:50 -0300)
Fix canonical checking for segment registers in ptrace

This avoids a local DOS where a process could oops the kernel by
passing bogus values to ptrace. Some versions of UML did this.

Found by Alexander Nyberg

Signed-off-by: Andi Kleen <ak@suse.de>
arch/x86_64/kernel/ptrace.c

index 812961f..edaf18b 100644 (file)
@@ -114,13 +114,13 @@ static int putreg(struct task_struct *child,
                        child->thread.es = value & 0xffff;
                        return 0;
                case offsetof(struct user_regs_struct,fs_base):
-                       if (!((value >> 48) == 0 || (value >> 48) == 0xffff))
-                               return -EIO; 
+                       if (value >= TASK_SIZE)
+                               return -EIO;
                        child->thread.fs = value;
                        return 0;
                case offsetof(struct user_regs_struct,gs_base):
-                       if (!((value >> 48) == 0 || (value >> 48) == 0xffff))
-                               return -EIO; 
+                       if (value >= TASK_SIZE)
+                               return -EIO;
                        child->thread.gs = value;
                        return 0;
                case offsetof(struct user_regs_struct, eflags):