Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754199AbbGPNd2 (ORCPT ); Thu, 16 Jul 2015 09:33:28 -0400 Received: from mail2.asahi-net.or.jp ([202.224.39.198]:65379 "EHLO mail2.asahi-net.or.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752346AbbGPNd0 (ORCPT ); Thu, 16 Jul 2015 09:33:26 -0400 Date: Thu, 16 Jul 2015 22:33:23 +0900 Message-ID: <87r3o8ns64.wl-ysato@users.sourceforge.jp> From: Yoshinori Sato To: Geert Uytterhoeven Cc: Arnd Bergmann , Linux-Arch , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] asm-generic: {get,put}_user ptr argument evaluate only 1 time In-Reply-To: References: <1437023722-7432-1-git-send-email-ysato@users.sourceforge.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/24.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2853 Lines: 73 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 > wrote: > > Current implemantation ptr argument evaluate 2 times. > > It'll be an unexpected result. > > > > Signed-off-by: Yoshinori Sato > > Acked-by: Geert Uytterhoeven > > > --- > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/