Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5096961ybi; Tue, 30 Jul 2019 13:43:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRnYVpu+507UNVfFxiHAhkQgwkCnLr5XUGn2aPNQb12Ib0ot3YFBhBqIYxQnw3YYcOv1vG X-Received: by 2002:aa7:8a97:: with SMTP id a23mr42955829pfc.117.1564519423882; Tue, 30 Jul 2019 13:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564519423; cv=none; d=google.com; s=arc-20160816; b=MSKVve/OfgeL9Na/IljAfraSQqdDaIrIf9wnp9zLl9ciAWe59NyV+GL5dCw5h0ECpj 8CbSUm7Mx2XkKxWgaP0uQIAMa17spjclqvfq3SZyLvLMIVDRe6WqlH9OnnUpZg3o6NKm JuobicqoemW3t0tqthqwPEFENx4GYMwU2dcgjBivO+pUlCcV91geXdOyTzuodGbXt/IQ mI76DC24q1g1YD0MCl5sy/jeUN183zRh2Juyt8qBYHeQlEeaqPRf9unUJwPX4UsF0B8Q BSe+Ao5zHhScDRw2FCxY9VHRlZiZDBtjDyBXaaJG3U2zwWBrqCp6RLwTbwrlg1SdjB+x W07Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=UiyIYqXSI6n8BvwhN7+LjSI4Y/g+Sy0AddtIzNX1Okc=; b=i/4USq9ypmaNiHi84qduFBvMef7oxwjerANCoTbVSJjRPlDnjGHffu2RgqaN5Td0Ql weGdAkIBkycVuNeQVHDYCMCT0Pl8RlHsJe6ciBGrhRGeWCQC9fz53hb9v8F75v3eDtNF naL4GwBZhmV/LN3YoGTI+/5Z7VQ2lwW4b952VZ678cMaIo4lGjnPzoQpMbt6jQAfe1/F G1QIdCeVaszlVhkxY192jPadcvx1p/rjKfu3eh66pQg+3XZi3jfD6cKXqXpxEEoc1eKA tU97NWs4BKYeOHNwh96IUYwHTSQR/mCZ53MvY7M6ZEX4f9UzxjaLaNGO+60HG8aFKgST OpMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CE2ybIhq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go12si26152598plb.251.2019.07.30.13.43.29; Tue, 30 Jul 2019 13:43: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; dkim=pass header.i=@chromium.org header.s=google header.b=CE2ybIhq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727559AbfG3SIB (ORCPT + 99 others); Tue, 30 Jul 2019 14:08:01 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:34151 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbfG3SIA (ORCPT ); Tue, 30 Jul 2019 14:08:00 -0400 Received: by mail-pl1-f196.google.com with SMTP id i2so29223448plt.1 for ; Tue, 30 Jul 2019 11:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UiyIYqXSI6n8BvwhN7+LjSI4Y/g+Sy0AddtIzNX1Okc=; b=CE2ybIhq+DHqTSzNEuPWsQl9INxAbJjWW+X54Ku6XG6LT1afZKNHBxq82foLw1BWvZ 8NL8ea1l7oLUTUU3hn2l+iwfsmRIlHQ5zSDph3UwbcfFWCnnm2LNjX5GpGftd01P8Vye R3EFG4W2GkYR/iTAjgtyxcvFBIwmlPtTE4nxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UiyIYqXSI6n8BvwhN7+LjSI4Y/g+Sy0AddtIzNX1Okc=; b=DgvDGthqZQBzo5+8l67+hjpXZsqpOVtfPHtQ6Y4KYckQ6NeHFZKDcLm02KE6HeOlh0 JZWzwQxk3JxipTxTBh23QjQMRpWLpztIm2mboKastZmmcOhz3VNVHNaMiSN75E0EawYj upFGkkG5IpsSQayXyVOTAhxefFT45Fazy7fbOW0TL6JcDA5kWWy/X+e6CSIXTc6qyVT+ AKPuaAEIs3QQVpd8lOwTbf9A/qoxvno01xjTN1kUG8zcA/+oSp1RSjpkGzTyPiza4v31 gk566RajD8GUQAhyWMreKef2+Pfm80CjqdG0aJqnQYDG6BrmpPJTN9+QZypy7/vOJNnv +h3A== X-Gm-Message-State: APjAAAXb17PONEUe3m9rCfWaZyyoHpMs1I8On9CX0ktSPplo/CgHg8+j /5XvV58cR+VbjSE7mDgaah6/sg== X-Received: by 2002:a17:902:aa09:: with SMTP id be9mr31359048plb.52.1564510079444; Tue, 30 Jul 2019 11:07:59 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y11sm68541316pfb.119.2019.07.30.11.07.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jul 2019 11:07:58 -0700 (PDT) Date: Tue, 30 Jul 2019 11:07:57 -0700 From: Kees Cook To: "Reshetova, Elena" Cc: Ingo Molnar , Andy Lutomirski , Theodore Ts'o , David Laight , Eric Biggers , "ebiggers@google.com" , "herbert@gondor.apana.org.au" , Peter Zijlstra , Daniel Borkmann , "linux-kernel@vger.kernel.org" , "jpoimboe@redhat.com" , "jannh@google.com" , "Perla, Enrico" , "mingo@redhat.com" , "bp@alien8.de" , "tglx@linutronix.de" , "gregkh@linuxfoundation.org" , "Edgecombe, Rick P" , Linus Torvalds , Peter Zijlstra Subject: Re: [PATCH] x86/entry/64: randomize kernel stack offset upon syscall Message-ID: <201907301102.9339710C6@keescook> References: <20190509084352.GA96236@gmail.com> <201905111703.5998DF5F@keescook> <20190512080245.GA7827@gmail.com> <201905120705.4F27DF3244@keescook> <2236FBA76BA1254E88B949DDB74E612BA4CA8DBF@IRSMSX102.ger.corp.intel.com> <20190528133347.GD19149@mit.edu> <2236FBA76BA1254E88B949DDB74E612BA4CABA56@IRSMSX102.ger.corp.intel.com> <201905291136.FD61FF42@keescook> <2236FBA76BA1254E88B949DDB74E612BA4D4BFCA@IRSMSX102.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2236FBA76BA1254E88B949DDB74E612BA4D4BFCA@IRSMSX102.ger.corp.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 29, 2019 at 11:41:11AM +0000, Reshetova, Elena wrote: > I want to summarize here the data (including the performance numbers) > and reasoning for the in-stack randomization feature. I have organized > it in a simple set of Q&A below. Thanks for these! > The in-stack randomization is really a very small change both code wise and > logic wise. > It does not affect real workloads and does not require enablement of other > features (such as GCC plugins). > So, I think we should really reconsider its inclusion. I'd agree: the code is tiny and while the benefit can't point to a specific issue, it does point to the general weakness of the stack offset being predictable which has been a core observation for many stack-based attacks. If we're going to save state between syscalls (like the 4096 random bytes pool), how about instead we just use a single per-CPU long mixed with rdtsc saved at syscall exit. That should be a reasonable balance between all the considerations and make it trivial for the feature to be a boot flag without the extra page of storage, etc. -- Kees Cook