mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dionna Glaze <dionnaglaze@google.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Dionna Glaze <dionnaglaze@google.com>,
	Tom Lendacky <Thomas.Lendacky@amd.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Joerg Roedel <jroedel@suse.de>, Peter Gonda <pgonda@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Dave Hansen <dave.hansen@linux.intel.com>
Subject: [PATCH v4 3/4] virt/coco/sev-guest: Remove err in handle_guest_request
Date: Mon, 24 Oct 2022 22:46:56 +0000	[thread overview]
Message-ID: <20221024224657.2917482-4-dionnaglaze@google.com> (raw)
In-Reply-To: <20221024224657.2917482-1-dionnaglaze@google.com>

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. Since the issue_request's
signature has changed fw_err to exitinfo2, we change the argument name
here.

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>

Fixes: fce96cf04430 ("virt: Add SEV-SNP guest driver")
Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
---
 drivers/virt/coco/sev-guest/sev-guest.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
index f422f9c58ba7..0508c2f46f6b 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -303,9 +303,8 @@ static int enc_payload(struct snp_guest_dev *snp_dev, u64 seqno, int version, u8
 
 static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, int msg_ver,
 				u8 type, void *req_buf, size_t req_sz, void *resp_buf,
-				u32 resp_sz, __u64 *fw_err)
+				u32 resp_sz, __u64 *exitinfo2)
 {
-	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, exitinfo2);
 
 	if (rc)
 		return rc;
-- 
2.38.0.135.g90850a2211-goog


  parent reply	other threads:[~2022-10-25  0:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24 22:46 [PATCH v4 0/4] Add throttling detection to sev-guest Dionna Glaze
2022-10-24 22:46 ` [PATCH v4 1/4] ccp: Name -1 return value as SEV_RET_NO_FW_CALL Dionna Glaze
2022-10-28 14:35   ` Tom Lendacky
2022-10-24 22:46 ` [PATCH v4 2/4] x86/sev: Change snp_guest_issue_request's fw_err Dionna Glaze
2022-10-27 16:09   ` Peter Gonda
2022-10-27 16:11     ` Dionna Amalie Glaze
2022-10-28 14:45   ` Tom Lendacky
2022-10-24 22:46 ` Dionna Glaze [this message]
2022-10-28 14:46   ` [PATCH v4 3/4] virt/coco/sev-guest: Remove err in handle_guest_request Tom Lendacky
2022-10-24 22:46 ` [PATCH v4 4/4] virt/coco/sev-guest: interpret VMM errors from guest request Dionna Glaze
2022-10-28 15:15   ` Tom Lendacky
2022-10-28 15:57     ` Dionna Amalie Glaze
2022-10-27 15:53 ` [PATCH v4 0/4] Add throttling detection to sev-guest Dionna Amalie Glaze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221024224657.2917482-4-dionnaglaze@google.com \
    --to=dionnaglaze@google.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®