* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-16 21:31 ` Al Viro
0 siblings, 0 replies; 36+ messages in thread
From: Al Viro @ 2016-09-16 21:31 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-kernel, Yoshinori Sato, linux-sh, Rich Felker
On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> Yes, reverting 6e050503a150 fixes the problem.
>
> I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
>
> Guenter
>
> > The change in question is
> > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > - return __copy_user(to, from, __copy_size);
> > + __copy_size = __copy_user(to, from, __copy_size);
> > +
> > + if (unlikely(__copy_size))
> > + memset(to + (n - __copy_size), 0, __copy_size);
> >
> > return __copy_size;
So we don't even hit that memset()? What the hell? __copy_user() is
declared as
__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
and __copy_size copy_from_user() is
__kernel_size_t __copy_size = (__kernel_size_t) n;
So
return __copy_user(to, from, __copy_size);
and
__copy_size = __copy_user(to, from, __copy_size);
return __copy_size;
ought to be doing exactly the same thing. At that point it's starting to
smell like a compiler bug somewhere in there.
Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
and see if that's enough to recover. And it would be nice to see what
all three variants (as it is, with commit reverted and with just that if
removed) generate in e.g. sys_utimensat() (fs/utimes.s)
^ permalink raw reply [flat|nested] 36+ messages in thread* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-16 21:31 ` Al Viro
@ 2016-09-16 21:39 ` Rich Felker
-1 siblings, 0 replies; 36+ messages in thread
From: Rich Felker @ 2016-09-16 21:39 UTC (permalink / raw)
To: Al Viro; +Cc: Guenter Roeck, linux-kernel, Yoshinori Sato, linux-sh
On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > Yes, reverting 6e050503a150 fixes the problem.
> >
> > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> >
> > Guenter
> >
> > > The change in question is
> > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > - return __copy_user(to, from, __copy_size);
> > > + __copy_size = __copy_user(to, from, __copy_size);
> > > +
> > > + if (unlikely(__copy_size))
> > > + memset(to + (n - __copy_size), 0, __copy_size);
> > >
> > > return __copy_size;
>
> So we don't even hit that memset()? What the hell? __copy_user() is
> declared as
> __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
>
> and __copy_size copy_from_user() is
>
> __kernel_size_t __copy_size = (__kernel_size_t) n;
>
> So
> return __copy_user(to, from, __copy_size);
> and
> __copy_size = __copy_user(to, from, __copy_size);
> return __copy_size;
> ought to be doing exactly the same thing. At that point it's starting to
> smell like a compiler bug somewhere in there.
>
> Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> and see if that's enough to recover. And it would be nice to see what
> all three variants (as it is, with commit reverted and with just that if
> removed) generate in e.g. sys_utimensat() (fs/utimes.s)
It would be useful to know what compiler version was used to build the
kernel. I wouldn't be surprised if some are buggy.
Rich
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-16 21:39 ` Rich Felker
0 siblings, 0 replies; 36+ messages in thread
From: Rich Felker @ 2016-09-16 21:39 UTC (permalink / raw)
To: Al Viro; +Cc: Guenter Roeck, linux-kernel, Yoshinori Sato, linux-sh
On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > Yes, reverting 6e050503a150 fixes the problem.
> >
> > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> >
> > Guenter
> >
> > > The change in question is
> > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > - return __copy_user(to, from, __copy_size);
> > > + __copy_size = __copy_user(to, from, __copy_size);
> > > +
> > > + if (unlikely(__copy_size))
> > > + memset(to + (n - __copy_size), 0, __copy_size);
> > >
> > > return __copy_size;
>
> So we don't even hit that memset()? What the hell? __copy_user() is
> declared as
> __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
>
> and __copy_size copy_from_user() is
>
> __kernel_size_t __copy_size = (__kernel_size_t) n;
>
> So
> return __copy_user(to, from, __copy_size);
> and
> __copy_size = __copy_user(to, from, __copy_size);
> return __copy_size;
> ought to be doing exactly the same thing. At that point it's starting to
> smell like a compiler bug somewhere in there.
>
> Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> and see if that's enough to recover. And it would be nice to see what
> all three variants (as it is, with commit reverted and with just that if
> removed) generate in e.g. sys_utimensat() (fs/utimes.s)
It would be useful to know what compiler version was used to build the
kernel. I wouldn't be surprised if some are buggy.
Rich
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-16 21:39 ` Rich Felker
@ 2016-09-16 22:47 ` Guenter Roeck
-1 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-16 22:47 UTC (permalink / raw)
To: Rich Felker; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On Fri, Sep 16, 2016 at 05:39:18PM -0400, Rich Felker wrote:
> On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> > On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > > Yes, reverting 6e050503a150 fixes the problem.
> > >
> > > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> > >
> > > Guenter
> > >
> > > > The change in question is
> > > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > > - return __copy_user(to, from, __copy_size);
> > > > + __copy_size = __copy_user(to, from, __copy_size);
> > > > +
> > > > + if (unlikely(__copy_size))
> > > > + memset(to + (n - __copy_size), 0, __copy_size);
> > > >
> > > > return __copy_size;
> >
> > So we don't even hit that memset()? What the hell? __copy_user() is
> > declared as
> > __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
> >
> > and __copy_size copy_from_user() is
> >
> > __kernel_size_t __copy_size = (__kernel_size_t) n;
> >
> > So
> > return __copy_user(to, from, __copy_size);
> > and
> > __copy_size = __copy_user(to, from, __copy_size);
> > return __copy_size;
> > ought to be doing exactly the same thing. At that point it's starting to
> > smell like a compiler bug somewhere in there.
> >
> > Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> > and see if that's enough to recover. And it would be nice to see what
> > all three variants (as it is, with commit reverted and with just that if
> > removed) generate in e.g. sys_utimensat() (fs/utimes.s)
>
> It would be useful to know what compiler version was used to build the
> kernel. I wouldn't be surprised if some are buggy.
>
4.6.3 from kernel.org.
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-16 22:47 ` Guenter Roeck
0 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-16 22:47 UTC (permalink / raw)
To: Rich Felker; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On Fri, Sep 16, 2016 at 05:39:18PM -0400, Rich Felker wrote:
> On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> > On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > > Yes, reverting 6e050503a150 fixes the problem.
> > >
> > > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> > >
> > > Guenter
> > >
> > > > The change in question is
> > > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > > - return __copy_user(to, from, __copy_size);
> > > > + __copy_size = __copy_user(to, from, __copy_size);
> > > > +
> > > > + if (unlikely(__copy_size))
> > > > + memset(to + (n - __copy_size), 0, __copy_size);
> > > >
> > > > return __copy_size;
> >
> > So we don't even hit that memset()? What the hell? __copy_user() is
> > declared as
> > __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
> >
> > and __copy_size copy_from_user() is
> >
> > __kernel_size_t __copy_size = (__kernel_size_t) n;
> >
> > So
> > return __copy_user(to, from, __copy_size);
> > and
> > __copy_size = __copy_user(to, from, __copy_size);
> > return __copy_size;
> > ought to be doing exactly the same thing. At that point it's starting to
> > smell like a compiler bug somewhere in there.
> >
> > Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> > and see if that's enough to recover. And it would be nice to see what
> > all three variants (as it is, with commit reverted and with just that if
> > removed) generate in e.g. sys_utimensat() (fs/utimes.s)
>
> It would be useful to know what compiler version was used to build the
> kernel. I wouldn't be surprised if some are buggy.
>
4.6.3 from kernel.org.
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-16 22:47 ` Guenter Roeck
@ 2016-09-16 23:32 ` Rich Felker
-1 siblings, 0 replies; 36+ messages in thread
From: Rich Felker @ 2016-09-16 23:32 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On Fri, Sep 16, 2016 at 03:47:44PM -0700, Guenter Roeck wrote:
> On Fri, Sep 16, 2016 at 05:39:18PM -0400, Rich Felker wrote:
> > On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> > > On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > > > Yes, reverting 6e050503a150 fixes the problem.
> > > >
> > > > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > > > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> > > >
> > > > Guenter
> > > >
> > > > > The change in question is
> > > > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > > > - return __copy_user(to, from, __copy_size);
> > > > > + __copy_size = __copy_user(to, from, __copy_size);
> > > > > +
> > > > > + if (unlikely(__copy_size))
> > > > > + memset(to + (n - __copy_size), 0, __copy_size);
> > > > >
> > > > > return __copy_size;
> > >
> > > So we don't even hit that memset()? What the hell? __copy_user() is
> > > declared as
> > > __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
> > >
> > > and __copy_size copy_from_user() is
> > >
> > > __kernel_size_t __copy_size = (__kernel_size_t) n;
> > >
> > > So
> > > return __copy_user(to, from, __copy_size);
> > > and
> > > __copy_size = __copy_user(to, from, __copy_size);
> > > return __copy_size;
> > > ought to be doing exactly the same thing. At that point it's starting to
> > > smell like a compiler bug somewhere in there.
> > >
> > > Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> > > and see if that's enough to recover. And it would be nice to see what
> > > all three variants (as it is, with commit reverted and with just that if
> > > removed) generate in e.g. sys_utimensat() (fs/utimes.s)
> >
> > It would be useful to know what compiler version was used to build the
> > kernel. I wouldn't be surprised if some are buggy.
> >
> 4.6.3 from kernel.org.
That is utterly ancient and probaby very buggy. I would recommend 5.x+
or at the very least 4.7 or 4.8.
Rich
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-16 23:32 ` Rich Felker
0 siblings, 0 replies; 36+ messages in thread
From: Rich Felker @ 2016-09-16 23:32 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On Fri, Sep 16, 2016 at 03:47:44PM -0700, Guenter Roeck wrote:
> On Fri, Sep 16, 2016 at 05:39:18PM -0400, Rich Felker wrote:
> > On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> > > On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > > > Yes, reverting 6e050503a150 fixes the problem.
> > > >
> > > > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > > > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> > > >
> > > > Guenter
> > > >
> > > > > The change in question is
> > > > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > > > - return __copy_user(to, from, __copy_size);
> > > > > + __copy_size = __copy_user(to, from, __copy_size);
> > > > > +
> > > > > + if (unlikely(__copy_size))
> > > > > + memset(to + (n - __copy_size), 0, __copy_size);
> > > > >
> > > > > return __copy_size;
> > >
> > > So we don't even hit that memset()? What the hell? __copy_user() is
> > > declared as
> > > __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
> > >
> > > and __copy_size copy_from_user() is
> > >
> > > __kernel_size_t __copy_size = (__kernel_size_t) n;
> > >
> > > So
> > > return __copy_user(to, from, __copy_size);
> > > and
> > > __copy_size = __copy_user(to, from, __copy_size);
> > > return __copy_size;
> > > ought to be doing exactly the same thing. At that point it's starting to
> > > smell like a compiler bug somewhere in there.
> > >
> > > Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> > > and see if that's enough to recover. And it would be nice to see what
> > > all three variants (as it is, with commit reverted and with just that if
> > > removed) generate in e.g. sys_utimensat() (fs/utimes.s)
> >
> > It would be useful to know what compiler version was used to build the
> > kernel. I wouldn't be surprised if some are buggy.
> >
> 4.6.3 from kernel.org.
That is utterly ancient and probaby very buggy. I would recommend 5.x+
or at the very least 4.7 or 4.8.
Rich
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-16 23:32 ` Rich Felker
@ 2016-09-17 2:23 ` Guenter Roeck
-1 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-17 2:23 UTC (permalink / raw)
To: Rich Felker; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/16/2016 04:32 PM, Rich Felker wrote:
>> 4.6.3 from kernel.org.
>
> That is utterly ancient and probaby very buggy. I would recommend 5.x+
> or at the very least 4.7 or 4.8.
>
Unfortunately that is the latest one available from kernel.org :-(.
I'll try to build one myself.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-17 2:23 ` Guenter Roeck
0 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-17 2:23 UTC (permalink / raw)
To: Rich Felker; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/16/2016 04:32 PM, Rich Felker wrote:
>> 4.6.3 from kernel.org.
>
> That is utterly ancient and probaby very buggy. I would recommend 5.x+
> or at the very least 4.7 or 4.8.
>
Unfortunately that is the latest one available from kernel.org :-(.
I'll try to build one myself.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-17 2:23 ` Guenter Roeck
@ 2016-09-18 4:40 ` Rob Landley
-1 siblings, 0 replies; 36+ messages in thread
From: Rob Landley @ 2016-09-18 4:40 UTC (permalink / raw)
To: Guenter Roeck, Rich Felker
Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/16/2016 09:23 PM, Guenter Roeck wrote:
> On 09/16/2016 04:32 PM, Rich Felker wrote:
>>> 4.6.3 from kernel.org.
>>
>> That is utterly ancient and probaby very buggy. I would recommend 5.x+
>> or at the very least 4.7 or 4.8.
>>
> Unfortunately that is the latest one available from kernel.org :-(.
> I'll try to build one myself.
Rich, you really, really need to get an actual release version of
https://github.com/richfelker/musl-cross-make posted.
Rob
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-18 4:40 ` Rob Landley
0 siblings, 0 replies; 36+ messages in thread
From: Rob Landley @ 2016-09-18 4:40 UTC (permalink / raw)
To: Guenter Roeck, Rich Felker
Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/16/2016 09:23 PM, Guenter Roeck wrote:
> On 09/16/2016 04:32 PM, Rich Felker wrote:
>>> 4.6.3 from kernel.org.
>>
>> That is utterly ancient and probaby very buggy. I would recommend 5.x+
>> or at the very least 4.7 or 4.8.
>>
> Unfortunately that is the latest one available from kernel.org :-(.
> I'll try to build one myself.
Rich, you really, really need to get an actual release version of
https://github.com/richfelker/musl-cross-make posted.
Rob
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-18 4:40 ` Rob Landley
@ 2016-09-18 15:17 ` Rich Felker
-1 siblings, 0 replies; 36+ messages in thread
From: Rich Felker @ 2016-09-18 15:17 UTC (permalink / raw)
To: Rob Landley
Cc: Guenter Roeck, Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On Sat, Sep 17, 2016 at 11:40:28PM -0500, Rob Landley wrote:
>
>
> On 09/16/2016 09:23 PM, Guenter Roeck wrote:
> > On 09/16/2016 04:32 PM, Rich Felker wrote:
> >>> 4.6.3 from kernel.org.
> >>
> >> That is utterly ancient and probaby very buggy. I would recommend 5.x+
> >> or at the very least 4.7 or 4.8.
> >>
> > Unfortunately that is the latest one available from kernel.org :-(.
> > I'll try to build one myself.
>
> Rich, you really, really need to get an actual release version of
> https://github.com/richfelker/musl-cross-make posted.
What do you mean? Binaries? There are release tags, though it would
probably be a good time to make another one.
But this project (musl-cross-make) is not needed for building kernels
-- stock gcc, any modern-ish version, should work fine. The canonical
way (from prior to my involvement) to build sh* kernels is to use a
gcc that supports any ISA level, and this can be done without multilib
libgcc since the kernel provides its own libgcc replacement functions.
Rich
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-18 15:17 ` Rich Felker
0 siblings, 0 replies; 36+ messages in thread
From: Rich Felker @ 2016-09-18 15:17 UTC (permalink / raw)
To: Rob Landley
Cc: Guenter Roeck, Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On Sat, Sep 17, 2016 at 11:40:28PM -0500, Rob Landley wrote:
>
>
> On 09/16/2016 09:23 PM, Guenter Roeck wrote:
> > On 09/16/2016 04:32 PM, Rich Felker wrote:
> >>> 4.6.3 from kernel.org.
> >>
> >> That is utterly ancient and probaby very buggy. I would recommend 5.x+
> >> or at the very least 4.7 or 4.8.
> >>
> > Unfortunately that is the latest one available from kernel.org :-(.
> > I'll try to build one myself.
>
> Rich, you really, really need to get an actual release version of
> https://github.com/richfelker/musl-cross-make posted.
What do you mean? Binaries? There are release tags, though it would
probably be a good time to make another one.
But this project (musl-cross-make) is not needed for building kernels
-- stock gcc, any modern-ish version, should work fine. The canonical
way (from prior to my involvement) to build sh* kernels is to use a
gcc that supports any ISA level, and this can be done without multilib
libgcc since the kernel provides its own libgcc replacement functions.
Rich
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-18 15:17 ` Rich Felker
@ 2016-09-29 2:36 ` Rob Landley
-1 siblings, 0 replies; 36+ messages in thread
From: Rob Landley @ 2016-09-29 2:36 UTC (permalink / raw)
To: Rich Felker
Cc: Guenter Roeck, Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/18/2016 10:17 AM, Rich Felker wrote:
> On Sat, Sep 17, 2016 at 11:40:28PM -0500, Rob Landley wrote:
>>
>>
>> On 09/16/2016 09:23 PM, Guenter Roeck wrote:
>>> On 09/16/2016 04:32 PM, Rich Felker wrote:
>>>>> 4.6.3 from kernel.org.
>>>>
>>>> That is utterly ancient and probaby very buggy. I would recommend 5.x+
>>>> or at the very least 4.7 or 4.8.
>>>>
>>> Unfortunately that is the latest one available from kernel.org :-(.
>>> I'll try to build one myself.
>>
>> Rich, you really, really need to get an actual release version of
>> https://github.com/richfelker/musl-cross-make posted.
>
> What do you mean? Binaries? There are release tags, though it would
> probably be a good time to make another one.
>
> But this project (musl-cross-make) is not needed for building kernels
> -- stock gcc, any modern-ish version, should work fine. The canonical
> way (from prior to my involvement) to build sh* kernels is to use a
> gcc that supports any ISA level, and this can be done without multilib
> libgcc since the kernel provides its own libgcc replacement functions.
The above was an example of somebody using a broken toolchain because
there isn't a known-good reference toolchain for the architecture, which
the kernel maintainer is known to regression test against. Having such a
thing might help people distinguish "bug in kernel" from "bug in gcc".
> Rich
Rob
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-29 2:36 ` Rob Landley
0 siblings, 0 replies; 36+ messages in thread
From: Rob Landley @ 2016-09-29 2:36 UTC (permalink / raw)
To: Rich Felker
Cc: Guenter Roeck, Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/18/2016 10:17 AM, Rich Felker wrote:
> On Sat, Sep 17, 2016 at 11:40:28PM -0500, Rob Landley wrote:
>>
>>
>> On 09/16/2016 09:23 PM, Guenter Roeck wrote:
>>> On 09/16/2016 04:32 PM, Rich Felker wrote:
>>>>> 4.6.3 from kernel.org.
>>>>
>>>> That is utterly ancient and probaby very buggy. I would recommend 5.x+
>>>> or at the very least 4.7 or 4.8.
>>>>
>>> Unfortunately that is the latest one available from kernel.org :-(.
>>> I'll try to build one myself.
>>
>> Rich, you really, really need to get an actual release version of
>> https://github.com/richfelker/musl-cross-make posted.
>
> What do you mean? Binaries? There are release tags, though it would
> probably be a good time to make another one.
>
> But this project (musl-cross-make) is not needed for building kernels
> -- stock gcc, any modern-ish version, should work fine. The canonical
> way (from prior to my involvement) to build sh* kernels is to use a
> gcc that supports any ISA level, and this can be done without multilib
> libgcc since the kernel provides its own libgcc replacement functions.
The above was an example of somebody using a broken toolchain because
there isn't a known-good reference toolchain for the architecture, which
the kernel maintainer is known to regression test against. Having such a
thing might help people distinguish "bug in kernel" from "bug in gcc".
> Rich
Rob
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-16 23:32 ` Rich Felker
@ 2016-09-17 2:28 ` Guenter Roeck
-1 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-17 2:28 UTC (permalink / raw)
To: Rich Felker; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/16/2016 04:32 PM, Rich Felker wrote:
[ ... ]
>>> It would be useful to know what compiler version was used to build the
>>> kernel. I wouldn't be surprised if some are buggy.
>>>
>> 4.6.3 from kernel.org.
>
> That is utterly ancient and probaby very buggy. I would recommend 5.x+
> or at the very least 4.7 or 4.8.
>
I found a toolchain with 5.3.0, and using it the problem disappears. Oh well.
Sorry for the noise.
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-17 2:28 ` Guenter Roeck
0 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-17 2:28 UTC (permalink / raw)
To: Rich Felker; +Cc: Al Viro, linux-kernel, Yoshinori Sato, linux-sh
On 09/16/2016 04:32 PM, Rich Felker wrote:
[ ... ]
>>> It would be useful to know what compiler version was used to build the
>>> kernel. I wouldn't be surprised if some are buggy.
>>>
>> 4.6.3 from kernel.org.
>
> That is utterly ancient and probaby very buggy. I would recommend 5.x+
> or at the very least 4.7 or 4.8.
>
I found a toolchain with 5.3.0, and using it the problem disappears. Oh well.
Sorry for the noise.
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-16 21:31 ` Al Viro
@ 2016-09-16 22:47 ` Guenter Roeck
-1 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-16 22:47 UTC (permalink / raw)
To: Al Viro; +Cc: linux-kernel, Yoshinori Sato, linux-sh, Rich Felker
On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > Yes, reverting 6e050503a150 fixes the problem.
> >
> > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> >
> > Guenter
> >
> > > The change in question is
> > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > - return __copy_user(to, from, __copy_size);
> > > + __copy_size = __copy_user(to, from, __copy_size);
> > > +
> > > + if (unlikely(__copy_size))
> > > + memset(to + (n - __copy_size), 0, __copy_size);
> > >
> > > return __copy_size;
>
> So we don't even hit that memset()? What the hell? __copy_user() is
> declared as
> __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
>
> and __copy_size copy_from_user() is
>
> __kernel_size_t __copy_size = (__kernel_size_t) n;
>
> So
> return __copy_user(to, from, __copy_size);
> and
> __copy_size = __copy_user(to, from, __copy_size);
> return __copy_size;
> ought to be doing exactly the same thing. At that point it's starting to
> smell like a compiler bug somewhere in there.
>
> Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> and see if that's enough to recover. And it would be nice to see what
> all three variants (as it is, with commit reverted and with just that if
> removed) generate in e.g. sys_utimensat() (fs/utimes.s)
Adding pr_info() just before the "if (unlikely..." fixes the problem.
Commenting out the "if (unlikely())" code fixes the problem.
Using a new variable "unsigned long x" for the return code instead of
re-using __copy_size fixes the problem.
Replacing "return __copy_size;" with "return __copy_size & 0xffffffff;"
fixes the problem.
The problem only seems to be seen if the copy size length is odd (more
specifically, the failing copy always has a length of 25 bytes).
No idea what is going on. Bug in __copy_user() ? Compiler bug ?
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-16 22:47 ` Guenter Roeck
0 siblings, 0 replies; 36+ messages in thread
From: Guenter Roeck @ 2016-09-16 22:47 UTC (permalink / raw)
To: Al Viro; +Cc: linux-kernel, Yoshinori Sato, linux-sh, Rich Felker
On Fri, Sep 16, 2016 at 10:31:41PM +0100, Al Viro wrote:
> On Fri, Sep 16, 2016 at 01:59:38PM -0700, Guenter Roeck wrote:
> > Yes, reverting 6e050503a150 fixes the problem.
> >
> > I added a BUG() into the "if (unlikely())" below, but it doesn't catch,
> > and I still get the ip: OVERRUN errors. Which leaves me a bit puzzled.
> >
> > Guenter
> >
> > > The change in question is
> > > if (__copy_size && __access_ok(__copy_from, __copy_size))
> > > - return __copy_user(to, from, __copy_size);
> > > + __copy_size = __copy_user(to, from, __copy_size);
> > > +
> > > + if (unlikely(__copy_size))
> > > + memset(to + (n - __copy_size), 0, __copy_size);
> > >
> > > return __copy_size;
>
> So we don't even hit that memset()? What the hell? __copy_user() is
> declared as
> __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
>
> and __copy_size copy_from_user() is
>
> __kernel_size_t __copy_size = (__kernel_size_t) n;
>
> So
> return __copy_user(to, from, __copy_size);
> and
> __copy_size = __copy_user(to, from, __copy_size);
> return __copy_size;
> ought to be doing exactly the same thing. At that point it's starting to
> smell like a compiler bug somewhere in there.
>
> Try to remove that (not triggered) if (unlikely(__copy_size)) memset(...)
> and see if that's enough to recover. And it would be nice to see what
> all three variants (as it is, with commit reverted and with just that if
> removed) generate in e.g. sys_utimensat() (fs/utimes.s)
Adding pr_info() just before the "if (unlikely..." fixes the problem.
Commenting out the "if (unlikely())" code fixes the problem.
Using a new variable "unsigned long x" for the return code instead of
re-using __copy_size fixes the problem.
Replacing "return __copy_size;" with "return __copy_size & 0xffffffff;"
fixes the problem.
The problem only seems to be seen if the copy size length is odd (more
specifically, the failing copy always has a length of 25 bytes).
No idea what is going on. Bug in __copy_user() ? Compiler bug ?
Guenter
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
2016-09-16 22:47 ` Guenter Roeck
@ 2016-09-16 23:00 ` Al Viro
-1 siblings, 0 replies; 36+ messages in thread
From: Al Viro @ 2016-09-16 23:00 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-kernel, Yoshinori Sato, linux-sh, Rich Felker
On Fri, Sep 16, 2016 at 03:47:04PM -0700, Guenter Roeck wrote:
> Adding pr_info() just before the "if (unlikely..." fixes the problem.
>
> Commenting out the "if (unlikely())" code fixes the problem.
>
> Using a new variable "unsigned long x" for the return code instead of
> re-using __copy_size fixes the problem.
>
> Replacing "return __copy_size;" with "return __copy_size & 0xffffffff;"
> fixes the problem.
>
> The problem only seems to be seen if the copy size length is odd (more
> specifically, the failing copy always has a length of 25 bytes).
>
> No idea what is going on. Bug in __copy_user() ? Compiler bug ?
Definitely a compiler bug. __kernel_size_t is 32 bits on sh; that & 0xffffffff
should've been optimized away, for crying out loud!
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'
@ 2016-09-16 23:00 ` Al Viro
0 siblings, 0 replies; 36+ messages in thread
From: Al Viro @ 2016-09-16 23:00 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-kernel, Yoshinori Sato, linux-sh, Rich Felker
On Fri, Sep 16, 2016 at 03:47:04PM -0700, Guenter Roeck wrote:
> Adding pr_info() just before the "if (unlikely..." fixes the problem.
>
> Commenting out the "if (unlikely())" code fixes the problem.
>
> Using a new variable "unsigned long x" for the return code instead of
> re-using __copy_size fixes the problem.
>
> Replacing "return __copy_size;" with "return __copy_size & 0xffffffff;"
> fixes the problem.
>
> The problem only seems to be seen if the copy size length is odd (more
> specifically, the failing copy always has a length of 25 bytes).
>
> No idea what is going on. Bug in __copy_user() ? Compiler bug ?
Definitely a compiler bug. __kernel_size_t is 32 bits on sh; that & 0xffffffff
should've been optimized away, for crying out loud!
^ permalink raw reply [flat|nested] 36+ messages in thread