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] [day] [month] [year] [list]
Date:   Mon, 25 Oct 2021 12:48:19 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Willy Tarreau' <w@....eu>
CC:     "Paul E . McKenney" <paulmck@...nel.org>,
        Bedirhan KURT <windowz414@...weeb.org>,
        Louvian Lyndal <louvianlyndal@...il.com>,
        "Ammar Faizi" <ammar.faizi@...dents.amikom.ac.id>,
        Peter Cordes <peter@...des.ca>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: RE: [PATCH 2/3] tools/nolibc: i386: fix initial stack alignment

From: Willy Tarreau
> Sent: 25 October 2021 09:06
> 
> On Mon, Oct 25, 2021 at 07:46:11AM +0000, David Laight wrote:
> > From: Willy Tarreau
> > > Sent: 24 October 2021 18:28
> > >
> > > After re-checking in the spec and comparing stack offsets with glibc,
> > > The last pushed argument must be 16-byte aligned (i.e. aligned before the
> > > call) so that in the callee esp+4 is multiple of 16, so the principle is
> > > the 32-bit equivalent to what Ammar fixed for x86_64. It's possible that
> > > 32-bit code using SSE2 or MMX could have been affected. In addition the
> > > frame pointer ought to be zero at the deepest level.
> > >
> > ...
> > >  /* startup code */
> > > +/*
> > > + * i386 System V ABI mandates:
> > > + * 1) last pushed argument must be 16-byte aligned.
> > > + * 2) The deepest stack frame should be set to zero
> >
> > I'm pretty sure that the historic SYSV i386 ABI only every required
> > 4-byte alignment for the stack.
> >
> > At some point it got 'randomly' changed to 16-byte.
> > I don't think this happened until after compiler support for SSE2
> > intrinsics was added.
> 
> It's very possible because I've done a number of tests and noticed
> that in some cases the called functions' stack doesn't seem to be
> more than 4-aligned. However the deepest function in the stack starts
> with an aligned stack so I prefer to follow this same rule.

Any call through asm is unlikely to maintain the 16 byte alignment.
But yes, starting off on the required (by gcc) alignment does no harm.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ