Re: [git pull] uaccess fixes

From: Al Viro
Date: Wed Sep 14 2016 - 21:35:38 EST


On Wed, Sep 14, 2016 at 04:47:47PM +0100, Al Viro wrote:
> Fixes for broken uaccess primitives - mostly lack of proper zeroing
> in copy_from_user()/get_user()/__get_user(), but for several architectures
> there's more (broken clear_user() on frv and strncpy_from_user() on hexagon).
> All of that is rc2-based stable fodder; usercopy stuff that went into mainline
> since then has added 3 conflicts - in parisc, ppc and itanic uaccess.h.
> Conflicts are trivial; I've pushed my variant of conflict resolution into
> #proposed-merge.

And a bit that has sat in a different branch since mid-August:

[x86] fix minor infoleak in get_user_ex()

get_user_ex(x, ptr) should zero x on failure. It's not a lot of a leak
(at most we are leaking uninitialized 64bit value off the kernel stack,
and in a fairly constrained situation, at that), but the fix is trivial,
so...

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index a0ae610..7821921 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -433,7 +433,11 @@ do { \
#define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
asm volatile("1: mov"itype" %1,%"rtype"0\n" \
"2:\n" \
- _ASM_EXTABLE_EX(1b, 2b) \
+ ".section .fixup,\"ax\"\n" \
+ "3:xor"itype" %"rtype"0,%"rtype"0\n" \
+ " jmp 2b\n" \
+ ".previous\n" \
+ _ASM_EXTABLE_EX(1b, 3b) \
: ltype(x) : "m" (__m(addr)))

#define __put_user_nocheck(x, ptr, size) \