Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp302137yba; Thu, 18 Apr 2019 01:18:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5LF7j1AKTZBqP8XcFDB9Wpo8JzGypdhu2lZCZb2FDup4WI4HExI8+sDcpP+H26pYxH5D7 X-Received: by 2002:a63:330e:: with SMTP id z14mr85417867pgz.4.1555575523291; Thu, 18 Apr 2019 01:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555575523; cv=none; d=google.com; s=arc-20160816; b=z9FKHQgdaWmc0eqftNwugmNsK3buHAeo1OP8XM82toPar4FYpL6EJhHqQugG+Ki0Jl OhswoFs1gPiLGTtzeUdenOvOgeKBI1CJPbapCyCpfD0w1VgoF2FKHKbguXP3ct1Jn9o7 YeF4d8jnQ9lKsNjAN2shJprO5Xr7rI2TAD/SRlDcsqlIvZ2bI3sf4pb/RNOaA0unryca wykH0DIrMs3jE5+oOyGkYi33yvH1eb0mt0nmk0XBCUYHGSqytc4na96AYAmzOc9hJEY9 1SosX8OXZXGLlbflZCOeKoa9Ts7nWwXDtqApgshw72RUM05b0GFMxzpXMZicalA0Jv5P UZeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=uYwFGWq03pr9SpYfliUADOL1nKm4nWlYXmcVPluI3mc=; b=uhMLnwjwcxdpkmRLTYBPmd98IZiF7F7XaPvrmBPZ1tpMHYHq9ITVxDNSmM6GFF+C/6 9rUBXzxQBFVduEnWgso2bKJBoGkdSdNftffBk73YXnahFZ2xUtaDEmMqY6URy0/OvF+d 8i/KgizIb5SlDadBpSxr+s1T9ncXAKFlWUaIJjzPSjzj8Oqx7peueOxNCAloFM8y1+Vj hKV41rYGK2pbUbvbNpAu7GA6kVlC6DistVyhajAR/J/dMUPGBJMuZvRr1aQx9Q4DXQ0W zVKN/s6vHubNXQootdnu30m+MgC4A73sGtTpfTkhNWZtC+APguXRBzS3lagkpaTLCnJW qq+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si1275498pgc.472.2019.04.18.01.18.27; Thu, 18 Apr 2019 01:18:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388197AbfDRIR0 (ORCPT + 99 others); Thu, 18 Apr 2019 04:17:26 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:32858 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfDRIR0 (ORCPT ); Thu, 18 Apr 2019 04:17:26 -0400 Received: from pd9ef12d2.dip0.t-ipconnect.de ([217.239.18.210] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hH2EU-0000hD-O7; Thu, 18 Apr 2019 10:17:22 +0200 Date: Thu, 18 Apr 2019 10:17:21 +0200 (CEST) From: Thomas Gleixner To: Kees Cook cc: Hector Marco-Gisbert , LKML , Ingo Molnar , "H. Peter Anvin" , X86 ML , Brian Gerst , Andy Lutomirski , Borislav Petkov , Huaitong Han , Ismael Ripoll Ripoll , Kernel Hardening , Jason Gunthorpe , Andi Kleen , Mark Rutland Subject: Re: [PATCH] x86_64: Disabling read-implies-exec when the stack is executable In-Reply-To: Message-ID: References: <1462963502-11636-1-git-send-email-hecmargi@upv.es> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Apr 2019, Kees Cook wrote: > On Wed, May 11, 2016 at 5:45 AM Hector Marco-Gisbert wrote: > *thread necromancy* > > I'd still like to see this get landed. READ_IMPLIES_EXEC is way too > powerful (it impacts, for example, mmap() regions of device driver > memory, forcing drivers to not be able to disallow VM_EXEC[1]). > > The only case it could break is on an AMD K8 (Athlon only, I assume?), > which seems unlikely to have a modern kernel run on it. If there is > still concern, then we could just test against the NX CPU feature: > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > index 69c0f892e310..367cd36259a4 100644 > --- a/arch/x86/include/asm/elf.h > +++ b/arch/x86/include/asm/elf.h > @@ -280,10 +280,12 @@ extern u32 elf_hwcap2; > > /* > * An executable for which elf_read_implies_exec() returns TRUE will > - * have the READ_IMPLIES_EXEC personality flag set automatically. > + * have the READ_IMPLIES_EXEC personality flag set automatically when > + * a CPU did not support NX or is using a 32-bit memory layout. > */ > -#define elf_read_implies_exec(ex, executable_stack) \ > - (executable_stack != EXSTACK_DISABLE_X) > +#define elf_read_implies_exec(ex, executable_stack) \ > + (mmap_is_ia32() || !(__supported_pte_mask & _PAGE_NX) ? \ What's special about ia32? All what matters is whether PAGE_NX is supported or not. That has nothing to do with 32/64bit unless I'm missing something (as usual). Thanks, tglx