Commit 5c25879d authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] x86_64: read_ldt() clear_user() return value checking

Signed-off-by: default avatarJesper Juhl <juhl-lkml@dif.dk>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 702e1a9b
...@@ -135,6 +135,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount) ...@@ -135,6 +135,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
return 0; return 0;
if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES) if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES)
bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES; bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES;
down(&mm->context.sem); down(&mm->context.sem);
size = mm->context.size*LDT_ENTRY_SIZE; size = mm->context.size*LDT_ENTRY_SIZE;
if (size > bytecount) if (size > bytecount)
...@@ -145,12 +146,17 @@ static int read_ldt(void __user * ptr, unsigned long bytecount) ...@@ -145,12 +146,17 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
err = -EFAULT; err = -EFAULT;
up(&mm->context.sem); up(&mm->context.sem);
if (err < 0) if (err < 0)
return err; goto error_return;
if (size != bytecount) { if (size != bytecount) {
/* zero-fill the rest */ /* zero-fill the rest */
clear_user(ptr+size, bytecount-size); if (clear_user(ptr+size, bytecount-size) != 0) {
err = -EFAULT;
goto error_return;
}
} }
return bytecount; return bytecount;
error_return:
return err;
} }
static int read_default_ldt(void __user * ptr, unsigned long bytecount) static int read_default_ldt(void __user * ptr, unsigned long bytecount)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment