On Thu, Apr 03, 2025 at 03:28:43PM +0800, Xiaoyao Li wrote:
> On 4/2/2025 11:49 PM, Daniel P. Berrangé wrote:
> > On Wed, Apr 02, 2025 at 11:26:11PM +0800, Xiaoyao Li wrote:
> > > 
> > > I guess the raw mode was introduced due to the design was changed to let
> > > guest kernel to forward to TD report to host QGS via TDVMCALL instead of
> > > guest application communicates with host QGS via vsock, and Linux TD guest
> > > driver doesn't integrate any QGS protocol but just forward the raw TD 
> > > report
> > > data to KVM.
> > > 
> > > > IMHO, QEMU should be made to pack & unpack the TDX report from
> > > > the guest into the GET_QUOTE_REQ / GET_QUOTE_RESP messages, and
> > > > this "raw" mode should be removed to QGS as it is inherantly
> > > > dangerous to have this magic protocol overloading.
> > > 
> > > There is no enforcement that the input data of TDVMCALL.GetQuote is the 
> > > raw
> > > data of TD report. It is just the current Linux tdx-guest driver of tsm
> > > implementation send the raw data. For other TDX OS, or third-party driver,
> > > they might encapsulate the raw TD report data with QGS message header. For
> > > such cases, if QEMU adds another layer of package, it leads to the wrong
> > > result.
> > 
> > If I look at the GHCI spec
> > 
> >    
> > https://cdrdv2-public.intel.com/726790/TDX%20Guest-Hypervisor%20Communication%20Interface_1.0_344426_006%20-%2020230311.pdf
> > 
> > In "3.3 TDG.VP.VMCALL<GetQuote>", it indicates the parameter is a
> > "TDREPORT_STRUCT". IOW, it doesn't look valid to allow the guest to
> > send arbitrary other data as QGS protocol messages.
> 
> In table 3-7, the description of R12 is
> 
>   Shared GPA as input - the memory contains a TDREPORT_STRUCT.
>   The same buffer is used as output - the memory contains a TD Quote.
> 
> table 3-10, describes the detailed format of the shared GPA:
> 
> starting from offset 24 bytes, it is the "Data"
> 
>   On input, the data filled by TD with input length. The data should
>   include TDREPORT_STRUCT. TD should zeroize the remaining buffer to
>   avoid information leak if size of shared GPA (R13) > Input Length.
> 
> It uses the word "contains" and "include", but without "only". So it is not
> clear to me.
> 
> I will work with internal attestation folks to make it clearer that who (TD
> guest or host VMM) is responsible to encapsulate the raw TDERPORT_STRCUT
> with QGS MSG protocol, and update the spec accordingly.

To be clear, my strong preference is that the spec be updated to only
permit the raw TDREPORT_STRUCT.

IMHO allowing arbitrary QGS MSGs would be a significant host security
weakness, as it exposes a huge amount of the QGS codebase to direct
attack from the guest. QEMU needs to be able to block that attack
vector. Without that, the benefit/value of shuffling of TDREPORTs via
the GetQuote hypercall is largely eliminated, and might as well have
just exposed QGS over VSOCK.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to