From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796220020; b=PaS5OAHsIFXUWUKgbA27feq2yW9eZFVvmA4CW/jtj4iAntYxbqWMMFPFla1ftrOiFMQl mzMTgIXEEwb6keZGmnlWwnu/vm1VgmWTiiDWVqL365JUgUZRu+UesU9tdUV5j6v2DpiB2 yVaJtRcswgn+RFkQKTGEOYkv8ksmGBnQlBfxKSjXpBnu4lAoOKrctJELUakYUFT4YbyPF klRiD2I4WBwmOfLhiDELfh5XjPLY543lEhmY/naJheovKDaxl3lPoi1GuJ12J6XzZia03 y+h70GxlBsM+rxD9anCXQPykH7GN2AWvzxTNf5gcthekek4VsmRErEKbc3R0YaFSxcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796220020; h=Received:DKIM-Signature:Received:Received:X-ME-Sender: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer: MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type:Content-Transfer-Encoding; bh=LKblIyZ87vPNcAL4KJnA29pasSiDpPDXtGBVTKW+0tY=; b=J60wjGu+NzjA4CINPDMyeBvxXT0JEOSqXG+Y4q3UnDAPsnlpCTcqzG3iXYmtRYrfPZo1 AXRyR2AYB3qRVFvXdiZdh5iUBmtLjTNhmOeogEbMx0sD0YB1QKdj193nxK4nos3V1IJDo maBXxaeREJBUNYJK6GQHqCq051XJMAV+rfaughDOxIHrER4hQdOMwgtenVdsD4OQJRcyZ cyvZ0JTEWFmstcGpBrY+WDwEkXtdpgiWMYCrrUTXuM3DDtb3mySXLXN1bIEAzBseK6Dci Ofk3raXkWiotQcz8RucQvh0nUyc0GNu/vT24hljwIpe/rGypm4rNeM4I/VgL3GguBAw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k1sPz5Nn; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30260606A325 for ; Wed, 2 Dec 2026 14:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=k1sPz5Nn Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDEB81F00924; Wed, 2 Dec 2026 14:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796220019; bh=LKblIyZ87vPNcAL4KJnA29pasSiDpPDXtGBVTKW+0tY=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=k1sPz5NnVSZspClXbf4deLxXQN9i/6+cLlGIt/+Z0zfaEgVD/3VhVGv+gR2tPTUDV mRSxp4SZiQ6+4hRPdTqV4FyHsbgIxPgnYm4abZ3ZFUY2y6eBHmf9Iay6mNBh6b1oEr +nymUBh7BHxjZVSf0DVxYuOvsEzvTuUvx7OiSrFMg078hUejQGo0OYzibuenazVT/p 0UJi0w0sNFbQFs+e3RYU6AygzHP5x9vCqWjxyuX2lxVk4m4LZWA0tkDbxZ/AADLKtQ fQpKgQ0Vnit2QP/uJ3/DroLjan5tEkoKYlOXCJp9l+OgyCOKlrfwZHfX0wlBRTbcOm ZFPlUwHOvOmjQ== Received: from ams-compute-02.internal (ams-compute-02.internal [10.64.2.62]) by mailfauth.ams.internal (Postfix) with ESMTP id 19E2F198003A; Wed, 2 Dec 2026 09:00:17 -0500 (EST) Received: from ams-imap-11 ([10.64.2.31]) by ams-compute-02.internal (MEProxy); Wed, 02 Dec 2026 09:00:17 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTGSZGeifPQtFagZCqb+5oc4YG8N8P5+BeCQXfLEpfMRLHQP42heOqwrW1ItQf3cFV 6/w2bj8/zkv9ef0CF974cSFXihOZ3vASif+0J8TDsma1Dow3xt/X8zf5R0bDIXMVepzisw bsRYL490472cXPIyqHawdRLEiScst85XvfyVX3Git6mYk3KVLGMbTNeaI45pI7FRL095ZF AFLYdQqa9YD1E95DQcDEgyL/KlYdx8glxpISznqHCKnbuBY2zqfcHgMoE/4G0EWeDtOoKo 3caUl+mMvv/wlpumeTl7k2HCFP/cswxk1jeE+uwRgj0ArZOVhR4KbkfQdKxaxqLgji6wVO TQgSfI/5xqJyJQktSztTFvuBnNIvOCNitAcbbXLandlml2LB81k4chfQatvnQqDQ/vaTN2 6aBnc3A5WLegBYo0qL9qH70Z4Zfuz6mgSUbsjQHyRRj0jNETg78J7Kbn+lcBhMFw3ft/wn lS4xh8KQYQibOw0xHhidWgNvtTPGthTnCQZXS4IZHK6M0Mqn4153DZaYeV4GhyEK5anSU2 HeMv4pa7IF1H8LbOq5PxlRs1ZOilWyryoTXW4hcq2La8Y9cG+B0M+to6OYK7izWLcmnRS9 IM1oLmyxE5hWxX41YViHM4gg5SEmK+mm7ZADn5JRqwS6qQ4xp99z5hYtqT2Q X-ME-Proxy: Feedback-ID: ice86485a:Fastmail Received: by mailuser.ams.internal (Postfix, from userid 501) id 1C3CDF80093; Wed, 2 Dec 2026 09:00:14 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Date: Wed, 02 Dec 2026 14:59:53 +0100 From: "Ard Biesheuvel" To: "Nikolay Borisov" , x86@kernel.org Cc: naveen@kernel.org, "Dan Williams" , "Kees Cook" , "Ingo Molnar" , "Vishal Annapurve" , "Arnd Bergmann" , "Greg Kroah-Hartman" , "Michael Ellerman" , "Suzuki K Poulose" , stable@vger.kernel.org Message-Id: <1faed4b6-2f4e-473a-a5fb-90f33ca190eb@app.fastmail.com> In-Reply-To: <20261130120003.136771-1-nik.borisov@suse.com> References: <20261130120003.136771-1-nik.borisov@suse.com> Subject: Re: [PATCH v3] x86/devmem: Drop /dev/mem access for confidential guests Content-Type: text/plain Content-Transfer-Encoding: 7bit On Mon, 30 Nov 2026, at 13:00, Nikolay Borisov wrote: > From: Dan Williams > > Nikolay reports that accessing BIOS data (first 1MB of the physical > address space) via /dev/mem results in a "crash" / terminated VM > (unhandled SEPT violation). See report [1] for details. > > The cause is ioremap() (via xlate_dev_mem_ptr()) establishes an > unencrypted mapping where the kernel had established an encrypted > mapping previously. The CPU enforces mapping consistency with a fault > upon detecting a mismatch. A similar situation arises with devmem access > to "unaccepted" confidential memory. In summary, it is fraught to allow > uncoordinated userspace mapping of confidential memory. > > While there is an existing mitigation to simulate and redirect access to > the BIOS data area with STRICT_DEVMEM=y, it is insufficient. > Specifically, STRICT_DEVMEM=y traps read(2) access to the BIOS data > area, and returns a zeroed buffer. However, it turns out the kernel > fails to enforce the same via mmap(2), and a direct mapping is > established. This is a hole, and unfortunately userspace has learned to > exploit it [2]. > > This means the kernel either needs: a mechanism to ensure consistent > plus accepted "encrypted" mappings of this /dev/mem mmap() hole, close > the hole by mapping the zero page in the mmap(2) path, block only BIOS > data access and let typical STRICT_DEVMEM protect the rest, or disable > /dev/mem altogether. > > The simplest option for now is to revoke memory access via /dev/mem for > confidential guests. > Require confidential guest userspace to jettison legacy dependencies on > /dev/mem similar to how other legacy mechanisms are jettisoned for > confidential operation. Recall that modern methods for BIOS data > access are available like /sys/firmware/dmi/tables. > > Now, this begs the question what to do with PCI sysfs which allows > userspace mappings of confidential MMIO with similar mapping consistency > and acceptance expectations? Here, the existing mitigation of > IO_STRICT_DEVMEM is likely sufficient. The kernel is expected to use > request_mem_region() when toggling the state of MMIO. With > IO_STRICT_DEVMEM that enforces kernel-exclusive access until > release_mem_region(), i.e. mapping conflicts are prevented. However, > this is left out for relevant series when secure MMIO support starts > landing. > > Cc: x86@kernel.org > Cc: Kees Cook > Cc: Ingo Molnar > Cc: Vishal Annapurve > Cc: Arnd Bergmann > Cc: Greg Kroah-Hartman > Cc: Michael Ellerman > Cc: Suzuki K Poulose > Link: > https://sources.debian.org/src/libdebian-installer/0.125/src/system/subarch-x86-linux.c/?hl=113#L93 > [2] > Reported-by: Nikolay Borisov > Closes: > http://lore.kernel.org/20250318113604.297726-1-nik.borisov@suse.com [1] > Fixes: 9aa6ea69852c ("x86/tdx: Make pages shared in ioremap()") > Cc: stable@vger.kernel.org > Signed-off-by: Dan Williams > Signed-off-by: Nikolay Borisov > --- > > Changes in V3: > * Only select STRICT_DEVMEM if DEVMEM is also selected (Sashiko, > Naveen) > * Remove superfluous check for CONFIG_STRICT_DEVMEM, devmem_is_allowed > is only > called when it's enabled > * Slightly modify the last 2 paragraphs of the changelog to reflect > that this no > longer follows the LOCKDOWN model and simply revokes memory access. And > explicilty call out the omission of IO_STRICT_DEVMEM > * Removed tags as the patch is sufficiently different now. > Acked-by: Ard Biesheuvel