From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B24BDC433E0 for ; Mon, 22 Jun 2020 19:41:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6CD9820708 for ; Mon, 22 Jun 2020 19:41:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="j9dDq1D5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CD9820708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB2CC8D0003; Mon, 22 Jun 2020 15:41:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C63D86B0033; Mon, 22 Jun 2020 15:41:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7A3D8D0003; Mon, 22 Jun 2020 15:41:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id 9ED9A6B0030 for ; Mon, 22 Jun 2020 15:41:06 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 26FE78249980 for ; Mon, 22 Jun 2020 19:41:06 +0000 (UTC) X-FDA: 76957866132.13.swing31_1c0eba726e35 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id E8D7118140B60 for ; Mon, 22 Jun 2020 19:41:05 +0000 (UTC) X-HE-Tag: swing31_1c0eba726e35 X-Filterd-Recvd-Size: 4764 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 22 Jun 2020 19:41:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=Tp0FvdeMkD0In5KDxlOtCuC1dG7VeQNXQJo7C/sHai0=; b=j9dDq1D51Tu300HC9aIqfHqXrc 5GsiBOxLP8aOZOMTrBrw86raw9grYGO9RU3QoRxrQjM3MbPncZPIaJD7nCx/iEAoDicUJ488gskqF eKwEUyWCBQf64/YzbovPa0zFNLCfqtjJnlx19cxHCWZ8896i6pjLHmHKaIqmqVGsz0kSFlRQzk6NS mxeKG9aoT9a5UtJ2faJ1aBOjtDzXAhrIfw/e8DdYA26SNjVODiL+Jq5iHY/kkANiCJ7NtGhAFQ7vv ia9YZKF88jbmGSh5r/VTE2oYtypW6d/g9eZaFjimuuiyH4z3nX4+kaRhyxw6GQIaL3PT4DMvV0w4d aYc+m9vA==; Received: from [2601:1c0:6280:3f0::19c2] by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnSJL-0002yS-CW; Mon, 22 Jun 2020 19:40:56 +0000 Subject: Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall To: Kees Cook , Thomas Gleixner Cc: Elena Reshetova , x86@kernel.org, Andy Lutomirski , Peter Zijlstra , Catalin Marinas , Will Deacon , Mark Rutland , Alexander Potapenko , Alexander Popov , Ard Biesheuvel , Jann Horn , kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20200622193146.2985288-1-keescook@chromium.org> <20200622193146.2985288-4-keescook@chromium.org> From: Randy Dunlap Message-ID: <87a7b943-ed15-8521-773e-c182a37ee61e@infradead.org> Date: Mon, 22 Jun 2020 12:40:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200622193146.2985288-4-keescook@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E8D7118140B60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 6/22/20 12:31 PM, Kees Cook wrote: > This provides the ability for architectures to enable kernel stack base > address offset randomization. This feature is controlled by the boot > param "randomize_kstack_offset=on/off", with its default value set by > CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT. > > Co-developed-by: Elena Reshetova > Signed-off-by: Elena Reshetova > Link: https://lore.kernel.org/r/20190415060918.3766-1-elena.reshetova@intel.com > Signed-off-by: Kees Cook > --- > Makefile | 4 ++++ > arch/Kconfig | 23 ++++++++++++++++++ > include/linux/randomize_kstack.h | 40 ++++++++++++++++++++++++++++++++ > init/main.c | 23 ++++++++++++++++++ > 4 files changed, 90 insertions(+) > create mode 100644 include/linux/randomize_kstack.h Hi, Please add documentation for the new kernel boot parameter to Documentation/admin-guide/kernel-parameters.txt. > diff --git a/arch/Kconfig b/arch/Kconfig > index 1ea61290900a..1f52c9cfefca 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -883,6 +883,29 @@ config VMAP_STACK > virtual mappings with real shadow memory, and KASAN_VMALLOC must > be enabled. > > +config HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET > + def_bool n > + help > + An arch should select this symbol if it can support kernel stack > + offset randomization with calls to add_random_kstack_offset() > + during syscall entry and choose_random_kstack_offset() during > + syscall exit. Downgrading of -fstack-protector-strong to > + -fstack-protector should also be applied to the entry code and > + closely examined, as the artificial stack bump looks like an array > + to the compiler, so it will attempt to add canary checks regardless > + of the static branch state. > + > +config RANDOMIZE_KSTACK_OFFSET_DEFAULT > + bool "Randomize kernel stack offset on syscall entry" > + depends on HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET > + help > + The kernel stack offset can be randomized (after pt_regs) by > + roughly 5 bits of entropy, frustrating memory corruption > + attacks that depend on stack address determinism or > + cross-syscall address exposures. This feature is controlled > + by kernel boot param "randomize_kstack_offset=on/off", and this > + config chooses the default boot state. thanks. -- ~Randy