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] [day] [month] [year] [list]
Message-ID: <61e64ce5-df76-f34a-1dc8-a0f1a856e2e5@amd.com>
Date:   Fri, 20 Jan 2023 11:15:48 -0600
From:   Tom Lendacky <thomas.lendacky@....com>
To:     Dionna Glaze <dionnaglaze@...gle.com>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, x86@...nel.org,
        Ashish Kalra <Ashish.Kalra@....com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Joerg Roedel <jroedel@...e.de>,
        Peter Gonda <pgonda@...gle.com>, Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH v3 2/2] kvm: sev: If ccp is busy, report throttled to
 guest

On 1/19/23 15:34, Dionna Glaze wrote:

Since you're building on SNP hypervisor patches, please keep @Ashish on 
direct copy.

> The ccp driver can be overloaded even with 1 HZ throttling. The return
> value of -EBUSY means that there is no firmware error to report back to
> user space, so the guest VM would see this as exitinfo2 = 0. The false
> success can trick the guest to update its the message sequence number
> when it shouldn't have.
> 
> Instead, when ccp returns -EBUSY, that is reported to userspace as the
> throttling return value.

Except the CCP driver doesn't return -EBUSY because it is overloaded. It 
will simply try to acquire the mutex and continue once it has it.

There are a couple of places that return -EBUSY in the driver for other 
reasons, as well as other -E* values. It looks like these need to be 
handled properly by the SNP hypervisor patches so that a "success" isn't 
reported back.

So this patch isn't necessary, but any -E* return value without having 
actually called the firmware needs to be handled properly. @Ashish, please 
work with Dionna on this.

Thanks,
Tom

> 
> Cc: Thomas Lendacky <Thomas.Lendacky@....com>
> Cc: Paolo Bonzini <pbonzini@...hat.com>
> Cc: Joerg Roedel <jroedel@...e.de>
> Cc: Peter Gonda <pgonda@...gle.com>
> Cc: Borislav Petkov <bp@...en8.de>
> 
> Signed-off-by: Dionna Glaze <dionnaglaze@...gle.com>
> ---
>   arch/x86/kvm/svm/sev.c | 18 ++++++++++++++++--
>   1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index cd9372ce6fc2..7da1cc300d7b 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -3642,7 +3642,14 @@ static void snp_handle_guest_request(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t
>   		goto unlock;
>   
>   	rc = sev_issue_cmd(kvm, SEV_CMD_SNP_GUEST_REQUEST, &data, &err);
> -	if (rc)
> +
> +	/*
> +	 * The ccp driver can return -EBUSY if the PSP is overloaded, so signal
> +	 * the request has been throttled.
> +	 */
> +	if (rc == -EBUSY)
> +		rc = SNP_GUEST_REQ_THROTTLED;
> +	else if (rc)
>   		/* use the firmware error code */
>   		rc = err;
>   
> @@ -3713,7 +3720,14 @@ static void snp_handle_ext_guest_request(struct vcpu_svm *svm, gpa_t req_gpa, gp
>   	if (sev->snp_certs_len)
>   		data_npages = sev->snp_certs_len >> PAGE_SHIFT;
>   
> -	if (rc) {
> +	/*
> +	 * The ccp driver can return -EBUSY if the PSP is overloaded, so signal
> +	 * the request has been throttled.
> +	 */
> +	if (rc == -EBUSY) {
> +		rc = SNP_GUEST_REQ_THROTTLED;
> +		goto cleanup;
> +	} else if (rc) {
>   		/*
>   		 * If buffer length is small then return the expected
>   		 * length in rbx.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ