From patchwork Wed Jan 22 17:19:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13947578 Received: from mail13.out.titan.email (mail13.out.titan.email [18.198.78.245]) (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 9F487215173 for ; Wed, 22 Jan 2025 17:29:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.198.78.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737566965; cv=none; b=G92tsdEEd5h62I8SMONJiO9mJMmnVk0+nr1F0SgKKlPdpSK/Xi5EHIxQwS+axPGft2EVDlIxGa/XDSJ0hMoShiQpum9bPFtTZkyh4aEFG1pglDbSgyX7rs0e2lPWMOpbADSMgA6K+lXjvKgZtZgvugBDu0Di6inykwll3Jr9pbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737566965; c=relaxed/simple; bh=AB+mmaXt7qGEW2WBJZAyCRpDhmRf7S/C4nkaGQVaxq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JitK53l2zJFw0LVSGnG0U3ZosWxp0+v3HCbqhwRbIiaopIWv06Xl3AWK+M7t3w+OZJz8OLNojSHPRRJ3yE9G/weY6/KGQHovKJ0vo3qAaSKbAfNPsHvSiLflbGbws4LqhmYFroBpsKCEUYceq4Zl1OXzR0hS7vEOkUJ9TsylQBs= 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=XLhOb0vr; arc=none smtp.client-ip=18.198.78.245 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="XLhOb0vr" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id 24322A0150; Wed, 22 Jan 2025 17:19:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=VWeq9rkukUyqf9ybH2ttB19u6OPJ/p54PCmlZ5v3Sl4=; c=relaxed/relaxed; d=techsingularity.net; h=from:to:cc:date:references:mime-version:subject:message-id:in-reply-to:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737566388; v=1; b=XLhOb0vrs4TMeU2TNsPr5AZQeARDCWVE2GbqaujkS+juHenwZyNyQvYHyz2KIkg6m0pac2w2 vXGeKGmzbeVK0qZFX88ZBaSu18fiKoQTPDzP0XSh3IisDQJ95wUJZHOVS/pr3qYH78eQA7l/0Hl cz6SWIsAdvDs9mwZHnUlt2uA= 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 8DB7BA0004; Wed, 22 Jan 2025 17:19:47 +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: Wed, 22 Jan 2025 17:19:22 +0000 Message-ID: <20250122171925.25472-2-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250122171925.25472-1-mgorman@techsingularity.net> References: <20250122171925.25472-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: 1737566388028479881.9138.5572320255195962264@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=679128b4 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 Wed Jan 22 17:19:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13947554 Received: from mail13.out.titan.email (mail13.out.titan.email [18.198.78.245]) (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 D40DF21505F; Wed, 22 Jan 2025 17:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.198.78.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737566408; cv=none; b=e66ls4YZ1fttG6UR/6iCZ0wX9OVaSB4Fe0E22ywogTGZ2A9WwN5KgUNEmRRKmh4ylj42ncHfRodTyYaeHkqCotBDlRAoSD8gVXZtAu9WHNj/xPseWledzUXORyV3N5lPiJ6A7M5LuhvuyczNjMcmH9Rqu7sXMvhjAPISBK21/gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737566408; c=relaxed/simple; bh=SuG5hvAQgjxhXm9LGjN9dYWNlAAqBwyJpF59KcRtkR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PLHhrSYdzweam+Kgqe4Ix0NhfIC4ykOfbTPU9aKHICkIE6eicDhvhTLu7IrW88e28uIdqtWMK6RA0jEuT2LKG9m5FRG/JaEoheVP+ddZn8vENT+V+suxolAaHxfGlDVwo7fMThB4gLgUkSvg5Rlp8JHjGfU9cWw6pjfBKKKoNLc= 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=Bpnsrt+X; arc=none smtp.client-ip=18.198.78.245 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="Bpnsrt+X" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id A0C49A015A; Wed, 22 Jan 2025 17:19:58 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Z2jYOWM8hUV6J3bzYS5e2M9sLIUUWbq7B6uKhS/GsCs=; c=relaxed/relaxed; d=techsingularity.net; h=mime-version:from:to:cc:message-id:in-reply-to:subject:date:references:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737566398; v=1; b=Bpnsrt+XYCpXjb4LOgVfgwsOpx/9Q7ZydDgH4UuJRheEiW3AHJAIB4mclRxQbwCFWzYu9/E9 LDApje3CjvtfkI2u0OXsR03GQyfT1EVJNCYQ1GFK0DiRF2s/Hz3JEDWgvcr5C6+2ZVFSxfFc4VE NgWkQ5xP5Bw789VU4DxEV+40= 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 33020A0008; Wed, 22 Jan 2025 17:19: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 2/4] mm: security: Allow default HARDENED_USERCOPY to be set at compile time Date: Wed, 22 Jan 2025 17:19:23 +0000 Message-ID: <20250122171925.25472-3-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250122171925.25472-1-mgorman@techsingularity.net> References: <20250122171925.25472-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: 1737566398543734204.9138.2594461423631213783@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=679128be 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..adcc260839c7 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 n + 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 Wed Jan 22 17:19:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13947555 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 BD2F42153C6 for ; Wed, 22 Jan 2025 17:20:10 +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=1737566412; cv=none; b=DcC/186H4zVbIgD3LLkCdNb7hcHwSWogvhX4hqwv8yM7D38Yl3ZCImbq/bLId8Sac08WHnmt3pArmcfL4/ScFKWhptWJvIHmiiPs3DC1kwDDw3rmx5fY2SlREg2csh4GP8O4449ijVIhLiKDBNuefy7W7iUmOSSqGI4fdrlB7cI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737566412; c=relaxed/simple; bh=6su9UrgLxfeY+Y7fVw1qRBBhgcWMQoVDEU8h6Q2G298=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fs4o+Vc9W4YRKO9OPfpa4qiZ2WUnkUUrYv3v/eIPRtDWOsmTXi9duGAetVrsTqLmJx2adq3X3bUG4k4EgriPb+ZDYhFPG+4zRn9L+dkbnHNT14Z0WNEbE7Qqln8mQ4+1/JDm4DcJhchNABBHQgBYj410obeXyngtjhhv8e/rUtQ= 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=Ey8CgysZ; 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="Ey8CgysZ" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id 374A1A00D9; Wed, 22 Jan 2025 17:20:09 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Y09jPq5GH+jLn+U5pAD6Zl5SbOMjMXu/OVlJSNYhum8=; c=relaxed/relaxed; d=techsingularity.net; h=subject:from:date:message-id:in-reply-to:references:mime-version:cc:to:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737566409; v=1; b=Ey8CgysZ9TAeWFDrjBCTOlZ7Wb1Knd7+3IimYe6w3M29wDeI+Io3YkM84i2YHyvXdCdd3NsL McJgYyTjl1Uccy6Wz6BRxz3e3hj/h+h62Z+qUDxn63VFdxAA/nDoe/ypDY/CSRqFwzBZtkCAmw0 sWj0RjA7TMhhY1YJhtBRfhA8= 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 B188FA0008; Wed, 22 Jan 2025 17:20:08 +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: Wed, 22 Jan 2025 17:19:24 +0000 Message-ID: <20250122171925.25472-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250122171925.25472-1-mgorman@techsingularity.net> References: <20250122171925.25472-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: 1737566409105785618.9138.6377992846655049101@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=679128c9 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 | 11 ++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index cf2446c9c30d..832f6a97e64c 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -221,9 +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 (static_branch_maybe(CONFIG_HARDENED_USERCOPY_DEFAULT_ON, + &validate_usercopy_range)) { + return; + } + if (!__builtin_constant_p(n)) __check_object_size(ptr, n, to_user); } diff --git a/mm/usercopy.c b/mm/usercopy.c index 4cf33305347a..2e86413ed244 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; @@ -271,7 +270,9 @@ __setup("hardened_usercopy=", parse_hardened_usercopy); static int __init set_hardened_usercopy(void) { if (enable_checks == false) - static_branch_enable(&bypass_usercopy_checks); + static_branch_enable(&validate_usercopy_range); + else + static_branch_disable(&validate_usercopy_range); return 1; } From patchwork Wed Jan 22 17:19:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13947556 Received: from mail13.out.titan.email (mail13.out.titan.email [18.198.78.245]) (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 2ABD921505C; Wed, 22 Jan 2025 17:20:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.198.78.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737566422; cv=none; b=GYmhhLcshkAXIkxWLlv5P150PNm83ZEpSMrosdWE6bPl3hxdXqoopVxkGsmtC+T8yoPPquR7wf4pKnqwboSEnmF6H2cN/p6cwnHSH3DB+IxQZslAwAnttObE+wD9BC2YhpliCor1dWIpXsoakIfJ5G1c0B7hWF2xQaSE3MdD8rQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737566422; c=relaxed/simple; bh=KrjSVaIoP+BpwwMwb3WYVndUBetVLdni2EXBCUvc5sE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pJsdO9cwsVr6Cb9Q/tHOK5Nab1yB0w1OjgY/eAEaqqNY+HCer1/LfrSBAbkvAK8gJ05ra0g27nj3+NszNB40AOZj0C/sd86p0TxdJoWavib5D0xW2duWWYqGSDq2z2rboeNKA9dIzmiY533E/lLOE+rhYsfW6qXY0AABMBrU8yE= 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=I1QCkv0E; arc=none smtp.client-ip=18.198.78.245 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="I1QCkv0E" Received: from smtp-out0101.titan.email (localhost [127.0.0.1]) by smtp-out0101.titan.email (Postfix) with ESMTP id B63F1A004C; Wed, 22 Jan 2025 17:20:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=BaW9mABtKsoIJb+CbhxfD7184LG2W72FFvHkaZBiFVw=; c=relaxed/relaxed; d=techsingularity.net; h=in-reply-to:references:cc:date:mime-version:from:to:subject:message-id:from:to:cc:subject:date:message-id:in-reply-to:references:reply-to; q=dns/txt; s=titan1; t=1737566419; v=1; b=I1QCkv0Eg/MH2uGO1edQyJOOZM80Tehnol1UXOq6NcQv9m3kwdKrTIB+TA/Og00F/0Li4SH3 7gxjKe3CwqiDmakweBlwVQ/EmXh1eNwpJcNbExbK9slad3OB2q/D/VKahpwyfsIKS0drRcn+MCK fJBlSSWA8C1/zq9zJUwb0Jao= 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 47F13A00D9; Wed, 22 Jan 2025 17:20:19 +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: Wed, 22 Jan 2025 17:19:25 +0000 Message-ID: <20250122171925.25472-5-mgorman@techsingularity.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250122171925.25472-1-mgorman@techsingularity.net> References: <20250122171925.25472-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: 1737566419624532139.9138.5752076647353518555@prod-euc1-smtp-out1002. X-CMAE-Score: 0 X-CMAE-Analysis: v=2.4 cv=UdNXSrSN c=1 sm=1 tr=0 ts=679128d3 a=jU4EnjUUC1PH4wSjvv7Pww==:117 a=jU4EnjUUC1PH4wSjvv7Pww==:17 a=CEWIc4RMnpUA:10 a=NEAV23lmAAAA:8 a=R_Myd5XaAAAA:8 a=Q9Z_rya5RYYz_BbIbTgA:9 a=L2g4Dz8VuBQ37YGmWQah: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 adcc260839c7..e22dc1801bee 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