From: Jesper Juhl Signed-off-by: Jesper Juhl Signed-off-by: Andrew Morton --- 25-akpm/arch/x86_64/kernel/ldt.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff -puN arch/x86_64/kernel/ldt.c~read_ldt-neglects-checking-of-clear_user-return arch/x86_64/kernel/ldt.c --- 25/arch/x86_64/kernel/ldt.c~read_ldt-neglects-checking-of-clear_user-return Wed Sep 1 14:30:42 2004 +++ 25-akpm/arch/x86_64/kernel/ldt.c Wed Sep 1 14:30:42 2004 @@ -135,6 +135,7 @@ static int read_ldt(void __user * ptr, u return 0; if (bytecount > LDT_ENTRY_SIZE*LDT_ENTRIES) bytecount = LDT_ENTRY_SIZE*LDT_ENTRIES; + down(&mm->context.sem); size = mm->context.size*LDT_ENTRY_SIZE; if (size > bytecount) @@ -145,12 +146,17 @@ static int read_ldt(void __user * ptr, u err = -EFAULT; up(&mm->context.sem); if (err < 0) - return err; + goto error_return; if (size != bytecount) { /* 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; +error_return: + return err; } static int read_default_ldt(void __user * ptr, unsigned long bytecount) _