From: KAMEZAWA Hiroyuki Date: Wed, 24 Aug 2011 23:46:12 +0000 (+1000) Subject: Because of x86-implement-strict-user-copy-checks-for-x86_64.patch X-Git-Tag: next-20110905~1^2~148 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=415f943d03a17e0b943584443fdf1a77b173e626;p=karo-tx-linux.git Because of x86-implement-strict-user-copy-checks-for-x86_64.patch When compiling mm/mempolicy.c the following warning is shown. In file included from arch/x86/include/asm/uaccess.h:572, from include/linux/uaccess.h:5, from include/linux/highmem.h:7, from include/linux/pagemap.h:10, from include/linux/mempolicy.h:70, from mm/mempolicy.c:68: In function `copy_from_user', inlined from `compat_sys_get_mempolicy' at mm/mempolicy.c:1415: arch/x86/include/asm/uaccess_64.h:64: warning: call to `copy_from_user_overflow' declared with attribute warning: copy_from_user() buffer size is not provably correct LD mm/built-in.o Fix this by passing correct buffer size value. Signed-off-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton --- diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 8b57173c1dd5..905f2027b2a1 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1412,7 +1412,9 @@ asmlinkage long compat_sys_get_mempolicy(int __user *policy, err = sys_get_mempolicy(policy, nm, nr_bits+1, addr, flags); if (!err && nmask) { - err = copy_from_user(bm, nm, alloc_size); + unsigned long copy_size; + copy_size = min_t(unsigned long, sizeof(bm), alloc_size); + err = copy_from_user(bm, nm, copy_size); /* ensure entire bitmap is zeroed */ err |= clear_user(nmask, ALIGN(maxnode-1, 8) / 8); err |= compat_put_bitmap(nmask, bm, nr_bits);