From patchwork Sat Mar 9 19:21:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 779176 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp852975wrt; Sat, 9 Mar 2024 11:29:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWFgLCPHNDKTODsi2VrI+zi+vWznzm3MzEr6/R7lTEGL56LAXrchSFFx7oI9ZHdhygDdSUrUuokk2E9hiIu0lBV X-Google-Smtp-Source: AGHT+IEav/30h4TdFwP4YcY4VYINB3QmaiJrBf2myRRiaTZ9I6vpBlWXwbJgVqQ97mBcCYVACEyT X-Received: by 2002:a05:622a:100f:b0:42e:848a:95ab with SMTP id d15-20020a05622a100f00b0042e848a95abmr4132332qte.55.1710012579283; Sat, 09 Mar 2024 11:29:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1710012579; cv=none; d=google.com; s=arc-20160816; b=jWwc+p9EWad6sB+dYB3Cmq2Q5L8aECrCfmXIqLEdDDIjprU9Lt9mNs39AMEQ4z/Qq9 I8G1PbZG94s2a53KDlZuJGNkjg68jErgZAhp0IK6WVME2BR4m4RzhGn2GneZX2dPAuS2 yVpWqTVR2qp//B/WV/QX1HmObqWUh7LoIBZWO+1NeWJVrOSb60z01n36NXn129Zz9cbK FKPWX0xC1FM/wz1h++AUXkX9M12RUAsWGHmFr9Nzk2fPw7IzpVQX+7bJ1aOVn2nqj+XP pz7Juds3LRCWS8Mo3u2H0Vt7yOCywVwYUUrqeVq/vswstfjzqnscjMHhHspxTr13Lq9Y Qhow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w5JHLoxMjL6tDi9iKJsLNg13AWr77+ZJm44MiLunTng=; fh=VVL9S728RflAihtvP55z6aKvYX3tLnO/29oizXZqTzY=; b=lQwhedauFVFHHKtYcgPkphWRAw9euYN/g9vj80a6Pl9p1SGnydoIAEDhjeV+3V53f7 fwBQwfhXtMhBtlVkJSBR/GmpHGXHGCv1dPCTYkLkqpBALFpO1zlnznKYPFx9F3AdiMSy 4+GqG2TECC8jpYa1xOCCR91bE1YVuGmjr1Uv3Rkj6dI3CUTo66suLzmbNO5viMQzxPqU DIOI/VukXydzsnOdprBtfS97ZnLBW7DgQe/zbnbD4ChQRjl6f8WlVjeMXg3/JD0wg5Sj fBzlCqlLoufj8vUoV9dU7RpY4UP/l2nOHZOHPeQuFib8Dz1WZybC80BHNJOnYmtmIzDu AA0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MmdwC1MM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u38-20020a05622a19a600b0042ed109d771si2168219qtc.308.2024.03.09.11.29.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Mar 2024 11:29:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MmdwC1MM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rj2Is-000388-Q7; Sat, 09 Mar 2024 14:24:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rj2Iq-0002wW-OW for qemu-devel@nongnu.org; Sat, 09 Mar 2024 14:24:16 -0500 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rj2Ig-0002hZ-4y for qemu-devel@nongnu.org; Sat, 09 Mar 2024 14:24:16 -0500 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a293f2280c7so503132666b.1 for ; Sat, 09 Mar 2024 11:24:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710012244; x=1710617044; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w5JHLoxMjL6tDi9iKJsLNg13AWr77+ZJm44MiLunTng=; b=MmdwC1MMKT6KDmA3Pn+r4RpSuGSI8C7+rM0SgtGR6cwGOvYgZp2MR4UDT/QG/v19mx 3NNYJGQCskDz9cjNexhPl2ZbKvYMocnryyygfxtR7gYNLSgMICUk3DsvaOd5V4uoIPwD tNAUTcC+OzYhaDoVAOqQ1SH+A4TVqfVS4p96/Vr/ubemvSo6I34WHnJkbmPLNy5vNMf4 xyZ1ImbyBR/ZN5o0YQeAaMgVvcWOWQhGmwM1IeWh4QCo2/XuvI5pI5f9enyDThF9E7TQ uagd9fxoRwoGigd2tDvmwMPBVr8/jeW/3cwXes9XLugzwajlR4o0+ibNl8DxXz7LX17a DMlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710012244; x=1710617044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w5JHLoxMjL6tDi9iKJsLNg13AWr77+ZJm44MiLunTng=; b=bzFeU5/ZBnjEfqQBWdbEf984Lsr6vfP4oVyF1HLaI7RqjyJiL8RkIkSLew3GlLyJX8 Va+mVysWQrymEJ4X1X4sWBtMJ/R+Me9h7TNyf7S66q0mVkngF11TXNDQ17yYW27NrNnw 5W4XNcEyI1tqCxp+EL847qJvVKFp6WPCwi2rqWFij3IMIM0S4BBbG4vSeMTiiFHu7Rb+ 3B7MwwbbBeDtKtRJqM3uB/ONUIfGFwsiF8aKKefyni9w80SGxCv88xLy59LACpZPuTbb xlndcHJzN3iDoAkfek+NZvAvV2CQCor3XT4uPSUmVXVXQyMQFzLIWhxHVz3J2PIyNdiO jqFg== X-Gm-Message-State: AOJu0YwUdgZpRSDNVCNAyjQCamRvwndPrZnqWXhigBULKe7x/xdWAN8J e4hinR83IzNJn8r6AkisYuxtDUVaEt8WohsjQZO7jDw0uEMuEvs7oTRqZPpAY8qcSHY3xCOtlXT K X-Received: by 2002:a17:906:3984:b0:a44:1f3:e474 with SMTP id h4-20020a170906398400b00a4401f3e474mr1261620eje.23.1710012244545; Sat, 09 Mar 2024 11:24:04 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.237]) by smtp.gmail.com with ESMTPSA id w22-20020a1709067c9600b00a45a72fadfcsm1180096ejo.23.2024.03.09.11.24.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 09 Mar 2024 11:24:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Zhao Liu , Paolo Bonzini , Marcelo Tosatti , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org Subject: [PULL 18/43] target/i386/sev: Fix missing ERRP_GUARD() for error_prepend() Date: Sat, 9 Mar 2024 20:21:45 +0100 Message-ID: <20240309192213.23420-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240309192213.23420-1-philmd@linaro.org> References: <20240309192213.23420-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=philmd@linaro.org; helo=mail-ej1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Zhao Liu As the comment in qapi/error, passing @errp to error_prepend() requires ERRP_GUARD(): * = Why, when and how to use ERRP_GUARD() = * * Without ERRP_GUARD(), use of the @errp parameter is restricted: ... * - It should not be passed to error_prepend(), error_vprepend() or * error_append_hint(), because that doesn't work with &error_fatal. * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. ERRP_GUARD() could avoid the case when @errp is the pointer of error_fatal, the user can't see this additional information, because exit() happens in error_setg earlier than information is added [1]. The sev_inject_launch_secret() passes @errp to error_prepend(), and as an APIs defined in target/i386/sev.h, it is necessary to protect its @errp with ERRP_GUARD(). To avoid the issue like [1] said, add missing ERRP_GUARD() at the beginning of this function. [1]: Issue description in the commit message of commit ae7c80a7bd73 ("error: New macro ERRP_GUARD()"). Cc: Paolo Bonzini Cc: Marcelo Tosatti Signed-off-by: Zhao Liu Reviewed-by: Thomas Huth Message-ID: <20240229143914.1977550-17-zhao1.liu@linux.intel.com> Signed-off-by: Philippe Mathieu-Daudé --- target/i386/sev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index 173de91afe..72930ff0dc 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -1044,6 +1044,7 @@ sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp) int sev_inject_launch_secret(const char *packet_hdr, const char *secret, uint64_t gpa, Error **errp) { + ERRP_GUARD(); struct kvm_sev_launch_secret input; g_autofree guchar *data = NULL, *hdr = NULL; int error, ret = 1;