Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4807396ooa; Tue, 14 Aug 2018 10:49:39 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzKUAnV4BfiB3W5QkpK4GB/e6Vh/9n6YnEXhpv/9p2g7AhNL6YjRH8lQk45JXaqX9RG+c3/ X-Received: by 2002:a17:902:2d24:: with SMTP id o33-v6mr21455337plb.38.1534268978981; Tue, 14 Aug 2018 10:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268978; cv=none; d=google.com; s=arc-20160816; b=RfGLGYwp12rRg9QnYUYnZJ+w+YROnGIhCJwlpOjO+vIVoo1zU6/CXSHEWh0FEQZB9y Ywuea2eE+Z7+IXaFXKvF/tvxBKjl+xgcF7vJ513NMopnhfwsb+hmvGjR8p9r+GSOE+kL h89Cqj6ddIeZvfq3JG4f/7arr7kZwTlFmAQOUylvP8BUnti6R4ZdHM+r4G3t79DlGi8A 5PEVfyFLPmSpfUSkCTQeJAkgccnVgyxU8Tx2VU23c4tFRfUSDqDJ3/UBRo94WxLzOIZb poQOJMwXWO7bOoljgceq17sTDFtcFbUTMr/6vxhdV8WBOCGvERtF7spIju4pHwc9YViG ouNA== 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 :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hlyxRljmN4ILP3Q5+MMkuKSUHK+uUglu6y3MBV4QNTI=; b=PVWXzdZ+8qJgTgWzZjG4Vdn1Xr/90NdFQbmBDHQ2JyVNxkR9HcltAiG7la/Pnl0v1p +XKjUqe16gkFgblZCNZRYVvJOFQwrV0EFS8skY2OIskxh1PlJ1BYdQHKZBid5dXYMKyv IDrH1D1vqWAqCF0ffBdi65TsIhSUA0vM8YyT+vgFxBqH/9ndGwbzo566CElh7CCmSgnF c2ecz/MOyHxu6zy1TAPslbDDx/S7d9LGIsGeYBouk5g1iWnbMIt3QsW1vbL4LHzgEUM4 41fXnCLlaXsnLXz9RxEpjws1G0wgFdtSEp/i0fWquinL7IkcrNCl/SNBXQkdkeqUeIlL Y3uA== 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 u16-v6si17503769pgv.180.2018.08.14.10.49.23; Tue, 14 Aug 2018 10:49:38 -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 S2403841AbeHNUfp (ORCPT + 99 others); Tue, 14 Aug 2018 16:35:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32794 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390379AbeHNUfp (ORCPT ); Tue, 14 Aug 2018 16:35:45 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4AF4FCB5; Tue, 14 Aug 2018 17:47:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Michal Hocko , Andrew Morton , Andy Lutomirski , Laura Abbott , Rasmus Villemoes , Mel Gorman , Linus Torvalds , "Srivatsa S. Bhat" , Srinidhi Rao Subject: [PATCH 4.4 04/43] fork: unconditionally clear stack on fork Date: Tue, 14 Aug 2018 19:17:40 +0200 Message-Id: <20180814171517.334471891@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171517.014285600@linuxfoundation.org> References: <20180814171517.014285600@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit e01e80634ecdde1dd113ac43b3adad21b47f3957 upstream. One of the classes of kernel stack content leaks[1] 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. In the face of stack content exposure flaws, those contents can leak to userspace. Fixing this will make the kernel no longer vulnerable to these flaws, 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 and after: Run times: 159.31 157.34 156.71 158.15 160.81 Mean: 158.46 Std Dev: 1.46 Instead of making this a build or runtime config, Andy Lutomirski recommended this just be enabled by default. [1] A noisy search for many kinds of stack content leaks can be seen here: https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=linux+kernel+stack+leak I did some more with perf and cycle counts on running 100,000 execs of /bin/true. before: Cycles: 218858861551 218853036130 214727610969 227656844122 224980542841 Mean: 221015379122.60 Std Dev: 4662486552.47 after: Cycles: 213868945060 213119275204 211820169456 224426673259 225489986348 Mean: 217745009865.40 Std Dev: 5935559279.99 It continues to look like it's faster, though the deviation is rather wide, but I'm not sure what I could do that would be less noisy. I'm open to ideas! Link: http://lkml.kernel.org/r/20180221021659.GA37073@beast Signed-off-by: Kees Cook Acked-by: Michal Hocko Reviewed-by: Andrew Morton Cc: Andy Lutomirski Cc: Laura Abbott Cc: Rasmus Villemoes Cc: Mel Gorman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds [ Srivatsa: Backported to 4.4.y ] Signed-off-by: Srivatsa S. Bhat Reviewed-by: Srinidhi Rao Signed-off-by: Greg Kroah-Hartman --- include/linux/thread_info.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -55,11 +55,7 @@ extern long do_no_restart_syscall(struct #ifdef __KERNEL__ -#ifdef CONFIG_DEBUG_STACK_USAGE -# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) -#else -# define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK) -#endif +#define THREADINFO_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) /* * flag set/clear/test wrappers