From nobody Thu Jan 30 17:42:04 2025 Received: from mail15.out.titan.email (mail15.out.titan.email [3.64.226.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05C431CBE95 for ; Thu, 23 Jan 2025 22:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.64.226.209 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670302; cv=none; b=iaddVoFY/lCVPgIsHXfzSYWJcoo0xbqlMgAPnuu1ObX549fXyJah7OagSEkKLNKoeD7SBtjMPNOymWOkoymrFQHgdleuADQPyNy8SBYjTDYn7u+UQhDpdlrIgUNccJnn8kaXbFdDn8xxg+hw0yTkpacwjmVWjSfZga2kWAAt24Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670302; c=relaxed/simple; bh=AB+mmaXt7qGEW2WBJZAyCRpDhmRf7S/C4nkaGQVaxq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jYgUhn0WlYwlkoFQJMboZAVezN/ECVtCuTbGrwWVgsC6T5ZihJudXATVkiu4e27PpZpf6gKJTqCdbuvAETm74wgaYUpE9mbDKlSMYuFCE6urxVUwo0NyZwym0dOSxyA6pI8+74vNtLrYE7dsUvnzMzhrr/aoN5WWUNOpKxFFo7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net; spf=pass smtp.mailfrom=techsingularity.net; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b=aq/s7EYj; arc=none smtp.client-ip=3.64.226.209 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b="aq/s7EYj" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id 2D8A7A003D; Thu, 23 Jan 2025 22:11:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=VWeq9rkukUyqf9ybH2ttB19u6OPJ/p54PCmlZ5v3Sl4=; c=relaxed/relaxed; d=techsingularity.net; h=from:references:to:message-id:cc:subject:date:in-reply-to:mime-version:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737670298; v=1; b=aq/s7EYjyVGhjPTYAQhId0qrGoKCDOZciZuVD+HniiGOeudil6YrzrwYAuMASZU8EIEBlrzP aktjqsOnhXD5RVHNhENa+eW/XfgZ2La509sPuZ6/Tx7mEU1bNvrSCci0IJe4XltVjiHyNue2x0z NDJJ1tEEAyg8KraHqGP2hlvk= Received: from mail.blacknight.com (ip-84-203-196-66.broadband.digiweb.ie [84.203.196.66]) by smtp-out0101.titan.email (Postfix) with ESMTPA id 9AEE2A0015; Thu, 23 Jan 2025 22:11:37 +0000 (UTC) Feedback-ID: :mgorman@techsingularity.net:techsingularity.net:flockmailId From: Mel Gorman To: Kees Cook Cc: Daniel Micay , Paul Moore , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Mel Gorman Subject: [PATCH 1/4] mm: security: Move hardened usercopy under 'Kernel hardening options' Date: Thu, 23 Jan 2025 22:11:12 +0000 Message-ID: <20250123221115.19722-2-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250123221115.19722-1-mgorman@techsingularity.net> References: <20250123221115.19722-1-mgorman@techsingularity.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-F-Verdict: SPFVALID X-Titan-Src-Out: 1737670298075006878.9138.5320540698317593988@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=6792be9a a=jU4EnjUUC1PH4wSjvv7Pww==:117 a=jU4EnjUUC1PH4wSjvv7Pww==:17 a=CEWIc4RMnpUA:10 a=R_Myd5XaAAAA:8 a=xVhDTqbCAAAA:8 a=KkbEisfxgXDdCi-76G0A:9 a=L2g4Dz8VuBQ37YGmWQah:22 a=GrmWmAYt4dzCMttCBZOh:22 X-Virus-Scanned: ClamAV using ClamSMTP Content-Type: text/plain; charset="utf-8" There is a submenu for 'Kernel hardening options' under "Security". Move HARDENED_USERCOPY under the hardening options as it is clearly related. Signed-off-by: Mel Gorman Acked-by: Paul Moore --- security/Kconfig | 12 ------------ security/Kconfig.hardening | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/security/Kconfig b/security/Kconfig index 28e685f53bd1..fe7346dc4bc3 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -159,18 +159,6 @@ config LSM_MMAP_MIN_ADDR this low address space will need the permission specific to the systems running LSM. =20 -config HARDENED_USERCOPY - bool "Harden memory copies between kernel and userspace" - imply STRICT_DEVMEM - help - This option checks for obviously wrong memory regions when - copying memory to/from the kernel (via copy_to_user() and - copy_from_user() functions) by rejecting memory ranges that - are larger than the specified heap object, span multiple - separately allocated pages, are not on the process stack, - or are part of the kernel text. This prevents entire classes - of heap overflow exploits and similar kernel memory exposures. - config FORTIFY_SOURCE bool "Harden common str/mem functions against buffer overflows" depends on ARCH_HAS_FORTIFY_SOURCE diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening index c9d5ca3d8d08..9088d613d519 100644 --- a/security/Kconfig.hardening +++ b/security/Kconfig.hardening @@ -279,6 +279,22 @@ config ZERO_CALL_USED_REGS =20 endmenu =20 +menu "Bounds checking" + +config HARDENED_USERCOPY + bool "Harden memory copies between kernel and userspace" + imply STRICT_DEVMEM + help + This option checks for obviously wrong memory regions when + copying memory to/from the kernel (via copy_to_user() and + copy_from_user() functions) by rejecting memory ranges that + are larger than the specified heap object, span multiple + separately allocated pages, are not on the process stack, + or are part of the kernel text. This prevents entire classes + of heap overflow exploits and similar kernel memory exposures. + +endmenu + menu "Hardening of kernel data structures" =20 config LIST_HARDENED --=20 2.43.0 From nobody Thu Jan 30 17:42:04 2025 Received: from mail19.out.titan.email (mail19.out.titan.email [3.64.226.213]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F3D21CDA0B for ; Thu, 23 Jan 2025 22:11:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.64.226.213 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670312; cv=none; b=VGJKx/mdql5h2IIE1flHiYlmOCTKnIuc4BA0X+PS+yznmuHuq7QHK/RcdfbjwD7GcYwn3YKkbJkLJ+YSh6rnrW/qbxiG5V9n9FTjW5v4JfOYu/OG7o0/RXIRT2QzMuig/EFvXyFDBPl7k8ZN3KQciEpfbfhJRim5ATfw/tEtm0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670312; c=relaxed/simple; bh=7F+5jvc+5P/sz5xc4yVqe1Jr3GI4/itvnxM8dwxDcPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yt2NAN+zgs4bylzkxkaTOHj4aXWNCq9mGfrtpqZAa8zJ+lFAIWNdWM9k/V2mbNrbbTO5xVYdCBIMjsBmJLdgOnC3TXvIZ4Sy0VvHkvY3dJALvd7eKEYMkTv5NjIDVmbfsEew4YH5/bBu11LH+uVC5/+MBb4utxosXuk0dCaNU6E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net; spf=pass smtp.mailfrom=techsingularity.net; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b=CRUij8AZ; arc=none smtp.client-ip=3.64.226.213 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b="CRUij8AZ" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id B641DA0015; Thu, 23 Jan 2025 22:11:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=LDgPNBesSofxnnV2IL91tTTGVUzCXnETfSmwHDCUeSU=; c=relaxed/relaxed; d=techsingularity.net; h=in-reply-to:references:to:subject:message-id:from:cc:date:mime-version:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737670308; v=1; b=CRUij8AZFPt0Exj3zpOfp3z8RqOCTxBGGzAHQlm722e38XuRDcnIEhEO8yoCho8zwEUQ6BmY mZFdCVp6Axzrsya4tUZFsaRw3nJqqwUzGcLx4ATZvAa52xgUwyr4E/PLxiV4soIAR/ieAwJVx6D Q6eUtXl7g/YuKhLdAyxH0N34= Received: from mail.blacknight.com (ip-84-203-196-66.broadband.digiweb.ie [84.203.196.66]) by smtp-out0101.titan.email (Postfix) with ESMTPA id 3FAE2A0010; Thu, 23 Jan 2025 22:11:48 +0000 (UTC) Feedback-ID: :mgorman@techsingularity.net:techsingularity.net:flockmailId From: Mel Gorman To: Kees Cook Cc: Daniel Micay , Paul Moore , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Mel Gorman Subject: [PATCH 2/4] mm: security: Allow default HARDENED_USERCOPY to be set at compile time Date: Thu, 23 Jan 2025 22:11:13 +0000 Message-ID: <20250123221115.19722-3-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250123221115.19722-1-mgorman@techsingularity.net> References: <20250123221115.19722-1-mgorman@techsingularity.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-F-Verdict: SPFVALID X-Titan-Src-Out: 1737670308635311287.9138.9018554698350676250@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=6792bea4 a=jU4EnjUUC1PH4wSjvv7Pww==:117 a=jU4EnjUUC1PH4wSjvv7Pww==:17 a=CEWIc4RMnpUA:10 a=R_Myd5XaAAAA:8 a=0z80O7jHjOjBg2F2ajAA:9 a=L2g4Dz8VuBQ37YGmWQah:22 X-Virus-Scanned: ClamAV using ClamSMTP Content-Type: text/plain; charset="utf-8" HARDENED_USERCOPY defaults to on if enabled at compile time. Allow hardened_usercopy=3D default to be set at compile time similar to init_on_alloc=3D and init_on_free=3D. The intent is that hardening options that can be disabled at runtime can set their default at build time. Signed-off-by: Mel Gorman --- Documentation/admin-guide/kernel-parameters.txt | 4 +++- mm/usercopy.c | 3 ++- security/Kconfig.hardening | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 3872bc6ec49d..5d759b20540a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1773,7 +1773,9 @@ allocation boundaries as a proactive defense against bounds-checking flaws in the kernel's copy_to_user()/copy_from_user() interface. - on Perform hardened usercopy checks (default). + The default is determined by + CONFIG_HARDENED_USERCOPY_DEFAULT_ON. + on Perform hardened usercopy checks. off Disable hardened usercopy checks. =20 hardlockup_all_cpu_backtrace=3D diff --git a/mm/usercopy.c b/mm/usercopy.c index 83c164aba6e0..4cf33305347a 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -255,7 +255,8 @@ void __check_object_size(const void *ptr, unsigned long= n, bool to_user) } EXPORT_SYMBOL(__check_object_size); =20 -static bool enable_checks __initdata =3D true; +static bool enable_checks __initdata =3D + IS_ENABLED(CONFIG_HARDENED_USERCOPY_DEFAULT_ON); =20 static int __init parse_hardened_usercopy(char *str) { diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening index 9088d613d519..3a941cc45396 100644 --- a/security/Kconfig.hardening +++ b/security/Kconfig.hardening @@ -293,6 +293,14 @@ config HARDENED_USERCOPY or are part of the kernel text. This prevents entire classes of heap overflow exploits and similar kernel memory exposures. =20 +config HARDENED_USERCOPY_DEFAULT_ON + bool "Harden memory copies by default" + depends on HARDENED_USERCOPY + default HARDENED_USERCOPY + help + This has the effect of setting "hardened_usercopy=3Don" on the kernel + command line. This can be disabled with "hardened_usercopy=3Doff". + endmenu =20 menu "Hardening of kernel data structures" --=20 2.43.0 From nobody Thu Jan 30 17:42:04 2025 Received: from mail12.out.titan.email (mail12.out.titan.email [18.198.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCE151CD205; Thu, 23 Jan 2025 22:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.198.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670323; cv=none; b=jcMK+dnDMA6BRZTFRPpTYbqOnrTw6UcdeB9I+WsQl1kzCadtLUFBRCJQx0SRgKhl7DoIYKU73It2+JYQLb36cyYwz244EWoIXjMeNc+S0Wcq7aASzOqSeMVYlei+/OQfV7+TJyg5p1LNtvrCR8PzouTs5VBqRFHy7aR2Jc4cT6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670323; c=relaxed/simple; bh=NmDNIslrbQ1hpZ/kK7MlMNwPpWf2dsldVIU9YB7wVNE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HiAs7nFTd0s0capbobTM4z3/c18tDf1hFUk1JNjNMgxyUKUjU+KYiyIp0brwopHsP+AwFyn63TjHfmUiIYMJv+2WkcB/c+vNF2/hhXlPen9O98G3SevG10/1Gf6k+FJty/1sGtdxNCQR89lfmlG4q9d2ZMRygPPHuUVTefDjj2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net; spf=pass smtp.mailfrom=techsingularity.net; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b=iTAmP+6D; arc=none smtp.client-ip=18.198.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b="iTAmP+6D" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id 3EA13A0015; Thu, 23 Jan 2025 22:11:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=BeyJBSn5Hh/oeJpBDKyeJyIArhFqMyBpnM+5KuJxZAI=; c=relaxed/relaxed; d=techsingularity.net; h=in-reply-to:mime-version:message-id:subject:date:references:from:to:cc:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737670319; v=1; b=iTAmP+6DkuqUEn4XJWA56m6yiaklCpRFR3kthmW9ufn9wF8VFnvzf3okiLIb9dsmOiT00fJ9 j4CLNN8UJ37nSL2dnLuZASHPurDV2GFHTz2XFUVZPeqfoDOcEv4tjR8xSEDgWYvMFF8AI6wNy+J gfJiIDzbFaw7fvaxcvXjSNCw= Received: from mail.blacknight.com (ip-84-203-196-66.broadband.digiweb.ie [84.203.196.66]) by smtp-out0101.titan.email (Postfix) with ESMTPA id C5EFAA0044; Thu, 23 Jan 2025 22:11:58 +0000 (UTC) Feedback-ID: :mgorman@techsingularity.net:techsingularity.net:flockmailId From: Mel Gorman To: Kees Cook Cc: Daniel Micay , Paul Moore , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Mel Gorman Subject: [PATCH 3/4] mm: security: Check early if HARDENED_USERCOPY is enabled Date: Thu, 23 Jan 2025 22:11:14 +0000 Message-ID: <20250123221115.19722-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250123221115.19722-1-mgorman@techsingularity.net> References: <20250123221115.19722-1-mgorman@techsingularity.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-F-Verdict: SPFVALID X-Titan-Src-Out: 1737670319143325168.9138.7788354316419647953@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=6792beaf a=jU4EnjUUC1PH4wSjvv7Pww==:117 a=jU4EnjUUC1PH4wSjvv7Pww==:17 a=CEWIc4RMnpUA:10 a=VwQbUJbxAAAA:8 a=R_Myd5XaAAAA:8 a=4yXJT0XmbIIbJQ27IpEA:9 a=L2g4Dz8VuBQ37YGmWQah:22 X-Virus-Scanned: ClamAV using ClamSMTP Content-Type: text/plain; charset="utf-8" HARDENED_USERCOPY is checked within a function so even if disabled, the function overhead still exists. Move the static check inline. This is at best a micro-optimisation and any difference in performance was within noise but it is relatively consistent with the init_on_* implementations. Suggested-by: Kees Cook Signed-off-by: Mel Gorman --- include/linux/thread_info.h | 8 +++++++- mm/usercopy.c | 13 +++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index cf2446c9c30d..09fc241a45f7 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -221,11 +221,17 @@ static inline int arch_within_stack_frames(const void= * const stack, extern void __check_object_size(const void *ptr, unsigned long n, bool to_user); =20 +DECLARE_STATIC_KEY_MAYBE(CONFIG_HARDENED_USERCOPY_DEFAULT_ON, + validate_usercopy_range); + static __always_inline void check_object_size(const void *ptr, unsigned lo= ng n, bool to_user) { - if (!__builtin_constant_p(n)) + if (!__builtin_constant_p(n) && + static_branch_maybe(CONFIG_HARDENED_USERCOPY_DEFAULT_ON, + &validate_usercopy_range)) { __check_object_size(ptr, n, to_user); + } } #else static inline void check_object_size(const void *ptr, unsigned long n, diff --git a/mm/usercopy.c b/mm/usercopy.c index 4cf33305347a..a1193bdabb16 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -201,7 +201,9 @@ static inline void check_heap_object(const void *ptr, u= nsigned long n, } } =20 -static DEFINE_STATIC_KEY_FALSE_RO(bypass_usercopy_checks); +DEFINE_STATIC_KEY_MAYBE_RO(CONFIG_HARDENED_USERCOPY_DEFAULT_ON, + validate_usercopy_range); +EXPORT_SYMBOL(validate_usercopy_range); =20 /* * Validates that the given object is: @@ -212,9 +214,6 @@ static DEFINE_STATIC_KEY_FALSE_RO(bypass_usercopy_check= s); */ void __check_object_size(const void *ptr, unsigned long n, bool to_user) { - if (static_branch_unlikely(&bypass_usercopy_checks)) - return; - /* Skip all tests if size is zero. */ if (!n) return; @@ -270,8 +269,10 @@ __setup("hardened_usercopy=3D", parse_hardened_usercop= y); =20 static int __init set_hardened_usercopy(void) { - if (enable_checks =3D=3D false) - static_branch_enable(&bypass_usercopy_checks); + if (enable_checks) + static_branch_enable(&validate_usercopy_range); + else + static_branch_disable(&validate_usercopy_range); return 1; } =20 --=20 2.43.0 From nobody Thu Jan 30 17:42:04 2025 Received: from mail15.out.titan.email (mail15.out.titan.email [3.64.226.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 369E81CEACB for ; Thu, 23 Jan 2025 22:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.64.226.209 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670333; cv=none; b=gr20ym/tEXc4OVEgRWH4CcNcPw+Sd7jujfBZW/kwm2MLeXs0sIeR1oBq8I/4MzpbtnCBNgpJSdgJNxjmgdAC6szai7zKi0Y3z/lQDMSqh3ceKkxb3ES5og+wWnowPAWlPYfkNA5c9iulY58vUJIAniPCe8SoGDL6RQSgILqPyPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670333; c=relaxed/simple; bh=FXnGYN1HLA7oKl4oNnF5ibO9kW/y1hP4Ubr7zJXHLCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A0ePCpCdhFF2Te1ozdt6IdhYli+RgEPBiFmWU3RT5MAs9oKa4pTnG1e7jH58RsAYcqw2t+rH7u877Xgws0zIi4GR0UR5+zFTxxyc422A3/JMhTDGcvMV44jCRcwicSiM8tgiIiAuUle9J6Qjn1nMzyxNM8mVQznPylcDplRf1QM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net; spf=pass smtp.mailfrom=techsingularity.net; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b=DG8o9ysz; arc=none smtp.client-ip=3.64.226.209 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=techsingularity.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=techsingularity.net header.i=@techsingularity.net header.b="DG8o9ysz" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id BD949A0015; Thu, 23 Jan 2025 22:12:09 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/ztBC38zol6aAkdXqs+b9CijeIaCMsYQyn8IPOdL8aY=; c=relaxed/relaxed; d=techsingularity.net; h=to:cc:message-id:in-reply-to:mime-version:from:date:references:subject:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737670329; v=1; b=DG8o9yszbOff1vdwbaD31yZT3dsXx5iPurhZd0IhzZLVVFs1ZzvYkaUbjyCn2UahZCdc4pKT V1jrguBwYzSUvYvm+UVOl/9dkVqbdk3+dKnLE9cJ409oY3G8YDiLrTEqTH2RT70WWE8+iuT+NTy CLVzQpG6+ZuRySB4KTJJREik= Received: from mail.blacknight.com (ip-84-203-196-66.broadband.digiweb.ie [84.203.196.66]) by smtp-out0101.titan.email (Postfix) with ESMTPA id 4D2D0A0010; Thu, 23 Jan 2025 22:12:09 +0000 (UTC) Feedback-ID: :mgorman@techsingularity.net:techsingularity.net:flockmailId From: Mel Gorman To: Kees Cook Cc: Daniel Micay , Paul Moore , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Mel Gorman Subject: [PATCH 4/4] fortify: Move FORTIFY_SOURCE under 'Kernel hardening options' Date: Thu, 23 Jan 2025 22:11:15 +0000 Message-ID: <20250123221115.19722-5-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250123221115.19722-1-mgorman@techsingularity.net> References: <20250123221115.19722-1-mgorman@techsingularity.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-F-Verdict: SPFVALID X-Titan-Src-Out: 1737670329649399389.9138.4356779843527689844@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=6792beb9 a=jU4EnjUUC1PH4wSjvv7Pww==:117 a=jU4EnjUUC1PH4wSjvv7Pww==:17 a=CEWIc4RMnpUA:10 a=NEAV23lmAAAA:8 a=R_Myd5XaAAAA:8 a=xVhDTqbCAAAA:8 a=is8aNrDapYGysjnIDgAA:9 a=L2g4Dz8VuBQ37YGmWQah:22 a=GrmWmAYt4dzCMttCBZOh:22 X-Virus-Scanned: ClamAV using ClamSMTP Content-Type: text/plain; charset="utf-8" FORTIFY_SOURCE is a hardening option both at build and runtime. Move it under 'Kernel hardening options'. Signed-off-by: Mel Gorman Acked-by: Paul Moore --- security/Kconfig | 9 --------- security/Kconfig.hardening | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/security/Kconfig b/security/Kconfig index fe7346dc4bc3..bca84f839fbe 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -159,15 +159,6 @@ config LSM_MMAP_MIN_ADDR this low address space will need the permission specific to the systems running LSM. =20 -config FORTIFY_SOURCE - bool "Harden common str/mem functions against buffer overflows" - depends on ARCH_HAS_FORTIFY_SOURCE - # https://github.com/llvm/llvm-project/issues/53645 - depends on !CC_IS_CLANG || !X86_32 - help - Detect overflows of buffers in common string and memory functions - where the compiler can determine and validate the buffer sizes. - config STATIC_USERMODEHELPER bool "Force all usermode helper calls through a single binary" help diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening index 3a941cc45396..1ce9009c3cc6 100644 --- a/security/Kconfig.hardening +++ b/security/Kconfig.hardening @@ -281,6 +281,15 @@ endmenu =20 menu "Bounds checking" =20 +config FORTIFY_SOURCE + bool "Harden common str/mem functions against buffer overflows" + depends on ARCH_HAS_FORTIFY_SOURCE + # https://github.com/llvm/llvm-project/issues/53645 + depends on !CC_IS_CLANG || !X86_32 + help + Detect overflows of buffers in common string and memory functions + where the compiler can determine and validate the buffer sizes. + config HARDENED_USERCOPY bool "Harden memory copies between kernel and userspace" imply STRICT_DEVMEM --=20 2.43.0