[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ea839e63-3374-5ff6-92ee-da6f1f714972@intel.com>
Date: Tue, 4 May 2021 07:33:16 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Brijesh Singh <brijesh.singh@....com>,
Andy Lutomirski <luto@...capital.net>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
tglx@...utronix.de, bp@...en8.de, jroedel@...e.de,
Thomas.Lendacky@....com, pbonzini@...hat.com, mingo@...hat.com,
rientjes@...gle.com, seanjc@...gle.com, peterz@...radead.org,
hpa@...or.com, tony.luck@...el.com
Subject: Re: [PATCH Part2 RFC v2 10/37] x86/fault: Add support to handle the
RMP fault for kernel address
On 5/4/21 5:31 AM, Brijesh Singh wrote:
> On 5/3/21 2:43 PM, Dave Hansen wrote:
>> On 5/3/21 12:41 PM, Brijesh Singh wrote:
>>> Sure, I will look into all the drivers which do a walk plus kmap to make
>>> sure that they fail instead of going into the fault path. Should I drop
>>> this patch or keep it just in the case we miss something?
>> I think you should drop it, and just ensure that the existing page fault
>> oops code can produce a coherent, descriptive error message about what
>> went wrong.
>
> A malicious guest could still trick the host into accessing a guest
> private page unless we make sure that host kernel *never* does kmap() on
> GPA. The example I was thinking is:
>
> 1. Guest provides a GPA to host.
>
> 2. Host queries the RMP table and finds that GPA is shared and allows
> the kmap() to happen.
>
> 3. Guest later changes the page to private.
This literally isn't possible in the SEV-SNP architecture. I really
wish you would stop stating it. It's horribly confusing.
The guest can not directly change the page to private. Only the host
can change the page to private. The guest must _ask_ the host to do it.
That's *CRITICALLY* important because what you need to do later is
prevent specific *HOST* behavior.
When those guest requests come it, the host has to ensure that the
request is refused or stalled until there is no chance that the host
will write to the page. That means that the host needs some locks and
some metadata.
It's also why Andy has been suggesting that you need something along the
lines of copy_to/from_guest(). Those functions would take and release
locks to ensure that shared->private guest page transitions are
impossible while host access to the memory is in flight.
> 4. Host write to mapped address will trigger a page-fault.
>
> KVM provides kvm_map_gfn(), kvm_vcpu_map() to map a GPA; these APIs will
> no longer be safe to be used.
Yes, it sounds like there is some missing KVM infrastructure that needs
to accompany this series.
> In addition, some shared pages are registered once by the guest and
> KVM updates the contents of the page on vcpu enter (e.g, CPU steal
> time).
Are you suggesting that the host would honor a guest request to convert
to private the shared page used for communicating CPU steal time? That
seems like a bug to me.
> IMHO, we should add the RMP table check before kmap'ing GPA but still
> keep this patch to mitigate the cases where a malicious guest changes
> the page state after the kmap().
I much prefer a solution where guest requests are placed under
sufficient scrutiny and not blindly followed by the host.
Powered by blists - more mailing lists