From mboxrd@z Thu Jan 1 00:00:00 1970 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 4029AC369AB for ; Fri, 18 Apr 2025 20:13:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2D996B0030; Fri, 18 Apr 2025 16:13:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CDA7A6B0031; Fri, 18 Apr 2025 16:13:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B549B6B0032; Fri, 18 Apr 2025 16:13:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9789F6B0030 for ; Fri, 18 Apr 2025 16:13:24 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BB7CE160D7C for ; Fri, 18 Apr 2025 20:13:25 +0000 (UTC) X-FDA: 83348264370.22.DA1A672 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 3D51C4000E for ; Fri, 18 Apr 2025 20:13:24 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IleN+pZ3; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of kees@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kees@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745007204; a=rsa-sha256; cv=none; b=fwbh21Tf/9GE28T+H1nJgWCWVdAayvkcBFEl+jGozVPcPKWx9zeTaH0qBEIXycY4ZCsNa+ vGIgPwaxzpQeiAUzXpwQXf+/4ml2oYNXmUQYc3Dph6BId2GyG46NPSf+8Ey14hgwLNBiDT 9oZG/6Bdh6Nw9GNHXe/W8I+We5UcB14= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IleN+pZ3; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of kees@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kees@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745007204; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VboXzmRt7p3YB1gfrV2sx9u0xfoIjTDEC02TKOzg+iE=; b=3oYTmvMCIzRpSJxEbqM4LdZDXWdNjg2W//jRjHOQwAJY+okCW+WQO8rf9KSZzbFbFhYP6x uU6cv/5/gDeiA/HehP97BJfN9sZifGpxv8YNKiR7EMuddsw54FuGPWpItrPN/UNnhScaRk P2q9GaP1l1Usk25yV4Sx4bLftn5H3x4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E77825C3A5E; Fri, 18 Apr 2025 20:11:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F90EC4CEE2; Fri, 18 Apr 2025 20:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745007202; bh=BVnZkjjSv9MWVlNg/FhLx0h58zSUOIcwkn/bPbmUKkY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IleN+pZ3cxJ75hjLuM7eHCurpvJEerxB1r3RthS3MTd8IPL8VffVGe0SpwrzIhNAV IhOPw6Qfd3kYmDxxtW+OxfB82G9V/3ocNP7X9c+hVg38BOBPK8KgawxiE1nS9KHcPd yOyGdJRaqkGxSe7a57XPYEwmHHahwxQ/bpkIIkaf2jdsRmO/eT1iqblFSHZLKO5TW6 YnBurIWzQBCwXR+kLlwFseJsbgn6wba0/eJ5A2/RA+fQx+NxUa6RQio9yLds7iOTBc Ido92N6j2dynDfmxLcpFGEWRQvcD4/gnd525/3KQDXVreFN73AVCuW54LEvEE+IZdt xvkM7DWO8cyNg== Date: Fri, 18 Apr 2025 13:13:20 -0700 From: Kees Cook To: Harry Yoo Cc: Petr Mladek , Sergio Perez Gonzalez , Vlastimil Babka , David Rientjes , Bagas Sanjaya , Jonathan Corbet , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , Andrew Morton , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Roman Gushchin , "Paul E. McKenney" , Randy Dunlap , Tamir Duberstein , Miguel Ojeda , Alice Ryhl , linux-doc@vger.kernel.org, linux-mm@kvack.org, Thomas Huth , "Borislav Petkov (AMD)" , Ard Biesheuvel , Greg Kroah-Hartman , Andreas Hindborg , Stephen Boyd , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] slab: Decouple slab_debug and no_hash_pointers Message-ID: <202504181307.254F81843@keescook> References: <20250415170232.it.467-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3D51C4000E X-Stat-Signature: uu4n7dkgjy7eo9ixiyd1oqw6dt8bbtk5 X-HE-Tag: 1745007204-463997 X-HE-Meta: U2FsdGVkX19EsXadkFTv+8JGbYFId3BpnLLOA2OIrpgQ4O7K0SkAg31SPnoMRj+FUMtvLjvmv8owpUCAaexRtjZS7vbl20AExr39LygfONs5Cx+oINtt2bDGlpR6r97ZkJ1SwgM4SdHsh9frtuW360ok2xt6IeNt5l98wSfSeUU+TNgsfAZOKBEHvoLtUMomJ5Qp7fhcxMyhlppbm64nBDFZD1KW83lWsbwkDZWvVU2pkpWJFn4PQLW1pQFeChdkMP/Rr0BZoYgh6mp4zC8M8Y5ZWpXG7T4OPwN1Mju2jK5w5kwvi68Hw/9dwcdQZbsmVm+5LBoHOzsFJ0MiYqRNKH6+XmG63w3qD+iZI++DkHpQTdPer6rw0vcJEzOYtFkMRrEf2vaOJFljf2L7h+66//fWbAh7Qf3SRI5nzKZqnEK2IzEBXtgT9aZVWPtKJC7CShov8Q8NMBE7vTGdCuQG2xh4YvzqbZDvOrLlY+sdovdA9/9zFeDWAIkCoKJA5eo+dxsK3V9vqsObn8rhB8JQc3ZRQ3zWuDOsgbV/oqiwIYD6i+hLUbderBXU3MtNkxLpOsblndSzawro1/zuE9WHBjvv6SctndW104O7gNJ64EkqcroQj1XcK2ISVZ6XHhyh6cHDDyOJV/MGglsE8lOHkXQ037Ve8ZD0fzT+voGQHMVjNMp8572ETmr3q/VUpYNFXPYvypMYqFrGhsNrr7DqL/d42ra44LPoIWNsq9f9Q3xVduduv9QsDv+fed+jJEtzw7Wrc4HYK8r9oZw+cwUvo88CWTvQiqz/PK4DapeUELD7AlQkmjElrD5hJncbZulgx8int3WsrDhaJd8rzxlrXfIZ/s7hViC0qEc4f9Dae+SN/VuSCS5UvUobU2YdcPsb/Iu5caEzkVjTAVOohQKzF8NeIvJgQv+R8y5gCgL9+/DKXcr6o51C8ICIfataMgVW1BoLINg7qR/4sJ6M7aZ nZcH8yT8 k14gF 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: List-Subscribe: List-Unsubscribe: On Thu, Apr 17, 2025 at 11:15:11PM +0900, Harry Yoo wrote: > On Tue, Apr 15, 2025 at 10:02:33AM -0700, Kees Cook wrote: > > Some system owners use slab_debug=FPZ (or similar) as a hardening option, > > but do not want to be forced into having kernel addresses exposed due > > to the implicit "no_hash_pointers" boot param setting.[1] > > Is this behavior documented somewhere or it's only in the code? > I couldn't find anything other than the code. Hmm, that's an excellent point. I don't see any mention of it in kernel-parameters.txt. Perhaps this? diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 4568572205ee..982e6511a225 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6483,6 +6483,10 @@ Documentation/mm/slub.rst. (slub_debug legacy name also accepted for now) + Using this option implies the "no_hash_pointers" + option which can be undone by adding the + "hash_pointers=always" option. + slab_max_order= [MM] Determines the maximum allowed order for slabs. A high setting may cause OOMs due to memory > > > Introduce the "hash_pointers" boot param, which defaults to "auto" > > (the current behavior), but also includes "always" (forcing on hashing > > even when "slab_debug=..." is defined), and "never". The existing > > "no_hash_pointers" boot param becomes an alias for "hash_pointers=never". > > > > This makes it possible to boot with "slab_debug=FPZ hash_pointers=always". > > > > Link: https://github.com/KSPP/linux/issues/368 [1] > > Fixes: 792702911f58 ("slub: force on no_hash_pointers when slub_debug is enabled") > > Co-developed-by: Sergio Perez Gonzalez > > Signed-off-by: Sergio Perez Gonzalez > > Acked-by: Vlastimil Babka > > Acked-by: David Rientjes > > Reviewed-by: Bagas Sanjaya > > Signed-off-by: Kees Cook > > --- > > Reviewed-by: Harry Yoo > > By the way, while this patch does not change existing behavior of > slub_debug implying no_hash_pointers, kmem_cache_init() is not the only > place that enables slub_debug_enabled static key. > > Maybe we should update __kmem_cache_create_args() too? > (in a separate patch) The state of pointer hashing should not change after boot. (It is intentionally designed to use __ro_after_init.) Honestly, I'd prefer that slab_debug was not tied to no_hash_pointers at all... -Kees -- Kees Cook