Received: by 10.223.185.116 with SMTP id b49csp90509wrg; Tue, 20 Feb 2018 16:34:10 -0800 (PST) X-Google-Smtp-Source: AH8x227fsFpu4ZlFplY0wqtirB8CQ5h+ViHswhhQAO/el4KEvDJg64DqPDjRhEGr9lbl5MZ+r63i X-Received: by 10.99.94.67 with SMTP id s64mr1112344pgb.379.1519173250656; Tue, 20 Feb 2018 16:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519173250; cv=none; d=google.com; s=arc-20160816; b=PYOQ1m5pw+O0M9Qy04cl+l0CwSPcX/aZj6W56Gj3vHBin8QV50i8XHY0T/4sEzhvnJ P40ltgNoSNUvR1cH2eGmHh/ZCvuzm7t+qBAojGwXnsc9MhQRYnyTEix/yvWHsVigNE98 eI+pB59NARb3YVUggDf7j0GxmyeKAoIs6FGM6DAN2G7m1134jxQ5NXbdMXlvSFeoEuCY gfUXqzz6i9oh+JvslnDhvg7ipbTCXzCyr24WpEhkRwbTV5mvatIBFo4OS3mXT3FTGxxV zW4W0gDURFlkJZWeMsP/YioZ04Aq0qs6NeS18f0+KzDh16zDIaArz+ep0JjP1kcbo17l R7vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=2OUc4j5QxbOZ6wtgZN8LtehOt7rOSQB5nmRQ3nfVg5k=; b=DaHkJREijI9xx+r4K9Y2MDRS8f7x4FoW+3/23h0FY0Q5s+4nbJvnfktkZhz8fYN4DN nvx5kGWkW22VNwL8DkEBJyEXmZiXE6Qaj6FaV+llt76C9/ewkE8evMXNBBCxF9B5P3qs sSVwEzme7mMd5X/TuCty3f+S9GNJsxoWKzpVxT8Nj7AqOP21BEjVMB86Iad1d464zV4j dk39G6PMr9M8QSFlBalBoTAmNNfdmMa88v9HvxUEFdQz9ItFyFSAZufMcMvkbcR8rSG8 PCWvyxNdWzwB9MevgdI3awMAMIP8yhZg8mO03IgDCXO3DzU8tfZnvZ2p79kCBjDr0lVr 6I1w== 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 l2-v6si11284541pli.824.2018.02.20.16.33.46; Tue, 20 Feb 2018 16:34:10 -0800 (PST) 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 S1751000AbeBUAbp (ORCPT + 99 others); Tue, 20 Feb 2018 19:31:45 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38484 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750710AbeBUAbo (ORCPT ); Tue, 20 Feb 2018 19:31:44 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 776FAEDD; Wed, 21 Feb 2018 00:31:43 +0000 (UTC) Date: Tue, 20 Feb 2018 16:31:42 -0800 From: Andrew Morton To: Kees Cook Cc: Andy Lutomirski , Jann Horn , Ingo Molnar , Laura Abbott , Thomas Gleixner , Al Viro , Sahara , "Levin, Alexander (Sasha Levin)" , Michal Hocko , Andrea Arcangeli , "Kirill A. Shutemov" , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [PATCH] fork: Allow stack to be wiped on fork Message-Id: <20180220163142.15366a82a7bece715b997597@linux-foundation.org> In-Reply-To: <20180117055015.GA15256@beast> References: <20180117055015.GA15256@beast> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 16 Jan 2018 21:50:15 -0800 Kees Cook wrote: > One of the classes of kernel stack content leaks is exposing the contents > of prior heap or stack contents when a new process stack is allocated. > Normally, those stacks are not zeroed, and the old contents remain in > place. With some types of stack content exposure flaws, those contents > can leak to userspace. Kernels built with CONFIG_CLEAR_STACK_FORK will > no longer be vulnerable to this, as the stack will be wiped each time > a stack is assigned to a new process. There's not a meaningful change > in runtime performance; it almost looks like it provides a benefit. > > Performing back-to-back kernel builds before: > Run times: 157.86 157.09 158.90 160.94 160.80 > Mean: 159.12 > Std Dev: 1.54 > > With CONFIG_CLEAR_STACK_FORK=y: > Run times: 159.31 157.34 156.71 158.15 160.81 > Mean: 158.46 > Std Dev: 1.46 > > ... > > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -904,6 +904,14 @@ config VMAP_STACK > the stack to map directly to the KASAN shadow map using a formula > that is incorrect if the stack is in vmalloc space. > > +config CLEAR_STACK_FORK > + bool "Clear the kernel stack at each fork" > + help > + To resist stack content leak flaws, this clears newly allocated > + kernel stacks to keep previously freed heap or stack contents > + from being present in the new stack. This has almost no > + measurable performance impact. > + It would be much nicer to be able to control this at runtime rather than compile-time. Why not a /proc tunable? We could always use more of those ;)