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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86A14F419A0 for ; Wed, 15 Apr 2026 12:49:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFB396B0089; Wed, 15 Apr 2026 08:49:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CABAB6B008C; Wed, 15 Apr 2026 08:49:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B73EF6B0092; Wed, 15 Apr 2026 08:49:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A24326B0089 for ; Wed, 15 Apr 2026 08:49:10 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5A801140448 for ; Wed, 15 Apr 2026 12:49:10 +0000 (UTC) X-FDA: 84660770460.20.C2DF651 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf12.hostedemail.com (Postfix) with ESMTP id 52E5340002 for ; Wed, 15 Apr 2026 12:49:08 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CXZiN4Zq; spf=pass (imf12.hostedemail.com: domain of david@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=david@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1776257348; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gMZa5KV+tcE5YO64Vp+w5NphVdK43kPGymBMgeLWk5g=; b=s1Hk7Pj6wWHOkakmBqFp4qnyRTERe89KjlOedQKnf0c/2IqlFmEcGAv1ys0wmv2gMAH+RJ 1SNxGamcE3p6PRYwfZwEcWsjKBRfI4MyvYUHJJCMvQ1JVV1VezEspU6XOCvyFhaI5TTfhe 8F3TsFzKzrwaEhv1mTWnOK5VZWbVZJA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CXZiN4Zq; spf=pass (imf12.hostedemail.com: domain of david@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=david@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1776257348; a=rsa-sha256; cv=none; b=rOTqMTycPVZaabbBl27/7UlgYiGgn9LgeLuxeWk1ee5FXAt5cV02Fckq1QSX1ZEyLhNHP4 1okESunm14ezqcJEhIPj60N1qjwumrdYmN6N2yPc8UDMWoptLT7ne+jrBZLw8c4aedSONA ykrx3Gx/hL/geN7uYOHaUGhb0xzi/2A= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id C2024600AD; Wed, 15 Apr 2026 12:49:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF21DC19424; Wed, 15 Apr 2026 12:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776257347; bh=z0QU7fIOckdevNLl67N0jcDETXgA9vaaD8hk9Cxb5qw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=CXZiN4ZqESEYgUFpVgLn6tlcj+2qfkWqnd43zukiIHbjVv2ZE4SxZ6zDVRTEcVnvq 3hri9KVxRpa7GkD0tvkUgf+ziy+2LNNYtQfklJ+lii2z2GHW4LUeA0qwmM8txAokwc MTmB7AEeBJZseE++VGbhqHuPq5aywAxF9etEtKNwedUPNbMXcwfvf5uig7hQP5/laP lpLSB+yzM2Em7R43Asp4sVRT978MX0ODbqO3SsOK47wAAiZKA1Z5SZSSomUVxZf4dZ ClbT7G0fzTDeI3zPLamwjM0vxQzw6an4+SVJoKIdx2Ql6S2PM+TaIBFiXGWR5MBvGM Q0WVKdiDDmzXg== Message-ID: <1c8e2cd6-4b50-4891-8a2d-6a45623e805f@kernel.org> Date: Wed, 15 Apr 2026 14:48:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 00/30] pkeys-based page table hardening To: Kevin Brodsky , linux-hardening@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , Andy Lutomirski , Catalin Marinas , Dave Hansen , Ira Weiny , Jann Horn , Jeff Xu , Joey Gouly , Kees Cook , Linus Walleij , Lorenzo Stoakes , Marc Zyngier , Mark Brown , Matthew Wilcox , Maxwell Bland , "Mike Rapoport (IBM)" , Peter Zijlstra , Pierre Langlois , Quentin Perret , Rick Edgecombe , Ryan Roberts , Thomas Gleixner , Vlastimil Babka , Will Deacon , Yang Shi , Yeoreum Yun , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, x86@kernel.org References: <20260227175518.3728055-1-kevin.brodsky@arm.com> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2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XcEXwDKQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: <20260227175518.3728055-1-kevin.brodsky@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Stat-Signature: 5qjp75ghijnc5qhyz5xhrxqf81c1dmfb X-Rspamd-Queue-Id: 52E5340002 X-Rspamd-Server: rspam09 X-HE-Tag: 1776257348-461258 X-HE-Meta: U2FsdGVkX1/Bg52e4GKmwnA8tqkDKOpWMup6tFbfPjUcmiHQJiU1ZSK41uIziqSe1OH4No3Sm5zE0y1Ww3o8A5NHK5ywIYQP4wHFHrQ3daL41gaBncj6N37OXbylvcNEPdJb+VKNsW+sA9Cnhxabk/Wwnx69shW1Cl4rfESiXxc+Kmb9A+bLBgD9BM4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vack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2/27/26 18:54, Kevin Brodsky wrote: > NEW in v6: support for large block mappings through a dedicated page table > allocator (patch 14-17) Heh, I had to read till the very end to realize that this is an RFC, and then saw your other mail. I can recommend using b4 for patch management, where you can configure a sticky prefix through b4 prep --set-prefixes RFC And using "b4 send" to automate all the rest. > > Threat model > ============ > > The proposed scheme aims at mitigating data-only attacks (e.g. > use-after-free/cross-cache attacks). In other words, it is assumed that > control flow is not corrupted, and that the attacker does not achieve > arbitrary code execution. Nothing prevents the pkey register from being > set to its most permissive state - the assumption is that the register > is only modified on legitimate code paths. > > A few related notes: > > - Functions that set the pkey register are all implemented inline. > Besides performance considerations, this is meant to avoid creating > a function that can be used as a straightforward gadget to set the > pkey register to an arbitrary value. > > - kpkeys_set_level() only accepts a compile-time constant as argument, > as a variable could be manipulated by an attacker. This could be > relaxed but it seems unlikely that a variable kpkeys level would be > needed in practice. > I see a lot of value for that also as a debugging mechanism. I hear that other people had private patches that would attempt to only map leaf pages in the direct map in pte_offset_map_lock() and friends. I assume there are some tricky bits to that (concurrent access to page tables). What's the general take regarding the thread model you describe vs. MTE? Regarding use-after-free, I'd assume KASAN would achieve something similar. And with MTE "reasonably" fast. Or what is the biggest difference you see, there? I'd assume that one difference would be, that not even match-all pointers could accidentally modify page tables. In the future, would you think that both mechanisms (pkey PT table protection + KASAN) would be active at the same time, or wouldn't there really be a lot of value in having both enabled? [...] > > > Open questions > ============== > > A few aspects in this RFC that are debatable and/or worth discussing: > > - Can the pkeys block allocator be abstracted into something more > generic? This seems desirable considering other use-cases for changing > attributes of regions of the linear map, but the handling of page > tables while splitting may be difficult to integrate in a generic > allocator. > > - There is currently no restriction on how kpkeys levels map to pkeys > permissions. A typical approach is to allocate one pkey per level and > make it writable at that level only. As the number of levels > increases, we may however run out of pkeys, especially on arm64 (just > 8 pkeys with POE). Depending on the use-cases, it may be acceptable to > use the same pkey for the data associated to multiple levels. > > > Any comment or feedback is highly appreciated, be it on the high-level > approach or implementation choices! How crucial would the dedicated page table allocator be for a first up streamed version? Assuming we introduce this as a debugging feature first, it would be perfectly reasonable to just disallow large block mappings in the direct map when enabled. That means, we could merge basic support first and think about how to deal with page tables in a different way with most of the pkey details out of the picture. -- Cheers, David