Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp808626ybv; Wed, 5 Feb 2020 15:06:47 -0800 (PST) X-Google-Smtp-Source: APXvYqxtH6YUTqzsysvkibjAQne8AIs1fxEMNvqDRY/W4Rs36YWoxhewuR/NpdMLwmjTcfzjPI7e X-Received: by 2002:a54:4707:: with SMTP id k7mr4609613oik.153.1580944007380; Wed, 05 Feb 2020 15:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580944007; cv=none; d=google.com; s=arc-20160816; b=jumydIGfpFW5qK7hHO2h4rYJkz6WtY07JmZncK1PkXYv0/4JMk8kmEosh9XAmLxXcw CRDNEjC2NhjYKDESMu2gKHXOCSaUXnrDuNDGHtsXWD6JNET14QfwZhbaAVGugPpHBkGl z7VChSbp1FsQG/X9LpqVe//5cZUTxzk5Y8RWsAg+BBjv/Xg7AxTRvMtctmln/l4UC9rB nHu4V+w53o2U5Zt9ko+gkgy3G0WFbaXrN/Kz8wL5Lu1n4js1XVRgpEc3YyUBlzuoPXiZ MjlF3ci7oGV8lgufwJaKpqlS1YHA/4TNAPFM13+BziT8RZoLmDcRP7oCSQ1Ks+WXQWsv 4ZuQ== 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:date:subject:cc:to:from; bh=L94nEjDKKzTX/Jv9Ox7bUdDNKBmz9CZdMh3OAcHthxo=; b=qSJF0OVCqGYkK8oz1MmCPpMdiTQJK+NeZgNX/rk3fu3HJb2axTUGRH/z07wryL8EBh bWoMMEFyBMmhUo28ijXOXs7FLQg1XzVMiGlhgwdJJz2hJOK5HSbgBf09E1k9UxDEKPrE wM3Ov1DccCv12m+n3Ip4dtrMpt7oqHMzbR+t3/1QCpbb/k91785zm+KcoilG0Ogz2cL7 amCHFnzkIbUqronmBVehNPPVU1wqg0ESSlN2pQ0Lm9+JgVJcKUQ6rxS3t+hIXSgV9l5E vulurgQDX9aVzwouTVs+5fQVYTUgGq5vM4UuXQnvElzGjsokkpzGw062Wo5Z2eEjnM5D +l+g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8si1065846oix.109.2020.02.05.15.06.35; Wed, 05 Feb 2020 15:06:47 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727613AbgBEWjp (ORCPT + 99 others); Wed, 5 Feb 2020 17:39:45 -0500 Received: from mga02.intel.com ([134.134.136.20]:60113 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727505AbgBEWjh (ORCPT ); Wed, 5 Feb 2020 17:39:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2020 14:39:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,407,1574150400"; d="scan'208";a="225092448" Received: from unknown (HELO localhost.jf.intel.com) ([10.54.75.26]) by fmsmga007.fm.intel.com with ESMTP; 05 Feb 2020 14:39:36 -0800 From: Kristen Carlson Accardi To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, arjan@linux.intel.com, keescook@chromium.org Cc: rick.p.edgecombe@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Kristen Carlson Accardi Subject: [RFC PATCH 05/11] x86: Makefile: Add build and config option for CONFIG_FG_KASLR Date: Wed, 5 Feb 2020 14:39:44 -0800 Message-Id: <20200205223950.1212394-6-kristen@linux.intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200205223950.1212394-1-kristen@linux.intel.com> References: <20200205223950.1212394-1-kristen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow user to select CONFIG_FG_KASLR if dependencies are met. Change the make file to build with -ffunction-sections if CONFIG_FG_KASLR Signed-off-by: Kristen Carlson Accardi --- Makefile | 4 ++++ arch/x86/Kconfig | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Makefile b/Makefile index c50ef91f6136..41438a921666 100644 --- a/Makefile +++ b/Makefile @@ -846,6 +846,10 @@ ifdef CONFIG_LIVEPATCH KBUILD_CFLAGS += $(call cc-option, -flive-patching=inline-clone) endif +ifdef CONFIG_FG_KASLR +KBUILD_CFLAGS += -ffunction-sections +endif + # arch Makefile may override CC so keep this after arch Makefile is included NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5e8949953660..b4b1b17076a8 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2208,6 +2208,19 @@ config RANDOMIZE_BASE If unsure, say Y. +config FG_KASLR + bool "Finer grained Kernel Address Space Layout Randomization" + depends on $(cc-option, -ffunction-sections) + depends on RANDOMIZE_BASE && X86_64 + help + This option improves the randomness of the kernel text + over basic Kernel Address Space Layout Randomization (KASLR) + by reordering the kernel text at boot time. This feature + uses information generated at compile time to re-layout the + kernel text section at boot time at function level granularity. + + If unsure, say N. + # Relocation on x86 needs some additional build support config X86_NEED_RELOCS def_bool y -- 2.24.1