lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 16 Jul 2015 08:40:31 +0200
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Yoshinori Sato <ysato@...rs.sourceforge.jp>
Cc:	Arnd Bergmann <arnd@...db.de>,
	Linux-Arch <linux-arch@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] asm-generic: {get,put}_user ptr argument evaluate only 1 time

Hi Sato-san,

On Thu, Jul 16, 2015 at 7:15 AM, Yoshinori Sato
<ysato@...rs.sourceforge.jp> wrote:
> Current implemantation ptr argument evaluate 2 times.
> It'll be an unexpected result.
>
> Signed-off-by: Yoshinori Sato <ysato@...rs.sourceforge.jp>

Acked-by: Geert Uytterhoeven <geert@...ux-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.

>                 -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@...ux-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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ