Linux Confidential Computing Development
 help / color / mirror / Atom feed
From: Nikolay Borisov <nik.borisov@suse.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: dave.hansen@linux.intel.com, linux-coco@lists.linux.dev,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	vannapurve@google.com,
	Elena Reshetova <elena.reshetova@intel.com>
Subject: Re: [RFC PATCH] /dev/mem: Disable /dev/mem under TDX guest
Date: Tue, 18 Mar 2025 14:53:34 +0200	[thread overview]
Message-ID: <b6d132a7-b259-46f4-8bde-fc517bd9d294@suse.com> (raw)
In-Reply-To: <guatjzjzipzjzvj4oou2gktxmzileawshxmxj22hsa5kmet5g4@2rhf7tzaiytw>



On 18.03.25 г. 14:23 ч., Kirill A. Shutemov wrote:
> On Tue, Mar 18, 2025 at 01:36:04PM +0200, Nikolay Borisov wrote:
>> If a piece of memory is read from /dev/mem that falls outside of the
>> System Ram region i.e bios data region the kernel creates a shared
>> mapping via xlate_dev_mem_ptr() (this behavior was introduced by
>> 9aa6ea69852c ("x86/tdx: Make pages shared in ioremap()"). This results
>> in a region having both a shared and a private mapping.
>>
>> Subsequent accesses to this region via the private mapping induce a
>> SEPT violation and a crash of the VMM.
> 
> Crash of VMM or TD termination? If VMM crashes in this case, it has to be
> fixed.

Went back through the bug reports and it seems this causes a SEPT 
violation inside the guest, which crashes, and is then re-created by 
GCP. So it would seem this causes an SEPT violation, rather than a VMM 
crash, my bad for mixing up the symptoms.

> 
>> In this particular case the
>> scenario was a userspace process reading something from the bios data
>> area at address 0x497 which creates a shared mapping, and a followup
>> reboot accessing __va(0x472) which access pfn 0 via the private mapping
>> causing mayhem.
> 
> I think it should lead to unrecoverable EPT-violation, but not VMM crash.

<nod> You are correct.

> 
>> Fix this by simply forbidding access to /dev/mem when running as an TDX
>> guest.
> 
> I think we need to think wider. What about applying a subset of LOCKDOWN_*
> in all coco guests by default. Many of them are relevant for the guest security.

How do you envision this to work, by introducing another 
CONFIG_LOCK_DOWN_KERNEL_FORCE_COCO or some such ? Will it be opt-in or 
mandatory?

Should we decide to follow the lockdown route this means the owner of 
the coco guest will have the ability to disable it and a misbehaving 
userspace process will still be able to induce an EPT violation.


> 




  reply	other threads:[~2025-03-18 12:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 11:36 [RFC PATCH] /dev/mem: Disable /dev/mem under TDX guest Nikolay Borisov
2025-03-18 11:53 ` Juergen Gross
2025-03-18 11:56   ` Nikolay Borisov
2025-03-18 12:23 ` Kirill A. Shutemov
2025-03-18 12:53   ` Nikolay Borisov [this message]
2025-03-18 13:27     ` Kirill A. Shutemov
2025-03-18 14:21       ` Nikolay Borisov
2025-03-20  9:38         ` Kirill A. Shutemov
2025-03-18 14:48 ` Dave Hansen
2025-03-18 17:56   ` Nikolay Borisov
2025-03-18 19:06 ` Dan Williams
2025-03-24  9:59   ` Nikolay Borisov
2025-03-25 18:16     ` Dan Williams
2025-03-28 10:51       ` Nikolay Borisov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6d132a7-b259-46f4-8bde-fc517bd9d294@suse.com \
    --to=nik.borisov@suse.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=elena.reshetova@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vannapurve@google.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox