[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: busybox sh broken on i386 with glibc 2.26, leads to kernel panic



On Sun, 2018-01-21 at 12:18 +0100, Aurelien Jarno wrote:
> On 2018-01-21 00:47, Ben Hutchings wrote:
> > On Wed, 17 Jan 2018 12:31:06 +0100 Aurelien Jarno <aurel32@debian.org> wrote:
> > [...]
> > > busybox is compiled with -mpreferred-stack-boundary=2 on i386 which has
> > > the same effect of reducing the default stack alignment from 16 bytes to
> > > 2 bytes. This comes from arch/i386/Makefile:
> > 
> > The argument is the log2 of the alignment, so this sets alignment to 4
> > bytes - which is compliant with the System V psABI for i386.
> 
> This is correct, but it is not compliant with the i386 GCC ABI which
> assumes the stack is 16-byte aligned (not just 4-byte aligned) when the
> call instruction in the caller was executed.

Yes, that's what I think the bug is - gcc's default ABI for
i386-linux-gnu was quietly changed.

> > Any assumption of 16-byte stack alignment in glibc on i386 will break
> > not only busybox but most binaries built with old versions of gcc
> > (before 4.2, if the comment in busybox is correct).  So this really
> > ought to be fixed there.
> 
> The 16-byte stack alignment in glibc on i386 comes from a GCC 7
> regression, reported as bug #887327. It has been fixed in the upstream
> gcc-7 branch in the mean time.
> 
> > I think that any libraries that need to maintain backward binary
> > compatibility will need to be compiled with the option
> > -mincoming-stack-boundary=2.  gcc will then fix up the stack alignment
> > in functions that need greater alignment for local variables.
> 
> If we allow any binary to be built with -mpreferred-stack-boundary=2,
> we need to build *all* libraries with -mincoming-stack-boundary=2, not
> only the ones that need to maintain backward binary compatibility.

That's true, but we could also specify that if you mess with stack
alignment you can only use libc6 and other libraries whose ABI pre-
dates the change in gcc.  (I don't know where we would do that; I
haven't seen any formal specifications of Debian architectures.)

> In that case we should make it the default in GCC.

I think there are quite few libraries where this would be necessary.  I
could be wrong.

Ben.

-- 
Ben Hutchings
Reality is just a crutch for people who can't handle science fiction.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: