public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Daniel Axtens <dja@axtens•net>
To: linuxppc-dev@lists•ozlabs.org
Cc: Daniel Axtens <dja@axtens•net>
Subject: [PATCH 1/3] powerpc/sparse: constify the address pointer in __get_user_check
Date: Mon, 30 Jan 2017 17:41:53 +1100	[thread overview]
Message-ID: <20170130064155.30281-2-dja@axtens.net> (raw)
In-Reply-To: <20170130064155.30281-1-dja@axtens.net>

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(-)

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);	\
-- 
2.9.3

  reply	other threads:[~2017-01-30  6:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-30  6:41 [PATCH 0/3] powerpc/sparse: constify addresses in get_user macros Daniel Axtens
2017-01-30  6:41 ` Daniel Axtens [this message]
2017-02-02 11:45   ` [1/3] powerpc/sparse: constify the address pointer in __get_user_check Michael Ellerman
2017-01-30  6:41 ` [PATCH 2/3] powerpc/sparse: constify the address pointer in __get_user_nocheck Daniel Axtens
2017-01-30  6:41 ` [PATCH 3/3] powerpc/sparse: constify the address pointer in __get_user_nosleep Daniel Axtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170130064155.30281-2-dja@axtens.net \
    --to=dja@axtens$(echo .)net \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox