Linux-m68k Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess()
@ 2020-05-29 19:02 Luc Van Oostenryck
  2020-05-29 19:02 ` [PATCH v2 1/2] m68k,nommu: add missing __user in uaccess' __ptr() macro Luc Van Oostenryck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-05-29 19:02 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer
  Cc: linux-m68k, linux-kernel, Luc Van Oostenryck

I received a bug report for an unrelated patch when used with m68k-nommu.
It appears that the origin of the problem is that __get_user() and
__put_user() doesn't handle correctly __user. These 2 patches fix this.

Note: this is only minimaly tested but is quite straightforward and
      since this only change __user annotation it will not change the
      generated code.


Changes since v1:
* fix typo: s/plan/plain/
* appease checkpatch with better style: s/__force*/__force */
* avoid excessive line length caused by the added cast.

Luc Van Oostenryck (2):
  m68k,nommu: add missing __user in uaccess' __ptr() macro
  m68k,nommu: fix implicit cast from __user in __{get,put}_user_asm()

 arch/m68k/include/asm/uaccess_no.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] m68k,nommu: add missing __user in uaccess' __ptr() macro
  2020-05-29 19:02 [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess() Luc Van Oostenryck
@ 2020-05-29 19:02 ` Luc Van Oostenryck
  2020-05-29 19:02 ` [PATCH v2 2/2] m68k,nommu: fix implicit cast from __user in __{get,put}_user_asm() Luc Van Oostenryck
  2020-05-30  0:59 ` [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess() Greg Ungerer
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-05-29 19:02 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer
  Cc: linux-m68k, linux-kernel, Luc Van Oostenryck, kbuild test robot

The assembly for __get_user() & __put_user() uses a macro, __ptr(),
to cast the pointer to 'unsigned long *' but the pointer is always
a __user one and so this cast creates a lot of warnings when using
Sparse.

So, change to the cast to 'unsigned long __user *'.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 arch/m68k/include/asm/uaccess_no.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/uaccess_no.h b/arch/m68k/include/asm/uaccess_no.h
index a24cfe4a0d32..9651766a62af 100644
--- a/arch/m68k/include/asm/uaccess_no.h
+++ b/arch/m68k/include/asm/uaccess_no.h
@@ -60,7 +60,7 @@ extern int __put_user_bad(void);
  * aliasing issues.
  */
 
-#define __ptr(x) ((unsigned long *)(x))
+#define __ptr(x) ((unsigned long __user *)(x))
 
 #define __put_user_asm(err,x,ptr,bwl)				\
 	__asm__ ("move" #bwl " %0,%1"				\
-- 
2.26.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] m68k,nommu: fix implicit cast from __user in __{get,put}_user_asm()
  2020-05-29 19:02 [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess() Luc Van Oostenryck
  2020-05-29 19:02 ` [PATCH v2 1/2] m68k,nommu: add missing __user in uaccess' __ptr() macro Luc Van Oostenryck
@ 2020-05-29 19:02 ` Luc Van Oostenryck
  2020-05-30  0:59 ` [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess() Greg Ungerer
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-05-29 19:02 UTC (permalink / raw)
  To: Geert Uytterhoeven, Greg Ungerer
  Cc: linux-m68k, linux-kernel, Luc Van Oostenryck, kbuild test robot

The assembly for __get_user_asm() & __put_user_asm() uses memcpy()
when the size is 8.

However, the pointer is always a __user one while memcpy() expects
a plain one and so this cast creates a lot of warnings when using
Sparse.

So, fix this by adding a cast to 'void __force *' at memcpy()'s
argument.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 arch/m68k/include/asm/uaccess_no.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/include/asm/uaccess_no.h b/arch/m68k/include/asm/uaccess_no.h
index 9651766a62af..9959327e99b0 100644
--- a/arch/m68k/include/asm/uaccess_no.h
+++ b/arch/m68k/include/asm/uaccess_no.h
@@ -42,7 +42,7 @@ static inline int _access_ok(unsigned long addr, unsigned long size)
 	__put_user_asm(__pu_err, __pu_val, ptr, l);	\
 	break;						\
     case 8:						\
-	memcpy(ptr, &__pu_val, sizeof (*(ptr))); \
+	memcpy((void __force *)ptr, &__pu_val, sizeof(*(ptr))); \
 	break;						\
     default:						\
 	__pu_err = __put_user_bad();			\
@@ -85,7 +85,7 @@ extern int __put_user_bad(void);
 	    u64 l;						\
 	    __typeof__(*(ptr)) t;				\
 	} __gu_val;						\
-	memcpy(&__gu_val.l, ptr, sizeof(__gu_val.l));		\
+	memcpy(&__gu_val.l, (const void __force *)ptr, sizeof (__gu_val.l)); \
 	(x) = __gu_val.t;					\
 	break;							\
     }								\
-- 
2.26.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess()
  2020-05-29 19:02 [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess() Luc Van Oostenryck
  2020-05-29 19:02 ` [PATCH v2 1/2] m68k,nommu: add missing __user in uaccess' __ptr() macro Luc Van Oostenryck
  2020-05-29 19:02 ` [PATCH v2 2/2] m68k,nommu: fix implicit cast from __user in __{get,put}_user_asm() Luc Van Oostenryck
@ 2020-05-30  0:59 ` Greg Ungerer
  2 siblings, 0 replies; 4+ messages in thread
From: Greg Ungerer @ 2020-05-30  0:59 UTC (permalink / raw)
  To: Luc Van Oostenryck, Geert Uytterhoeven; +Cc: linux-m68k, linux-kernel

Hi Luc,

On 30/5/20 5:02 am, Luc Van Oostenryck wrote:
> I received a bug report for an unrelated patch when used with m68k-nommu.
> It appears that the origin of the problem is that __get_user() and
> __put_user() doesn't handle correctly __user. These 2 patches fix this.
> 
> Note: this is only minimaly tested but is quite straightforward and
>        since this only change __user annotation it will not change the
>        generated code.
> 
> 
> Changes since v1:
> * fix typo: s/plan/plain/
> * appease checkpatch with better style: s/__force*/__force */
> * avoid excessive line length caused by the added cast.
> 
> Luc Van Oostenryck (2):
>    m68k,nommu: add missing __user in uaccess' __ptr() macro
>    m68k,nommu: fix implicit cast from __user in __{get,put}_user_asm()
> 
>   arch/m68k/include/asm/uaccess_no.h | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)

Looks good, thanks for the fixup.
Applied to the m68knommu git tree, for-next branch.

Regards
Greg

  

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-29 19:02 [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess() Luc Van Oostenryck
2020-05-29 19:02 ` [PATCH v2 1/2] m68k,nommu: add missing __user in uaccess' __ptr() macro Luc Van Oostenryck
2020-05-29 19:02 ` [PATCH v2 2/2] m68k,nommu: fix implicit cast from __user in __{get,put}_user_asm() Luc Van Oostenryck
2020-05-30  0:59 ` [PATCH v2 0/2] fix missing handling of __user in nommu's uaccess() Greg Ungerer

Linux-m68k Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-m68k/0 linux-m68k/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-m68k linux-m68k/ https://lore.kernel.org/linux-m68k \
		linux-m68k@vger.kernel.org linux-m68k@lists.linux-m68k.org
	public-inbox-index linux-m68k

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-m68k


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git