From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750873AbdALPGD (ORCPT ); Thu, 12 Jan 2017 10:06:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58606 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbdALPFz (ORCPT ); Thu, 12 Jan 2017 10:05:55 -0500 Date: Thu, 12 Jan 2017 09:03:18 -0600 From: Josh Poimboeuf To: Andy Lutomirski Cc: Herbert Xu , Linus Torvalds , Linux Kernel Mailing List , Linux Crypto Mailing List , Ingo Molnar , Thomas Gleixner , Andy Lutomirski , Ard Biesheuvel Subject: Re: x86-64: Maintain 16-byte stack alignment Message-ID: <20170112150318.eq4lmfitxvitpix4@treble> References: <20170110143340.GA3787@gondor.apana.org.au> <20170110143913.GA3822@gondor.apana.org.au> <20170112070534.GA14016@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 12 Jan 2017 15:03:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 11, 2017 at 11:51:10PM -0800, Andy Lutomirski wrote: > On Wed, Jan 11, 2017 at 11:05 PM, Herbert Xu > 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. For the entry code, could we just replace all calls with CALL_ALIGNED? That might be less intrusive than trying to adjust all the pt_regs accesses. Then to ensure that nobody ever uses 'call' directly: '#define call please-use-CALL-ALIGNED-instead-of-call' I think that would be possible if CALL_ALIGNED were a ".macro". -- Josh