[PATCH] x86_64: Fix canonical checking for segment registers in ptrace

Allowed user programs to set a non canonical segment base, which would cause
oopses in the kernel later.

Credit-to: Alexander Nyberg <alexn@dsv.su.se>

 For identifying and reporting this bug.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Andi Kleen 2005-05-16 21:53:30 -07:00 committed by Linus Torvalds
parent d1099e8a18
commit f6b8d4778c

View File

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