All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: "kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH] usercopy: Don't test 64-bit get/put_user() on 32-bit powerpc
Date: Tue, 21 Feb 2017 11:13:28 -0800	[thread overview]
Message-ID: <CAGXu5jLTTcyGyY2KtuCX3tCThvGH0mCnFWyLaznyng=nTss6Dw@mail.gmail.com> (raw)
In-Reply-To: <1487410400-28313-1-git-send-email-mpe@ellerman.id.au>

On Sat, Feb 18, 2017 at 1:33 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Add PPC32 to the opt-out list, otherwise it breaks the build.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  lib/test_user_copy.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c
> index 4a79f2c1cd6e..6f335a3d4ae2 100644
> --- a/lib/test_user_copy.c
> +++ b/lib/test_user_copy.c
> @@ -37,6 +37,7 @@
>                             !defined(CONFIG_MICROBLAZE) &&      \
>                             !defined(CONFIG_MN10300) &&         \
>                             !defined(CONFIG_NIOS2) &&           \
> +                           !defined(CONFIG_PPC32) &&           \
>                             !defined(CONFIG_SUPERH))
>  # define TEST_U64
>  #endif

I'm fine to add this, but I'm curious why it fails? ppc uaccess.h has:

#define get_user(x, ptr) \
        __get_user_check((x), (ptr), sizeof(*(ptr)))

#define __get_user_check(x, ptr, size)                                  \
({                                                                      \
...
                __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \

#define __get_user_size(x, ptr, size, retval)                   \
do {                                                            \
...
        case 8: __get_user_asm2(x, ptr, retval);  break;        \

#ifdef __powerpc64__
#define __get_user_asm2(x, addr, err)                   \
        __get_user_asm(x, addr, err, "ld")
#else /* __powerpc64__ */
#define __get_user_asm2(x, addr, err)                   \
        __asm__ __volatile__(                           \
...

It looks like __get_user_asm2() was explicitly designed for handling
64-bit get_user()?

-Kees

-- 
Kees Cook
Pixel Security

WARNING: multiple messages have this Message-ID (diff)
From: Kees Cook <keescook@chromium.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: "kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [kernel-hardening] Re: [PATCH] usercopy: Don't test 64-bit get/put_user() on 32-bit powerpc
Date: Tue, 21 Feb 2017 11:13:28 -0800	[thread overview]
Message-ID: <CAGXu5jLTTcyGyY2KtuCX3tCThvGH0mCnFWyLaznyng=nTss6Dw@mail.gmail.com> (raw)
In-Reply-To: <1487410400-28313-1-git-send-email-mpe@ellerman.id.au>

On Sat, Feb 18, 2017 at 1:33 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> Add PPC32 to the opt-out list, otherwise it breaks the build.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  lib/test_user_copy.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c
> index 4a79f2c1cd6e..6f335a3d4ae2 100644
> --- a/lib/test_user_copy.c
> +++ b/lib/test_user_copy.c
> @@ -37,6 +37,7 @@
>                             !defined(CONFIG_MICROBLAZE) &&      \
>                             !defined(CONFIG_MN10300) &&         \
>                             !defined(CONFIG_NIOS2) &&           \
> +                           !defined(CONFIG_PPC32) &&           \
>                             !defined(CONFIG_SUPERH))
>  # define TEST_U64
>  #endif

I'm fine to add this, but I'm curious why it fails? ppc uaccess.h has:

#define get_user(x, ptr) \
        __get_user_check((x), (ptr), sizeof(*(ptr)))

#define __get_user_check(x, ptr, size)                                  \
({                                                                      \
...
                __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \

#define __get_user_size(x, ptr, size, retval)                   \
do {                                                            \
...
        case 8: __get_user_asm2(x, ptr, retval);  break;        \

#ifdef __powerpc64__
#define __get_user_asm2(x, addr, err)                   \
        __get_user_asm(x, addr, err, "ld")
#else /* __powerpc64__ */
#define __get_user_asm2(x, addr, err)                   \
        __asm__ __volatile__(                           \
...

It looks like __get_user_asm2() was explicitly designed for handling
64-bit get_user()?

-Kees

-- 
Kees Cook
Pixel Security

  reply	other threads:[~2017-02-21 19:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-18  9:33 [PATCH] usercopy: Don't test 64-bit get/put_user() on 32-bit powerpc Michael Ellerman
2017-02-18  9:33 ` [kernel-hardening] " Michael Ellerman
2017-02-21 19:13 ` Kees Cook [this message]
2017-02-21 19:13   ` [kernel-hardening] " Kees Cook
2017-02-22  2:44   ` Michael Ellerman
2017-02-22  2:44     ` [kernel-hardening] " Michael Ellerman

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='CAGXu5jLTTcyGyY2KtuCX3tCThvGH0mCnFWyLaznyng=nTss6Dw@mail.gmail.com' \
    --to=keescook@chromium.org \
    --cc=geert@linux-m68k.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.