linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* linux-next: build failure after merge of the aio tree
@ 2016-03-15  6:46 Stephen Rothwell
  2016-03-15 14:38 ` Andy Shevchenko
  2016-03-15 16:19 ` Sudip Mukherjee
  0 siblings, 2 replies; 9+ messages in thread
From: Stephen Rothwell @ 2016-03-15  6:46 UTC (permalink / raw)
  To: Benjamin LaHaise
  Cc: linux-next, linux-kernel, Michael Ellerman,
	Benjamin Herrenschmidt, linuxppc-dev, Al Viro, Christoph Hellwig

Hi Benjamin,

After merging the aio tree, today's linux-next build (powerpc
ppc44x_defconfig) failed like this:

fs/built-in.o: In function `aio_thread_op_foo_at':
aio.c:(.text+0x4dab4): undefined reference to `__get_user_bad'
aio.c:(.text+0x4daec): undefined reference to `__get_user_bad'

Caused by commit

  150a0b4905f1 ("aio: add support for async openat()")

despite commit

  d2f7a973e11e ("aio: don't use __get_user() for 64 bit values")

This is due to a bug in the powerpc __get_user_check() macro (the return
value is defined to be "unsigned long" which is only 32 bits on a 32
bit platform).

I applied the patch below which seems to help (Michael, what do you
think?), but given Al's and Christoph's reactions, I am inclined to
remove the aio tree from tomorrow and maybe it can be revisited after
the merge window.

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Tue, 15 Mar 2016 16:36:06 +1100
Subject: [PATCH] powerpc: fix get_user for 64 bit typs on 32 bit platforms

solution borrowed from the x86 uaccess.h

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 arch/powerpc/include/asm/uaccess.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index b7c20f0b8fbe..52262b2f37fc 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -261,10 +261,13 @@ do {								\
 	}							\
 } while (0)
 
+#define __inttype(x) \
+	__typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
+
 #define __get_user_nocheck(x, ptr, size)			\
 ({								\
 	long __gu_err;						\
-	unsigned long __gu_val;					\
+	__inttype(*(ptr)) __gu_val;				\
 	__typeof__(*(ptr)) __user *__gu_addr = (ptr);	\
 	__chk_user_ptr(ptr);					\
 	if (!is_kernel_addr((unsigned long)__gu_addr))		\
@@ -277,7 +280,7 @@ do {								\
 #define __get_user_check(x, ptr, size)					\
 ({									\
 	long __gu_err = -EFAULT;					\
-	unsigned long  __gu_val = 0;					\
+	__inttype(*(ptr)) __gu_val = 0;				\
 	__typeof__(*(ptr)) __user *__gu_addr = (ptr);		\
 	might_fault();							\
 	if (access_ok(VERIFY_READ, __gu_addr, (size)))			\
@@ -289,7 +292,7 @@ do {								\
 #define __get_user_nosleep(x, ptr, size)			\
 ({								\
 	long __gu_err;						\
-	unsigned long __gu_val;					\
+	__inttype(*(ptr)) __gu_val;				\
 	__typeof__(*(ptr)) __user *__gu_addr = (ptr);	\
 	__chk_user_ptr(ptr);					\
 	__get_user_size(__gu_val, __gu_addr, (size), __gu_err);	\
-- 
2.7.0

-- 
Cheers,
Stephen Rothwell

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-15  6:46 linux-next: build failure after merge of the aio tree Stephen Rothwell
@ 2016-03-15 14:38 ` Andy Shevchenko
  2016-03-15 16:42   ` Arnd Bergmann
  2016-03-15 16:19 ` Sudip Mukherjee
  1 sibling, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2016-03-15 14:38 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Benjamin LaHaise, linux-next, linux-kernel@vger.kernel.org,
	Michael Ellerman, Benjamin Herrenschmidt, linuxppc-dev, Al Viro,
	Christoph Hellwig

On Tue, Mar 15, 2016 at 8:46 AM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> Hi Benjamin,
>
> After merging the aio tree, today's linux-next build (powerpc
> ppc44x_defconfig) failed like this:
>
> fs/built-in.o: In function `aio_thread_op_foo_at':
> aio.c:(.text+0x4dab4): undefined reference to `__get_user_bad'
> aio.c:(.text+0x4daec): undefined reference to `__get_user_bad'

avr32 seems affected as well and the below solution is not suitable
(should be much more verbose in asm, I guess).

>
> Caused by commit
>
>   150a0b4905f1 ("aio: add support for async openat()")
>
> despite commit
>
>   d2f7a973e11e ("aio: don't use __get_user() for 64 bit values")
>
> This is due to a bug in the powerpc __get_user_check() macro (the return
> value is defined to be "unsigned long" which is only 32 bits on a 32
> bit platform).
>
> I applied the patch below which seems to help (Michael, what do you
> think?), but given Al's and Christoph's reactions, I am inclined to
> remove the aio tree from tomorrow and maybe it can be revisited after
> the merge window.
>
> From: Stephen Rothwell <sfr@canb.auug.org.au>
> Date: Tue, 15 Mar 2016 16:36:06 +1100
> Subject: [PATCH] powerpc: fix get_user for 64 bit typs on 32 bit platforms
>
> solution borrowed from the x86 uaccess.h
>
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> ---
>  arch/powerpc/include/asm/uaccess.h | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
> index b7c20f0b8fbe..52262b2f37fc 100644
> --- a/arch/powerpc/include/asm/uaccess.h
> +++ b/arch/powerpc/include/asm/uaccess.h
> @@ -261,10 +261,13 @@ do {                                                              \
>         }                                                       \
>  } while (0)
>
> +#define __inttype(x) \
> +       __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
> +
>  #define __get_user_nocheck(x, ptr, size)                       \
>  ({                                                             \
>         long __gu_err;                                          \
> -       unsigned long __gu_val;                                 \
> +       __inttype(*(ptr)) __gu_val;                             \
>         __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
>         __chk_user_ptr(ptr);                                    \
>         if (!is_kernel_addr((unsigned long)__gu_addr))          \
> @@ -277,7 +280,7 @@ do {                                                                \
>  #define __get_user_check(x, ptr, size)                                 \
>  ({                                                                     \
>         long __gu_err = -EFAULT;                                        \
> -       unsigned long  __gu_val = 0;                                    \
> +       __inttype(*(ptr)) __gu_val = 0;                         \
>         __typeof__(*(ptr)) __user *__gu_addr = (ptr);           \
>         might_fault();                                                  \
>         if (access_ok(VERIFY_READ, __gu_addr, (size)))                  \
> @@ -289,7 +292,7 @@ do {                                                                \
>  #define __get_user_nosleep(x, ptr, size)                       \
>  ({                                                             \
>         long __gu_err;                                          \
> -       unsigned long __gu_val;                                 \
> +       __inttype(*(ptr)) __gu_val;                             \
>         __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
>         __chk_user_ptr(ptr);                                    \
>         __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
> --
> 2.7.0
>
> --
> Cheers,
> Stephen Rothwell



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-15  6:46 linux-next: build failure after merge of the aio tree Stephen Rothwell
  2016-03-15 14:38 ` Andy Shevchenko
@ 2016-03-15 16:19 ` Sudip Mukherjee
  2016-03-15 16:22   ` Benjamin LaHaise
  1 sibling, 1 reply; 9+ messages in thread
From: Sudip Mukherjee @ 2016-03-15 16:19 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Benjamin LaHaise, linux-next, linux-kernel, Michael Ellerman,
	Benjamin Herrenschmidt, linuxppc-dev, Al Viro, Christoph Hellwig

On Tue, Mar 15, 2016 at 05:46:34PM +1100, Stephen Rothwell wrote:
> Hi Benjamin,
> 
> After merging the aio tree, today's linux-next build (powerpc
> ppc44x_defconfig) failed like this:
> 
> fs/built-in.o: In function `aio_thread_op_foo_at':
> aio.c:(.text+0x4dab4): undefined reference to `__get_user_bad'
> aio.c:(.text+0x4daec): undefined reference to `__get_user_bad'
> 
> Caused by commit
> 
>   150a0b4905f1 ("aio: add support for async openat()")
> 
> despite commit
> 
>   d2f7a973e11e ("aio: don't use __get_user() for 64 bit values")
> 
> This is due to a bug in the powerpc __get_user_check() macro (the return
> value is defined to be "unsigned long" which is only 32 bits on a 32
> bit platform).

m68k allmodconfig and all defs of m32r fails while building next-20160315.

regards
sudip

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-15 16:19 ` Sudip Mukherjee
@ 2016-03-15 16:22   ` Benjamin LaHaise
  2016-03-15 22:02     ` Arnd Bergmann
  0 siblings, 1 reply; 9+ messages in thread
From: Benjamin LaHaise @ 2016-03-15 16:22 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Stephen Rothwell, linux-next, linux-kernel, Michael Ellerman,
	Benjamin Herrenschmidt, linuxppc-dev, Al Viro, Christoph Hellwig

On Tue, Mar 15, 2016 at 04:19:02PM +0000, Sudip Mukherjee wrote:
> On Tue, Mar 15, 2016 at 05:46:34PM +1100, Stephen Rothwell wrote:
> > Hi Benjamin,
> > 
> > After merging the aio tree, today's linux-next build (powerpc
> > ppc44x_defconfig) failed like this:
> > 
> > fs/built-in.o: In function `aio_thread_op_foo_at':
> > aio.c:(.text+0x4dab4): undefined reference to `__get_user_bad'
> > aio.c:(.text+0x4daec): undefined reference to `__get_user_bad'
> > 
> > Caused by commit
> > 
> >   150a0b4905f1 ("aio: add support for async openat()")
> > 
> > despite commit
> > 
> >   d2f7a973e11e ("aio: don't use __get_user() for 64 bit values")
> > 
> > This is due to a bug in the powerpc __get_user_check() macro (the return
> > value is defined to be "unsigned long" which is only 32 bits on a 32
> > bit platform).
> 
> m68k allmodconfig and all defs of m32r fails while building next-20160315.
> 
> regards
> sudip

I've removed everything from the aio-next.git tree for now.  Will revisit 
after the merge window.

		-ben
-- 
"Thought is the essence of where you are now."

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-15 14:38 ` Andy Shevchenko
@ 2016-03-15 16:42   ` Arnd Bergmann
  0 siblings, 0 replies; 9+ messages in thread
From: Arnd Bergmann @ 2016-03-15 16:42 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Andy Shevchenko, Stephen Rothwell, linux-kernel@vger.kernel.org,
	Benjamin LaHaise, linux-next, Christoph Hellwig, Al Viro

On Tuesday 15 March 2016 16:38:51 Andy Shevchenko wrote:
> On Tue, Mar 15, 2016 at 8:46 AM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> > Hi Benjamin,
> >
> > After merging the aio tree, today's linux-next build (powerpc
> > ppc44x_defconfig) failed like this:
> >
> > fs/built-in.o: In function `aio_thread_op_foo_at':
> > aio.c:(.text+0x4dab4): undefined reference to `__get_user_bad'
> > aio.c:(.text+0x4daec): undefined reference to `__get_user_bad'
> 
> avr32 seems affected as well and the below solution is not suitable
> (should be much more verbose in asm, I guess).
> 

ARM as well, at least for ARMv7-M.

	Arnd

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-15 16:22   ` Benjamin LaHaise
@ 2016-03-15 22:02     ` Arnd Bergmann
  2016-03-16 11:12       ` Andy Shevchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Arnd Bergmann @ 2016-03-15 22:02 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Benjamin LaHaise, Sudip Mukherjee, Stephen Rothwell, linux-kernel,
	linux-next, Al Viro, Christoph Hellwig

On Tuesday 15 March 2016 12:22:28 Benjamin LaHaise wrote:
> On Tue, Mar 15, 2016 at 04:19:02PM +0000, Sudip Mukherjee wrote:
> > On Tue, Mar 15, 2016 at 05:46:34PM +1100, Stephen Rothwell wrote:
> > > Hi Benjamin,
> > > 
> > > After merging the aio tree, today's linux-next build (powerpc
> > > ppc44x_defconfig) failed like this:
> > > 
> > > fs/built-in.o: In function `aio_thread_op_foo_at':
> > > aio.c:(.text+0x4dab4): undefined reference to `__get_user_bad'
> > > aio.c:(.text+0x4daec): undefined reference to `__get_user_bad'
> > > 
> > > Caused by commit
> > > 
> > >   150a0b4905f1 ("aio: add support for async openat()")
> > > 
> > > despite commit
> > > 
> > >   d2f7a973e11e ("aio: don't use __get_user() for 64 bit values")
> > > 
> > > This is due to a bug in the powerpc __get_user_check() macro (the return
> > > value is defined to be "unsigned long" which is only 32 bits on a 32
> > > bit platform).
> > 
> > m68k allmodconfig and all defs of m32r fails while building next-20160315.
> > 
> > regards
> > sudip
> 
> I've removed everything from the aio-next.git tree for now.  Will revisit 
> after the merge window.
> 

I've also sent a patch that fixes the link error on ARM and that should
work on all other architectures too.

	Arnd

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-15 22:02     ` Arnd Bergmann
@ 2016-03-16 11:12       ` Andy Shevchenko
  2016-03-16 13:59         ` Arnd Bergmann
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2016-03-16 11:12 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linuxppc-dev, Benjamin LaHaise, Sudip Mukherjee, Stephen Rothwell,
	linux-kernel@vger.kernel.org, linux-next, Al Viro,
	Christoph Hellwig

On Wed, Mar 16, 2016 at 12:02 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Tuesday 15 March 2016 12:22:28 Benjamin LaHaise wrote:
>> On Tue, Mar 15, 2016 at 04:19:02PM +0000, Sudip Mukherjee wrote:
>> > On Tue, Mar 15, 2016 at 05:46:34PM +1100, Stephen Rothwell wrote:
>> > > Hi Benjamin,
>> > >
>> > > After merging the aio tree, today's linux-next build (powerpc
>> > > ppc44x_defconfig) failed like this:
>> > >
>> > > fs/built-in.o: In function `aio_thread_op_foo_at':
>> > > aio.c:(.text+0x4dab4): undefined reference to `__get_user_bad'
>> > > aio.c:(.text+0x4daec): undefined reference to `__get_user_bad'
>> > >
>> > > Caused by commit
>> > >
>> > >   150a0b4905f1 ("aio: add support for async openat()")
>> > >
>> > > despite commit
>> > >
>> > >   d2f7a973e11e ("aio: don't use __get_user() for 64 bit values")
>> > >

>> I've removed everything from the aio-next.git tree for now.  Will revisit
>> after the merge window.

I think it is the best solution right now.

> I've also sent a patch that fixes the link error on ARM and that should
> work on all other architectures too.

In case of avr32 signalfd_read() fails. Does your patch help with it as well?

P.S. Bisecting shows same culprit: 150a0b4905f1 ("aio: add support for
async openat()")

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-16 11:12       ` Andy Shevchenko
@ 2016-03-16 13:59         ` Arnd Bergmann
  2016-03-16 14:07           ` Benjamin LaHaise
  0 siblings, 1 reply; 9+ messages in thread
From: Arnd Bergmann @ 2016-03-16 13:59 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Andy Shevchenko, Stephen Rothwell, linux-kernel@vger.kernel.org,
	Benjamin LaHaise, linux-next, Christoph Hellwig, Al Viro,
	Sudip Mukherjee

On Wednesday 16 March 2016 13:12:36 Andy Shevchenko wrote:
> 
> > I've also sent a patch that fixes the link error on ARM and that should
> > work on all other architectures too.
> 
> In case of avr32 signalfd_read() fails. Does your patch help with it as well?
> 
> P.S. Bisecting shows same culprit: 150a0b4905f1 ("aio: add support for
> async openat()")

I don't know. What is the symptom on avr32? My patch only removes the
get_user() instances on 64-bit values and replaces them with a
single copy_from_user() call.

	Arnd

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: linux-next: build failure after merge of the aio tree
  2016-03-16 13:59         ` Arnd Bergmann
@ 2016-03-16 14:07           ` Benjamin LaHaise
  0 siblings, 0 replies; 9+ messages in thread
From: Benjamin LaHaise @ 2016-03-16 14:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linuxppc-dev, Andy Shevchenko, Stephen Rothwell,
	linux-kernel@vger.kernel.org, linux-next, Christoph Hellwig,
	Al Viro, Sudip Mukherjee

On Wed, Mar 16, 2016 at 02:59:38PM +0100, Arnd Bergmann wrote:
> On Wednesday 16 March 2016 13:12:36 Andy Shevchenko wrote:
> > 
> > > I've also sent a patch that fixes the link error on ARM and that should
> > > work on all other architectures too.
> > 
> > In case of avr32 signalfd_read() fails. Does your patch help with it as well?
> > 
> > P.S. Bisecting shows same culprit: 150a0b4905f1 ("aio: add support for
> > async openat()")
> 
> I don't know. What is the symptom on avr32? My patch only removes the
> get_user() instances on 64-bit values and replaces them with a
> single copy_from_user() call.

Which is the wrong fix.  Arch code should be able to handle 64 bit values 
in all the get/put_user() variants.  We use 64 bit variables all over the 
place in interfaces to userspace.

		-ben

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-03-16 14:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-15  6:46 linux-next: build failure after merge of the aio tree Stephen Rothwell
2016-03-15 14:38 ` Andy Shevchenko
2016-03-15 16:42   ` Arnd Bergmann
2016-03-15 16:19 ` Sudip Mukherjee
2016-03-15 16:22   ` Benjamin LaHaise
2016-03-15 22:02     ` Arnd Bergmann
2016-03-16 11:12       ` Andy Shevchenko
2016-03-16 13:59         ` Arnd Bergmann
2016-03-16 14:07           ` Benjamin LaHaise

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).