* [PATCH v2] virt/coco/sev-guest: Remove err in handle_guest_request
@ 2022-10-19 19:58 Dionna Glaze
2022-10-19 20:32 ` Tom Lendacky
0 siblings, 1 reply; 3+ messages in thread
From: Dionna Glaze @ 2022-10-19 19:58 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Dionna Glaze, Tom Lendacky, Paolo Bonzini, Joerg Roedel,
Peter Gonda, Thomas Gleixner, Dave Hansen
The err variable may not be set in the call to snp_issue_guest_request,
yet it is unconditionally written back to fw_err if fw_err is non-null.
This is undefined behavior, and currently returns uninitialized kernel
stack memory to user space.
The fw_err argument is better to just pass through to
snp_issue_guest_request, so we do that.
Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Peter Gonda <pgonda@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
---
drivers/virt/coco/sev-guest/sev-guest.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
index f422f9c58ba7..00708b4491e0 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -305,7 +305,6 @@ static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, in
u8 type, void *req_buf, size_t req_sz, void *resp_buf,
u32 resp_sz, __u64 *fw_err)
{
- unsigned long err;
u64 seqno;
int rc;
@@ -322,9 +321,7 @@ static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, in
return rc;
/* Call firmware to process the request */
- rc = snp_issue_guest_request(exit_code, &snp_dev->input, &err);
- if (fw_err)
- *fw_err = err;
+ rc = snp_issue_guest_request(exit_code, &snp_dev->input, fw_err);
if (rc)
return rc;
--
2.38.0.413.g74048e4d9e-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] virt/coco/sev-guest: Remove err in handle_guest_request
2022-10-19 19:58 [PATCH v2] virt/coco/sev-guest: Remove err in handle_guest_request Dionna Glaze
@ 2022-10-19 20:32 ` Tom Lendacky
2022-10-20 16:18 ` Dionna Amalie Glaze
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lendacky @ 2022-10-19 20:32 UTC (permalink / raw)
To: Dionna Glaze, x86, linux-kernel
Cc: Paolo Bonzini, Joerg Roedel, Peter Gonda, Thomas Gleixner, Dave Hansen
On 10/19/22 14:58, Dionna Glaze wrote:
> The err variable may not be set in the call to snp_issue_guest_request,
> yet it is unconditionally written back to fw_err if fw_err is non-null.
> This is undefined behavior, and currently returns uninitialized kernel
> stack memory to user space.
>
> The fw_err argument is better to just pass through to
> snp_issue_guest_request, so we do that.
>
> Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Joerg Roedel <jroedel@suse.de>
> Cc: Peter Gonda <pgonda@google.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
>
> Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
You should include a Fixes: tag.
With that,
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Also, you may want to base your other series [1] on this one, since you'll
likely get conflicts if this is applied first.
[1] https://lore.kernel.org/lkml/20221019173537.1238121-1-dionnaglaze@google.com/
Thanks,
Tom
> ---
> drivers/virt/coco/sev-guest/sev-guest.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
> index f422f9c58ba7..00708b4491e0 100644
> --- a/drivers/virt/coco/sev-guest/sev-guest.c
> +++ b/drivers/virt/coco/sev-guest/sev-guest.c
> @@ -305,7 +305,6 @@ static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, in
> u8 type, void *req_buf, size_t req_sz, void *resp_buf,
> u32 resp_sz, __u64 *fw_err)
> {
> - unsigned long err;
> u64 seqno;
> int rc;
>
> @@ -322,9 +321,7 @@ static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, in
> return rc;
>
> /* Call firmware to process the request */
> - rc = snp_issue_guest_request(exit_code, &snp_dev->input, &err);
> - if (fw_err)
> - *fw_err = err;
> + rc = snp_issue_guest_request(exit_code, &snp_dev->input, fw_err);
>
> if (rc)
> return rc;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] virt/coco/sev-guest: Remove err in handle_guest_request
2022-10-19 20:32 ` Tom Lendacky
@ 2022-10-20 16:18 ` Dionna Amalie Glaze
0 siblings, 0 replies; 3+ messages in thread
From: Dionna Amalie Glaze @ 2022-10-20 16:18 UTC (permalink / raw)
To: Tom Lendacky
Cc: x86, linux-kernel, Paolo Bonzini, Joerg Roedel, Peter Gonda,
Thomas Gleixner, Dave Hansen
>
> You should include a Fixes: tag.
>
> With that,
> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
>
> Also, you may want to base your other series [1] on this one, since you'll
> likely get conflicts if this is applied first.
>
> [1] https://lore.kernel.org/lkml/20221019173537.1238121-1-dionnaglaze@google.com/
>
Let's call this a wash and I'll roll this into that other series then.
By passing through fw_err directly, I get an unsigned long vs unsigned
long long type error (in this v2, mea culpa). So I'll put the rename
and re-typing in the x86 patch before this one.
--
-Dionna Glaze, PhD (she/her)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-20 16:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 19:58 [PATCH v2] virt/coco/sev-guest: Remove err in handle_guest_request Dionna Glaze
2022-10-19 20:32 ` Tom Lendacky
2022-10-20 16:18 ` Dionna Amalie Glaze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®