public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@linux-m68k.org>
To: linux-m68k@vger.kernel.org
Cc: hch@lst.de, geert@linux-m68k.org,
	Greg Ungerer <gerg@linux-m68k.org>,
	kernel test robot <lkp@intel.com>
Subject: [PATCH] m68knommu: add missing __user annotations
Date: Tue,  8 Sep 2020 23:26:47 +1000	[thread overview]
Message-ID: <20200908132647.923201-1-gerg@linux-m68k.org> (raw)

Some of the m68knommu user access functions are not using the __user
annotation where required. Specifically __clear_user(), strnlen_user()
and strncpy_from_user() need their user space source address annoted
with __user.

Picked up by the kernel test robot, when running sparse:

  sparse warnings: (new ones prefixed by >>)

     drivers/char/mem.c:163:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void *to @@     got char [noderef] __user *buf @@
     drivers/char/mem.c:163:37: sparse:     expected void *to
     drivers/char/mem.c:163:37: sparse:     got char [noderef] __user *buf
  >> drivers/char/mem.c:737:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void *to @@     got char [noderef] __user * @@
     drivers/char/mem.c:737:21: sparse:     expected void *to
  >> drivers/char/mem.c:737:21: sparse:     got char [noderef] __user *

Add in __user where appropriate.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
---
 arch/m68k/include/asm/uaccess_no.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/m68k/include/asm/uaccess_no.h b/arch/m68k/include/asm/uaccess_no.h
index dcfb69361408..764b01a3bd07 100644
--- a/arch/m68k/include/asm/uaccess_no.h
+++ b/arch/m68k/include/asm/uaccess_no.h
@@ -125,7 +125,7 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
  */
 
 static inline long
-strncpy_from_user(char *dst, const char *src, long count)
+strncpy_from_user(char *dst, const char __user *src, long count)
 {
 	char *tmp;
 	strncpy(dst, src, count);
@@ -139,7 +139,7 @@ strncpy_from_user(char *dst, const char *src, long count)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-static inline long strnlen_user(const char *src, long n)
+static inline long strnlen_user(const char __user *src, long n)
 {
 	return(strlen(src) + 1); /* DAVIDM make safer */
 }
@@ -149,7 +149,7 @@ static inline long strnlen_user(const char *src, long n)
  */
 
 static inline unsigned long
-__clear_user(void *to, unsigned long n)
+__clear_user(void __user *to, unsigned long n)
 {
 	memset(to, 0, n);
 	return 0;
-- 
2.25.1


             reply	other threads:[~2020-09-08 17:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 13:26 Greg Ungerer [this message]
2020-09-08 13:30 ` [PATCH] m68knommu: add missing __user annotations Christoph Hellwig
2020-09-08 23:26   ` Greg Ungerer

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=20200908132647.923201-1-gerg@linux-m68k.org \
    --to=gerg@linux-m68k.org \
    --cc=geert@linux-m68k.org \
    --cc=hch@lst.de \
    --cc=linux-m68k@vger.kernel.org \
    --cc=lkp@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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