LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [RFC] breakage in 4223cc34365e4 (h8300: uaccess.h update)
Date: Mon, 10 Mar 2008 16:57:14 -0400	[thread overview]
Message-ID: <87fxuyz49h.wl%ysato@users.sourceforge.jp> (raw)
In-Reply-To: <20080302232314.GW27894@ZenIV.linux.org.uk>

At Sun, 2 Mar 2008 23:23:14 +0000,
Al Viro wrote:
> 
> 	After that commit in asm-h8300/uaccess.h we have 
> 
> #define get_user(x, ptr)                                        \
> ({                                                              \
>     int __gu_err = 0;                                           \
>     uint32_t __gu_val = 0;                              \
>     ^^^^^^^^^^^^^^^^^
>     switch (sizeof(*(ptr))) {                                   \
>     case 1:                                                     \
>     case 2:                                                     \
>     case 4:                                                     \
>         __gu_val = *(ptr);                                      \
>         break;                                                  \
>     case 8:                                                     \
>         memcpy(&__gu_val, ptr, sizeof (*(ptr)));                \
>                                ^^^^^^^^^^^^^^^^
> 
> which, of course, is FUBAR whenever we actually hit that case - memcpy of
> 8 bytes into uint32_t is obviously wrong.  Why don't we simply do

Oops.

> 
> #define get_user(x, ptr)                                        \
> ({                                                              \
>     int __gu_err = 0;                                           \
>     typeof(*(ptr)) __gu_val = *ptr;                             \
>     switch (sizeof(*(ptr))) {                                   \
>     case 1:                                                     \
>     case 2:                                                     \
>     case 4:                                                     \
>     case 8:                                                     \
>         break;                                                  \
>     default:                                                    \
>         __gu_err = __get_user_bad();                            \
>         break;                                                  \
>     }                                                           \
>     (x) = __gu_val;                                             \
>     __gu_err;                                                   \
> })
> 
> and be done with that, anyway?

Good! no problem.
Thank you.

Signed-off-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

 include/asm-h8300/uaccess.h |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/asm-h8300/uaccess.h b/include/asm-h8300/uaccess.h
index a22350e..356068c 100644
--- a/include/asm-h8300/uaccess.h
+++ b/include/asm-h8300/uaccess.h
@@ -91,22 +91,19 @@ extern int __put_user_bad(void);
 #define get_user(x, ptr)					\
 ({								\
     int __gu_err = 0;						\
-    uint32_t __gu_val = 0;				\
+    typeof(*(ptr)) __gu_val = *ptr;				\
     switch (sizeof(*(ptr))) {					\
     case 1:							\
     case 2:							\
     case 4:							\
-	__gu_val = *(ptr);	                		\
-	break;							\
-    case 8:							\
-	memcpy(&__gu_val, ptr, sizeof (*(ptr))); 		\
+    case 8: 							\
 	break;							\
     default:							\
-	__gu_val = 0;						\
 	__gu_err = __get_user_bad();				\
+	__gu_val = 0;						\
 	break;							\
     }								\
-    (x) = (typeof(*(ptr)))__gu_val;				\
+    (x) = __gu_val;						\
     __gu_err;							\
 })
 #define __get_user(x, ptr) get_user(x, ptr)
-- 
1.5.4.3

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>

      reply	other threads:[~2008-03-10 20:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-02 23:23 Al Viro
2008-03-10 20:57 ` Yoshinori Sato [this message]

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=87fxuyz49h.wl%ysato@users.sourceforge.jp \
    --to=ysato@users.sourceforge.jp \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    --subject='Re: [RFC] breakage in 4223cc34365e4 (h8300: uaccess.h update)' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).