From nobody Mon Jun 8 20:53:16 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D890437B01E; Tue, 26 May 2026 15:43:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779810236; cv=none; b=Q/Py5iZo5ZOyZvHnx2J/4X5NE64VdCKMsc3IZS9MNALvaja9NVVBtj09rA1K5RUhyfKgAIBVWuMss1rlljrnRfbj17iqhvl8E0SMbCljip5T3TQJ9UUFMRR4XUP18XT40u80nxYQeumVx9MCQVcsp0vJzG2hvqX8nninlaC/f1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779810236; c=relaxed/simple; bh=xswy/ZI8855+/iI3+pwID95mnx03jChcIwiPXBQo9j4=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=emFEuYIH0OtKM+dDju93X8HHBFVpezwj95S9vMGMwJlveugY6MysWn+/GDS0aVJvxdD6CI/ynhxyPKrhN/fmaFcS3y934rAaL6e+r/RAH+ksxmNARZoxrw+1hsc496ATlL6WU/FDBpy6xT0Gduy1MoOOuBa+Tp3QLKOjw9a9xzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=q/kG7DpO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HW0ttw0D; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="q/kG7DpO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HW0ttw0D" Date: Tue, 26 May 2026 15:43:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779810233; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qtxnvfuGmUaGN6OZxbw2Z7t2q/bOFS6BXI983y96P90=; b=q/kG7DpOL5Xa3TtFIgugIO7/3wuft/GXk3Ww0Aip9t+J4y+i75wTmkrDDVvE1WFdajlDnW /QAcA2hDrw0ZTT+ZUJhYRUXg4qPLUkDhE7ehwhC2/EFfV3Y9XunSRnP4iwp1ijJsoQU8A+ rif3R7Rq1MlDKSFEN06Myb7/5cmX755Qxo0gm+CvSWRpP4O+T45i8dJNn5230kFsg2jVOS AVYi3tOJaEq/04BH2WBIDimQJTaj2Yyl0qfsVRceFbaa+R7iO3+OC0I3XxeibXT7YD2TbN aBkxiXDp6N0hx3eGuk24UOcjs9j2vBNObUWvGoPlZ42ei+BoLWG3VguSDUZgFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779810233; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qtxnvfuGmUaGN6OZxbw2Z7t2q/bOFS6BXI983y96P90=; b=HW0ttw0D4YtWQ5fkx4Zaw2czWMei2AhGT6jhMq2bqVU0rjDhbEPVJzca6rhgsOcOT9JLc9 Vf5EJCv6MuhAAPAw== From: "tip-bot2 for Dave Hansen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/tdx] coco/tdx-host: Lock out module updates when reading version Cc: Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177981023215.1039918.9202575390771633110.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/tdx branch of tip: Commit-ID: bd0ba697612ab463b1ba9bbe725fbb0c88a15cb3 Gitweb: https://git.kernel.org/tip/bd0ba697612ab463b1ba9bbe725fbb0c8= 8a15cb3 Author: Dave Hansen AuthorDate: Fri, 22 May 2026 08:56:29 -07:00 Committer: Dave Hansen CommitterDate: Tue, 26 May 2026 08:41:51 -07:00 coco/tdx-host: Lock out module updates when reading version The TDX module version is currently stashed in some global variables and dumped out to sysfs without locking. This works fine when the version is static and never changes. But with runtime module updates, the TDX module version can change. Some kind of locking is needed. Barring this, userspace could theoretically see a strange torn module version that is some Frankenstein version from from two different updates. Use the new module update lock/unlock to prevent updates while trying to read the version. Don't be fussy about it. There's no need to snapshot the version or do READ_ONCE(), or minimize lock holding times. sysfs_emit() does not sleep. Also note that the lock/unlock are backed by preempt_dis/enable() which are really cheap CPU-local operations. This is not a heavyweight lock. Signed-off-by: Dave Hansen --- drivers/virt/coco/tdx-host/tdx-host.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/virt/coco/tdx-host/tdx-host.c b/drivers/virt/coco/tdx-= host/tdx-host.c index e5a672b..d489529 100644 --- a/drivers/virt/coco/tdx-host/tdx-host.c +++ b/drivers/virt/coco/tdx-host/tdx-host.c @@ -26,15 +26,24 @@ static ssize_t version_show(struct device *dev, struct = device_attribute *attr, { const struct tdx_sys_info *tdx_sysinfo =3D tdx_get_sysinfo(); const struct tdx_sys_info_version *ver; + int ret; =20 if (!tdx_sysinfo) return -ENXIO; =20 + /* + * The version number can change during an update. + * Lock out updates while printing the version. + */ + seamldr_lock_module_update(); + ver =3D &tdx_sysinfo->version; + ret =3D sysfs_emit(buf, TDX_VERSION_FMT "\n", ver->major_version, + ver->minor_version, + ver->update_version); + seamldr_unlock_module_update(); =20 - return sysfs_emit(buf, TDX_VERSION_FMT "\n", ver->major_version, - ver->minor_version, - ver->update_version); + return ret; } static DEVICE_ATTR_RO(version); =20