From patchwork Thu Jan 23 22:11:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13948700 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 45DEB1CBE95 for ; Thu, 23 Jan 2025 22:11:44 +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=1737670308; cv=none; b=GTEXK41JKkCcEJGgF1NsXQEcyevj47srnfNT8Ye0hmesRd1wJAlQKakm7vwhpK2QuFDJKDRWj913NTaMsytDViQucxiE6nE2F2mf7OSRbSResBy5ZzhQFa8RZYhpyDa9iirtetBuU/tGDfWLjAzQOZbAla/XVbTGTDlrJGnpkTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670308; c=relaxed/simple; bh=AB+mmaXt7qGEW2WBJZAyCRpDhmRf7S/C4nkaGQVaxq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZGguPX1IK2H+yaCAOw9r/psGPB5EbIYex3vjtGx/bqXDkUsk7zxdBdFHoHqSrtOwRCNBhPFdYAM3xpEUTWJcm9LtblX0EZiXEv9KasIsG+J4k3sUMn/AEhXnP1HJvceL908tQhnSwt4T2UqQpE0YbFAEO8qhQaLKlFwyqQW9ZYA= 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.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="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-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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. -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 endmenu +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" config LIST_HARDENED From patchwork Thu Jan 23 22:11:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13948701 Received: from mail17.out.titan.email (mail17.out.titan.email [3.64.226.211]) (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 4F8691CD1FD for ; Thu, 23 Jan 2025 22:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.64.226.211 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670318; cv=none; b=r94oSmMUPFf5PpKW0AJkdel8YM5ND68eG4ZertpP9hPtajMEzcGk9dNJq9hSVwQdLeQcgXRr6NzKR52xp58gNonVrENXMkwX75JeotbktbPwdaNaU0mKdv3fvRRp18IMGLh6RadpchwwW00Gd75w3d209JKLpBPsmCaRQtcWFVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670318; c=relaxed/simple; bh=7F+5jvc+5P/sz5xc4yVqe1Jr3GI4/itvnxM8dwxDcPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bz4ljIAr9PUh16KLPX3Xxr0UWUCxVKThMFRCdij0IJk9VfB+tiOOC8mMnL1RoPqz2GptTFLiFcQmKcGRJvFLbVfxeI5e2jOmOY6D8sAP2PFquHS+ZC8PEqjpwz1vxMOzuYXsSYR6KuikfNVuahciGOAgeNaVTGFbI0gmxy35HhE= 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.211 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-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 HARDENED_USERCOPY defaults to on if enabled at compile time. Allow hardened_usercopy= default to be set at compile time similar to init_on_alloc= and init_on_free=. 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/Documentation/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. hardlockup_all_cpu_backtrace= 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); -static bool enable_checks __initdata = true; +static bool enable_checks __initdata = + IS_ENABLED(CONFIG_HARDENED_USERCOPY_DEFAULT_ON); 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. +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=on" on the kernel + command line. This can be disabled with "hardened_usercopy=off". + endmenu menu "Hardening of kernel data structures" From patchwork Thu Jan 23 22:11:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13948702 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-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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); +DECLARE_STATIC_KEY_MAYBE(CONFIG_HARDENED_USERCOPY_DEFAULT_ON, + validate_usercopy_range); + static __always_inline void check_object_size(const void *ptr, unsigned long 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, unsigned long n, } } -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); /* * Validates that the given object is: @@ -212,9 +214,6 @@ static DEFINE_STATIC_KEY_FALSE_RO(bypass_usercopy_checks); */ 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=", parse_hardened_usercopy); static int __init set_hardened_usercopy(void) { - if (enable_checks == 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; } From patchwork Thu Jan 23 22:11:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13948703 Received: from mail18.out.titan.email (mail18.out.titan.email [3.64.226.212]) (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 416851CDA0B for ; Thu, 23 Jan 2025 22:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.64.226.212 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670340; cv=none; b=c35OfAxasS7Af0cuzCYS8/x4kKZZ5IBxmOyKHNy1vO653FfSe5w17J0VKahTHV3G9vAj42HLeNrBKZjORlrVULXwu0Q8BK641PYk1E3ogTYOQgQRZuPth8QlWuTwCGxzA8nX0BLp3tgnjeYq/dAjtbWXsWG148imnEjRLKIlgWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737670340; c=relaxed/simple; bh=FXnGYN1HLA7oKl4oNnF5ibO9kW/y1hP4Ubr7zJXHLCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=usFHl33xeOImRauObX96q7C5EZNTZ2U+VKMCIBNxN6A3CPcCBRn6ibfnAYTXcZGOmYQDiA7u+klQdalwYdZ4nlTr86ELlYiWmzdOWrA4XCTpSSkZ+52guM2AzlLTY6u8l0dIse9GEzji3qZ08ZH2QVqTcFXc4pwy1nmGJKJ2nvw= 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.212 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-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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. -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 menu "Bounds checking" +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