lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ecfe3b3a-0a7d-86e7-08fb-f693bfa9255b@amd.com>
Date:   Wed, 27 Oct 2021 16:12:52 -0500
From:   Brijesh Singh <brijesh.singh@....com>
To:     Peter Gonda <pgonda@...gle.com>
Cc:     brijesh.singh@....com, x86@...nel.org,
        LKML <linux-kernel@...r.kernel.org>,
        kvm list <kvm@...r.kernel.org>, linux-efi@...r.kernel.org,
        platform-driver-x86@...r.kernel.org, linux-coco@...ts.linux.dev,
        linux-mm@...ck.org, Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Joerg Roedel <jroedel@...e.de>,
        Tom Lendacky <Thomas.Lendacky@....com>,
        "H. Peter Anvin" <hpa@...or.com>, Ard Biesheuvel <ardb@...nel.org>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Jim Mattson <jmattson@...gle.com>,
        Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Sergio Lopez <slp@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        David Rientjes <rientjes@...gle.com>,
        Dov Murik <dovmurik@...ux.ibm.com>,
        Tobin Feldman-Fitzthum <tobin@....com>,
        Borislav Petkov <bp@...en8.de>,
        Michael Roth <michael.roth@....com>,
        Vlastimil Babka <vbabka@...e.cz>,
        "Kirill A . Shutemov" <kirill@...temov.name>,
        Andi Kleen <ak@...ux.intel.com>,
        "Dr . David Alan Gilbert" <dgilbert@...hat.com>,
        tony.luck@...el.com, Marc Orr <marcorr@...gle.com>,
        sathyanarayanan.kuppuswamy@...ux.intel.com
Subject: Re: [PATCH v6 40/42] virt: Add SEV-SNP guest driver



On 10/27/21 4:05 PM, Peter Gonda wrote:
....

>>>>>
>>>>> Thanks for updating this sequence number logic. But I still have some
>>>>> concerns. In verify_and_dec_payload() we check the encryption header
>>>>> but all these fields are accessible to the hypervisor, meaning it can
>>>>> change the header and cause this sequence number to not get
>>>>> incremented. We then will reuse the sequence number for the next
>>>>> command, which isn't great for AES GCM. It seems very hard to tell if
>>>>> the FW actually got our request and created a response there by
>>>>> incrementing the sequence number by 2, or if the hypervisor is acting
>>>>> in bad faith. It seems like to be safe we need to completely stop
>>>>> using this vmpck if we cannot confirm the PSP has gotten our request
>>>>> and created a response. Thoughts?
>>>>>
>>>>
>>>> Very good point, I think we can detect this condition by rearranging the
>>>> checks. The verify_and_dec_payload() is called only after the command is
>>>> succesful and does the following checks
>>>>
>>>> 1) Verifies the header
>>>> 2) Decrypts the payload
>>>> 3) Later we increment the sequence
>>>>
>>>> If we arrange to the below order then we can avoid this condition.
>>>> 1) Decrypt the payload
>>>> 2) Increment the sequence number
>>>> 3) Verify the header
>>>>
>>>> The descryption will succeed only if PSP constructed the payload.
>>>>
>>>> Does this make sense ?
>>>
>>> Either ordering seems fine to me. I don't think it changes much though
>>> since the header (bytes 30-50 according to the spec) are included in
>>> the authenticated data of the encryption. So any hypervisor modictions
>>> will lead to a decryption failure right?
>>>
>>> Either case if we do fail the decryption, what are your thoughts on
>>> not allowing further use of that VMPCK?
>>>
>>
>> We have limited number of VMPCK (total 3). I am not sure switching to
>> different will change much. HV can quickly exaust it. Once we have SVSM
>> in-place then its possible that SVSM may use of the VMPCK. If the
>> decryption failed, then maybe its safe to erase the key from the secrets
>> page (in other words guest OS cannot use that key for any further
>> communication). A guest can reload the driver will different VMPCK id
>> and try again.
> 
> SNP cannot really cover DOS at all since the VMM could just never
> schedule the VM. In this case we know that the hypervisor is trying to
> mess with the guest, so my preference would be to stop sending guest
> messages to prevent that duplicated IV usage. If one caller gets an
> EBADMSG it knows its in this case but the rest of userspace has no
> idea. Maybe log an error?
> 
>>

Yap, we cannot protect against the DOS. This is why I was saying that we 
zero the key from secrets page so that guest cannot use that key for any 
future communication (whether its from rest of userspace or kexec 
kernel). I can update the driver to log the message and ensure that 
future messages will *not* use that key. The VMPCK ID is a module 
params, so a guest can reload the driver to use different VMPCK.


>> thanks

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ