Message ID | 20170130064155.30281-2-dja@axtens.net (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Mon, 2017-01-30 at 06:41:53 UTC, Daniel Axtens wrote: > In __get_user_check, we create an intermediate pointer for the > user address we're about to fetch. We currently don't tag this > pointer as const. Make it const, as we are simply dereferencing > it, and it's scope is limited to the __get_user_check macro. > > Signed-off-by: Daniel Axtens <dja@axtens.net> Series applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/f84ed59a612d866cde0bd17ad2a52a cheers
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index a15d84d59356..71d81cbe3781 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -274,7 +274,7 @@ do { \ ({ \ long __gu_err = -EFAULT; \ unsigned long __gu_val = 0; \ - __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ might_fault(); \ if (access_ok(VERIFY_READ, __gu_addr, (size))) \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
In __get_user_check, we create an intermediate pointer for the user address we're about to fetch. We currently don't tag this pointer as const. Make it const, as we are simply dereferencing it, and it's scope is limited to the __get_user_check macro. Signed-off-by: Daniel Axtens <dja@axtens.net> --- This fixes warnings outside arch/powerpc where people are passing constified pointers into get_user(), such as: linux/fs/exec.c:423:21: warning: incorrect type in initializer (different modifiers) expected unsigned int [noderef] <asn:1>*__gu_addr got unsigned int const [noderef] [usertype] <asn:1>* linux/kernel/trace/trace.c:1219:15: warning: incorrect type in initializer (different modifiers) expected char [noderef] <asn:1>*__gu_addr got char const [noderef] <asn:1>* A total of 14 warnings in my pseries build are squashed. --- arch/powerpc/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)