Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1557158

Re: x86-64: Maintain 16-byte stack alignment

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: x86-64: Maintain 16-byte stack alignment
Date 2017-01-12 09:00 +0100
Message-ID <sYIsF-1h1-3@gated-at.bofh.it> (permalink)
References <sY5KF-2vR-21@gated-at.bofh.it> <sY5KF-2vR-19@gated-at.bofh.it> <sY85Q-44s-27@gated-at.bofh.it> <sYHGh-11j-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jan 11, 2017 at 11:05 PM, Herbert Xu
<herbert@gondor.apana.org.au> wrote:
> On Tue, Jan 10, 2017 at 09:05:28AM -0800, Linus Torvalds wrote:
>>
>> I'm pretty sure we have random asm code that may not maintain a
>> 16-byte stack alignment when it calls other code (including, in some
>> cases, calling C code).
>>
>> So I'm not at all convinced that this is a good idea. We shouldn't
>> expect 16-byte alignment to be something trustworthy.
>
> So what if we audited all the x86 assembly code to fix this? Would
> it then be acceptable to do a 16-byte aligned stack?
>
> On the face of it it doesn't seem to be a huge amount of code
> assuming they mostly live under arch/x86.

The problem is that we have nasties like TRACE_IRQS_OFF.  Performance
doesn't really matter for these macros, so we could probably rig up a
helper for forcibly align the stack there.  Maybe
FRAME_BEGIN_FORCE_ALIGN?  I also think I'd rather not to modify
pt_regs.  We should just fix the small number of code paths that
create a pt_regs and then call into C code to align the stack.

But if we can't do this with automatic verification, then I'm not sure
I want to do it at all.  The asm is already more precarious than I'd
like, and having a code path that is misaligned is asking for obscure
bugs down the road.

--Andy

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-10 15:40 +0100
  Re: x86-64: Maintain 16-byte stack alignment Linus Torvalds <torvalds@linux-foundation.org> - 2017-01-10 18:10 +0100
    Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-10 18:20 +0100
    Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-11 04:20 +0100
      Re: x86-64: Maintain 16-byte stack alignment Linus Torvalds <torvalds@linux-foundation.org> - 2017-01-11 04:40 +0100
        Re: x86-64: Maintain 16-byte stack alignment Linus Torvalds <torvalds@linux-foundation.org> - 2017-01-11 05:20 +0100
          Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-11 05:40 +0100
            Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-11 07:10 +0100
              Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-12 07:30 +0100
                Re: x86-64: Maintain 16-byte stack alignment Ingo Molnar <mingo@kernel.org> - 2017-01-12 08:50 +0100
                Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-12 15:10 +0100
                Re: x86-64: Maintain 16-byte stack alignment Linus Torvalds <torvalds@linux-foundation.org> - 2017-01-12 21:00 +0100
                Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-12 21:10 +0100
                Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-12 21:20 +0100
                Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-12 22:00 +0100
                Re: x86-64: Maintain 16-byte stack alignment Linus Torvalds <torvalds@linux-foundation.org> - 2017-01-12 22:50 +0100
                Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-13 09:40 +0100
                Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-13 02:50 +0100
                Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-13 04:20 +0100
                Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-13 04:30 +0100
                Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-13 05:30 +0100
                Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-13 06:10 +0100
                Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-13 09:50 +0100
                Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-13 09:50 +0100
                Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-13 09:50 +0100
                Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-13 09:40 +0100
                Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-13 14:10 +0100
            Re: x86-64: Maintain 16-byte stack alignment Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-01-11 09:10 +0100
              Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-11 09:20 +0100
                Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-11 19:30 +0100
    Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-12 08:10 +0100
      Re: x86-64: Maintain 16-byte stack alignment Ingo Molnar <mingo@kernel.org> - 2017-01-12 08:50 +0100
        Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-12 15:50 +0100
      Re: x86-64: Maintain 16-byte stack alignment Andy Lutomirski <luto@amacapital.net> - 2017-01-12 09:00 +0100
        Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-12 09:10 +0100
          Re: x86-64: Maintain 16-byte stack alignment Ingo Molnar <mingo@kernel.org> - 2017-01-12 09:20 +0100
        Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-12 16:10 +0100
          Re: x86-64: Maintain 16-byte stack alignment Herbert Xu <herbert@gondor.apana.org.au> - 2017-01-12 16:10 +0100
            Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-12 16:20 +0100
          Re: x86-64: Maintain 16-byte stack alignment Josh Poimboeuf <jpoimboe@redhat.com> - 2017-01-12 16:20 +0100

csiph-web