From patchwork Mon Oct 24 22:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dionna Amalie Glaze X-Patchwork-Id: 10420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp723048wru; Mon, 24 Oct 2022 17:28:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7c7j2jXN4FczVsGfdqfgB+G4Z/JOuO00iJGYIb/A9Mg+uY/1/4Iop1FY3z6uswu9lQeGLD X-Received: by 2002:a05:6402:380a:b0:451:ae08:7a6c with SMTP id es10-20020a056402380a00b00451ae087a6cmr32193541edb.161.1666657685439; Mon, 24 Oct 2022 17:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666657685; cv=none; d=google.com; s=arc-20160816; b=NB4DJxPUIjWogIDiRBS9NPNvgeAQyBy59KwwiLDBk3bjen8X8rP3AUKoGlfI3e9rgZ JAfd6HyjLlZHalAaLDjP7rUS8Rb3hqCaw6xL03GBuop4+v3hk6l4o1ZE1denP9mYM9kh d/vxiVxx5YhGdXnocQUuq3TbgD4p5Of6K8PZ0djgzW1Gpwj28SV4AA9brHBHTed8exf0 6UXaOMMANTCLHSupZsVZpWhB8X/RnmbIrUPp8A6Y++Sl+l5MJHz/BA1h7gtI7RiYfbIA zsxhvFc0NLPzGqd2iXbOv03Qb8Ttvw6skK+DZPsrw9igGoaSw58HONQxsoGkt34Wf3Js b6Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=t50s+W2sjRzmfaqPHM8BWoKuylKuq2NrCynpVhPS9Gk=; b=CxOZBZD2wnLTN4cZhU1t7RpVBrQ6AsFz1EZqbp08h933u37as7gikqTlemCMD+mA7t 82zQzZCr0pFBLLvZAP6RPD5lBx52IkuGg1Q1ZjsoURxqVspxRchf+Ke5Q0WWE27PCXsf Ja+q6zr7och2EmhQFb3WX4n220A35cowWfpHKAqrA+RQUg7mO103NlFHSVrnXz7sI/I3 0KMbIFxRyU6uYOEhz5KzPRlZTyFOdPZ4mYPtSZTu3Ob+tgAx9Nqfi1TCsn1IvBE5u5fP zJ5DCgcUDneunqYzQGtLm+BDm1vIIVChH8arPP9O7eKfRF5LnhCGQ1oDfamFADkoBFPL bJEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VukVbYSP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bt9-20020a0564020a4900b00461f10cb543si1113851edb.154.2022.10.24.17.27.42; Mon, 24 Oct 2022 17:28:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VukVbYSP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbiJYAYR (ORCPT + 99 others); Mon, 24 Oct 2022 20:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbiJYAX2 (ORCPT ); Mon, 24 Oct 2022 20:23:28 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6760FCC827 for ; Mon, 24 Oct 2022 15:47:06 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id cb7-20020a056a00430700b00561b86e0265so5287228pfb.13 for ; Mon, 24 Oct 2022 15:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=t50s+W2sjRzmfaqPHM8BWoKuylKuq2NrCynpVhPS9Gk=; b=VukVbYSP3OxCt2Aov1s0MXfB7/bJ8+HJOcG+qkdTnvVwyqSeEysxQibuYGQUZ3GZHb LQo/uctV2e8+FXtRqm1w3rlwt5gYx58CGxPrKqoR0yeaP8JfVnpR+nP6OXi9wVTzBBl9 AXKCdAMTHbE1mKJISj2iUiRLdw6PTThAzbg+o+a8LaRJc82/oAFNbu6ylNV6osG+qHp8 m5CycDkb++iVbaZA3ZFPyLWI3Z7GFGvKnDD+R/CQ2yo1ag9cs5xDXCH6qE743Q8S1mOq S/kRVHwrJWzq6x1OLj+u3ATxd/9s8S1RZ3/NisX1JirkpZVY76wYTLHgmfhH45U6kaxx 3HAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t50s+W2sjRzmfaqPHM8BWoKuylKuq2NrCynpVhPS9Gk=; b=Bul4N3EFuhyyXyM0v7Gbm1d9wFFgTUVjuIKWIHKOuppIg2F7Bz4nkx+J5o4POFYv3l HYnOtvcWFn3OKCabFBUFiqc2aTg8cydtGotepVr3ywQdg8v8idvrP6oOOo/Bf4+OD1Hx FqFoHRM0cLfN7GPcPnsKqrYMkS7t0vLU2Yqay4avMQ9195DYH4f/HON/Ev13b+HkGzEc 936fs5uRUjEVUHI0VHmTPG99aj8ZZ07YyDx0YtJYwCadf502dnuizn04jYhuI1mV9iz6 blKSsvjcEgzARRO85DZfwQ322W2OovDd5zV3qvFuqc5yUrXsu9MjSnjDuSiQ99N9eE6L H0tw== X-Gm-Message-State: ACrzQf09eT6O4CMoDHFdqin1H9KQ/hzLVQprOQjK28iSmSaKlYSpPgjj yjX3a+Rw/cjFPLv+x7DjALe8zPxdu0iDUV51U+aE0+D/Il00jy9enBD6RpdVHjSkrnp7Yn0HEWt 3Zcqgx9EsHJeTIl/NyLftAJjZ2ZoHM4BKFFF1VuwwogUF0qLKIQQghOcMN2UepqRMwxq9mr55J9 wtW/Hipn4= X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90a:4811:b0:20a:fee1:8f69 with SMTP id a17-20020a17090a481100b0020afee18f69mr4038806pjh.0.1666651625380; Mon, 24 Oct 2022 15:47:05 -0700 (PDT) Date: Mon, 24 Oct 2022 22:46:56 +0000 In-Reply-To: <20221024224657.2917482-1-dionnaglaze@google.com> Mime-Version: 1.0 References: <20221024224657.2917482-1-dionnaglaze@google.com> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog Message-ID: <20221024224657.2917482-4-dionnaglaze@google.com> Subject: [PATCH v4 3/4] virt/coco/sev-guest: Remove err in handle_guest_request From: Dionna Glaze To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Dionna Glaze , Tom Lendacky , Paolo Bonzini , Joerg Roedel , Peter Gonda , Thomas Gleixner , Dave Hansen X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747617249225465112?= X-GMAIL-MSGID: =?utf-8?q?1747617249225465112?= 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 Cc: Paolo Bonzini Cc: Joerg Roedel Cc: Peter Gonda Cc: Thomas Gleixner Cc: Dave Hansen Fixes: fce96cf04430 ("virt: Add SEV-SNP guest driver") Signed-off-by: Dionna Glaze Reviewed-by: Tom Lendacky --- 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;