From patchwork Tue May 23 07:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13251619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F427C7EE23 for ; Tue, 23 May 2023 07:31:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7113C6B0081; Tue, 23 May 2023 03:31:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BFCC6B0082; Tue, 23 May 2023 03:31:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AF7F900003; Tue, 23 May 2023 03:31:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4C99A6B0081 for ; Tue, 23 May 2023 03:31:51 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1848C1A06E2 for ; Tue, 23 May 2023 07:31:51 +0000 (UTC) X-FDA: 80820700422.09.C525342 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf26.hostedemail.com (Postfix) with ESMTP id 25116140013 for ; Tue, 23 May 2023 07:31:48 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=12BbIW+5; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JjwwBXLw; dmarc=none; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684827109; a=rsa-sha256; cv=none; b=P4kHAVTeazlzXGSwBczCU5/R8HI8VtYl7OiYpi/AM1PPPYo+bhbVhGzBrLDjHFGbyEIYrP 60xn58IUg/0H7BAl03kYQ+zQ3MoC5tOPCzgAv6f72z4SDbrFZd8/dRpPmg32A9kMM2FeUi /UoESi6aUM84vhbOx6a4/O+Hx9u6Nj8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=12BbIW+5; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JjwwBXLw; dmarc=none; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684827109; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=ZEzc5LOCCEl4X9/BHaKPnOKiEHFUp8WpILtxUD4qjNg=; b=njeqUTuT/kjdJXJnoH355RBVsbGM2vm696veOZlGLo/DsRLBeTDaklfq+wlUyfI98+wTHC U7/HW5lX8XBKyjD50IY0uho9NfNtntF/KUoR06JRaMJJE36kj1qFDgYqYO+n9Rd3YPz69O 01nhGFShnXn7HWNFSm6Zgfrr8XpEa4Q= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7F80722770; Tue, 23 May 2023 07:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1684827104; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZEzc5LOCCEl4X9/BHaKPnOKiEHFUp8WpILtxUD4qjNg=; b=12BbIW+5OtsAyqRSCvzLDYP3yElbsULJxVddqtKq/f2DjB9ngYqgGSk1x9aJAe2LFl0aT5 Av9d/xS5Au9Xg+ZXIMYrhmFHYiLJMZCFs1T3yHyWNXlbzGZoY+BYaJLAPzbQ3Hl+NgON2n IfGbXRLe/wU9OxcQZ2tmlvn32ZeejU8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1684827104; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZEzc5LOCCEl4X9/BHaKPnOKiEHFUp8WpILtxUD4qjNg=; b=JjwwBXLwGDpGwrmS1npS/eF+SP7rLitCKRX5eu3zbu10pCWZ8EHThUk1eJoi2X3/KY/Nwv RRAeMt35EdLTFWBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5222913588; Tue, 23 May 2023 07:31:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cr9ZE+BrbGRSIQAAMHmgww (envelope-from ); Tue, 23 May 2023 07:31:44 +0000 From: Vlastimil Babka To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim Cc: Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Kees Cook , linux-mm@kvack.org, linux-hardening@vger.kernel.org, patches@lists.linux.dev, linux-kernel@vger.kernel.org, Vlastimil Babka Subject: [PATCH] mm/slab: remove HAVE_HARDENED_USERCOPY_ALLOCATOR Date: Tue, 23 May 2023 09:31:36 +0200 Message-Id: <20230523073136.4900-1-vbabka@suse.cz> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 25116140013 X-Stat-Signature: ddjpqhf1m69quzkfj53rcg1chhdn1s3r X-HE-Tag: 1684827108-525264 X-HE-Meta: U2FsdGVkX19uliauhwA2E35Lalp2FG+cgnM9QlDQ1r32YVQ+Swc0z0846eLc/6CXufnIkk9j1/YT6SN/UOiw+2yfw/Cl6E4wrCS6wZDDKgDJBt+kHp94dAmYjXG5JZVgiBWKzrc/XGvPHpj9YA9RTdkV5ndnLHlZ5EUGbBfK/Fe5yjGyQZsd8jdp7B6JObUX+GHCFi07kbxUeb72vwSZAUozQspuLX3a0vOcyS+aKz69XQLTN9CbH57fRX8n+JmdcHZfgqoU0D2LO4T5Sv6m0pX2Tm34I+GagIs3WSHdJ2GVizKZ58FuldAOXB7YZ/kSKaCb3LWfcDw252I5kCXyfE/6bVW+bbmn9yoffywgF2zhN2r9+XXl2QiXHjUcToyqIUdKLSdYDDdyPJ+cUchpfbMGKuy5OsQ37OQWXmlmxhMxiUfp/APFiea7kSzd/OCamzE2sv0zRgDfL8pHRPB5uEn6DzvR1VedzvgXKvMOuvX3+ZOTuzg3o1PpzZDwKUOnFTTFszYVWOZog81ZNMm2Q7i+Xg2hNWvOIwLOP/htr8JOXEJdI/Nb6D1ip6W70dqXON64zKlJqoP3qcHqgbwqRVR2q15NutDVIMfLUImIpM3Dvb56FtmqLw+iCAOQ67Wbvrc3eln8SJKqmvZTQF+sM8PDljgDNwBs2YIIAat82bYF5cZjPO8oQuJVtfROH228V0FbvKupbKsPXFDOFHixYaPaKV+i6XdlCNyg6o7qHhtLu6dyqDNXL648IFVDHIgsgjII3zNhHm2Tuqh8Br6BjtOJo3t55+ax9G9bFmnNzXr6vWdUJAfZYA8vn+Qkipb0aH5bTLCfHxTyGCBKy23n77RUEBG/+wBOFZOs5e98wI5oHJb2KETkPuksXlAd+LYkFOM1GS/y1yEQFTrTcSogOxEsqlzwUHhkV2oiHmkhVysnNZSfoTRAVCmUfYPKv2qjtPfP/DjMYxDaQGzMgRo /TEwbAUi CFcKI0TiQNU7fDgLLfXQES0qHaape0XvJ3ptSP8NvQU8QjbyDrKVZQ/flkBpQEPxz3XqQPSEEVkbM+PrFKlJrsd4F4i4oPyAFQJI/LX69JFdKT/aKkpljXpRr6seb51QFLcmUIcWQ9hHBbKtq/Z/55rlj8H7D/pXY48UnM8n4wJysMEsoWYGN8JX1W2dGydJFEigqvE2xKKcXSTO4uR+zo2JhTegfes5VbosgGQcSOmjTn+xjfrU1DKBB843OgUaWTm4PXE4cUtyyQovIcsZzmgi61iqDrINjQC3Gd4f1D82TXWpYvysqBi5QMQ== 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: With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef. Signed-off-by: Vlastimil Babka Reviewed-by: David Hildenbrand Reviewed-by: Kees Cook Acked-by: David Rientjes Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Lorenzo Stoakes --- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 7672a22647b4..041f0da42f2b 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in @@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach). diff --git a/mm/slab.h b/mm/slab.h index f01ac256a8f5..695ef96b4b5b 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -832,17 +832,8 @@ struct kmem_obj_info { void __kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct slab *slab); #endif -#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object(const void *ptr, unsigned long n, const struct slab *slab, bool to_user); -#else -static inline -void __check_heap_object(const void *ptr, unsigned long n, - const struct slab *slab, bool to_user) -{ -} -#endif - #ifdef CONFIG_SLUB_DEBUG void skip_orig_size_check(struct kmem_cache *s, const void *object); #endif diff --git a/security/Kconfig b/security/Kconfig index 97abeb9b9a19..52c9af08ad35 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -127,16 +127,8 @@ config LSM_MMAP_MIN_ADDR this low address space will need the permission specific to the systems running LSM. -config HAVE_HARDENED_USERCOPY_ALLOCATOR - bool - help - The heap allocator implements __check_heap_object() for - validating memory ranges against heap object sizes in - support of CONFIG_HARDENED_USERCOPY. - config HARDENED_USERCOPY bool "Harden memory copies between kernel and userspace" - depends on HAVE_HARDENED_USERCOPY_ALLOCATOR imply STRICT_DEVMEM help This option checks for obviously wrong memory regions when