From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Linux-Arch <linux-arch@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] asm-generic: {get,put}_user ptr argument evaluate only 1 time
Date: Thu, 16 Jul 2015 22:33:23 +0900 [thread overview]
Message-ID: <87r3o8ns64.wl-ysato@users.sourceforge.jp> (raw)
In-Reply-To: <CAMuHMdX05U3b6sqzc+cJFO9fnGfewTrwoOiXm-fA_V4GmjBKHg@mail.gmail.com>
On Thu, 16 Jul 2015 15:40:31 +0900,
Geert Uytterhoeven wrote:
>
> Hi Sato-san,
>
> On Thu, Jul 16, 2015 at 7:15 AM, Yoshinori Sato
> <ysato@users.sourceforge.jp> wrote:
> > Current implemantation ptr argument evaluate 2 times.
> > It'll be an unexpected result.
> >
> > Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> > ---
> > include/asm-generic/uaccess.h | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
> > index 72d8803..1b813fb 100644
> > --- a/include/asm-generic/uaccess.h
> > +++ b/include/asm-generic/uaccess.h
> > @@ -163,9 +163,10 @@ static inline __must_check long __copy_to_user(void __user *to,
> >
> > #define put_user(x, ptr) \
> > ({ \
> > + __typeof__((ptr)) __p = (ptr); \
> > might_fault(); \
> > - access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \
> > - __put_user(x, ptr) : \
> > + access_ok(VERIFY_WRITE, __p, sizeof(*__p)) ? \
> > + __put_user(x, __p) : \
>
> For safety, you may want to change "x" to "(x") while at it.
That's right.
I'll sent v2.
> > -EFAULT; \
> > })
> >
> > @@ -225,9 +226,10 @@ extern int __put_user_bad(void) __attribute__((noreturn));
> >
> > #define get_user(x, ptr) \
> > ({ \
> > + __typeof__((ptr)) __p = (ptr); \
> > might_fault(); \
> > - access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \
> > - __get_user(x, ptr) : \
> > + access_ok(VERIFY_READ, __p, sizeof(*__p)) ? \
> > + __get_user(x, __p) : \
>
> Likewise.
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
--
Yoshinori Sato
<ysato@users.sourceforge.jp>
next prev parent reply other threads:[~2015-07-16 13:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 5:15 [PATCH] asm-generic: {get,put}_user ptr argument evaluate only 1 time Yoshinori Sato
2015-07-16 5:15 ` Yoshinori Sato
2015-07-16 6:40 ` Geert Uytterhoeven
2015-07-16 6:40 ` Geert Uytterhoeven
2015-07-16 13:33 ` Yoshinori Sato [this message]
2015-07-16 14:15 ` Arnd Bergmann
2015-07-17 3:27 ` Yoshinori Sato
2015-07-16 14:16 ` [PATCH v2] " Yoshinori Sato
2015-07-21 6:14 ` [PATCH v3] " Yoshinori Sato
2015-07-21 14:06 ` David Howells
2015-07-21 14:06 ` David Howells
2015-07-22 6:09 ` Yoshinori Sato
2015-07-22 14:52 ` [PATCH v4] " Yoshinori Sato
2015-07-22 22:24 ` David Howells
2015-07-22 22:24 ` David Howells
2015-07-23 17:55 ` [PATCH v5] " Yoshinori Sato
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=87r3o8ns64.wl-ysato@users.sourceforge.jp \
--to=ysato@users.sourceforge.jp \
--cc=arnd@arndb.de \
--cc=geert@linux-m68k.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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