From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5615A28505E; Thu, 16 Jul 2026 14:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784211255; cv=none; b=nlQElP6/fUpKU3HF9IS0UNN6oEmSHcFie5qN/U3p5xIsJGiORY4jRKmSEZSH2EiAZ02ohsDCJuL+/i2kuZtLarf29HD6B4/1uNsFk7AereATLKVwbsp2esfNb3f3DxKWulqbslYTLUq3J+Syx+MdqdAAzkm6z1rF/DkPgGVRLik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784211255; c=relaxed/simple; bh=yIYv86QmFR/2YQmcq2wu1hgGjjcvKCmsVvegZOS8s0c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FeR27+M9Y1Lmc0KBSBXVlLWNMgiI7Q3zr1phX1JOjXcGNWyFD7dRz+Vi2LRHp/GsBMsS3FpH7AZoHasKO43MsrN5zGK7+gD/o0jHM+YzEpABAKbkfRGpkPQf+NNAbK5B05zNGYEA/pGwStZtPrIVvv3ClFSdb+LFftt8tmVjBsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xjBoBVN2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xjBoBVN2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B18EF1F00A3A; Thu, 16 Jul 2026 14:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784211254; bh=lgPkXbOupSmTV+rSkz1iataMR62GA8HcCo+iKP5bXU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xjBoBVN27WvAMRlnE8IWsxBgUmeEIZ1qQaEFXNa6Fj2xGSVQGeQkRlJo8cVPt3LCJ LZtX6CP7eFsfzyI5GzK+49d2fcqSQCD+m2mqmJGjq1FzL+5X4oje5dCUuoPRIPRuao S3rUBxGZ8IOkelP2IjK5jAQ1TmV/IAqWBYMSgPHA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Tycho Andersen (AMD)" , Tom Lendacky , Herbert Xu Subject: [PATCH 6.18 357/480] crypto: ccp - Do not initialize SNP for ioctl(SNP_COMMIT) Date: Thu, 16 Jul 2026 15:31:44 +0200 Message-ID: <20260716133052.526259215@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133044.672218725@linuxfoundation.org> References: <20260716133044.672218725@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tycho Andersen (AMD) commit 5a1364da2f04217a36e2fdfa2db4ee025b383a20 upstream. Sashiko notes: > if SEV initialization fails and KVM is actively running normal VMs, could a > userspace process trigger this code path via /dev/sev ioctls (e.g., > SEV_PDH_GEN) and zero out MSR_VM_HSAVE_PA globally? Would the next VMRUN > execution for an active VM trigger a general protection fault and crash the > host? The SNP_COMMIT command does not require the firmware to be in any particular state. Skip initializing it if it was previously uninitialized. The SEV-SNP firmware specification doc 56860 does not mention SNP_COMMIT in Table 5 as a command that is allowed in the UNINIT state, but it is in fact allowed and a future documentation update will reflect that. Fixes: ceac7fb89e8d ("crypto: ccp - Ensure implicit SEV/SNP init and shutdown in ioctls") Reported-by: Sashiko Assisted-by: Gemini:gemini-3.1-pro-preview Link: https://sashiko.dev/#/patchset/20260324161301.1353976-1-tycho%40kernel.org CC: Signed-off-by: Tycho Andersen (AMD) Reviewed-by: Tom Lendacky Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccp/sev-dev.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -2411,24 +2411,13 @@ cleanup: static int sev_ioctl_do_snp_commit(struct sev_issue_cmd *argp) { - struct sev_device *sev = psp_master->sev_data; struct sev_data_snp_commit buf; - bool shutdown_required = false; - int ret, error; - - if (!sev->snp_initialized) { - ret = snp_move_to_init_state(argp, &shutdown_required); - if (ret) - return ret; - } + int ret; buf.len = sizeof(buf); ret = __sev_do_cmd_locked(SEV_CMD_SNP_COMMIT, &buf, &argp->error); - if (shutdown_required) - __sev_snp_shutdown_locked(&error, false); - return ret; }