From nobody Mon Jun 8 07:24:56 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 48DA83D412B; Fri, 5 Jun 2026 21:25:11 +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=1780694712; cv=none; b=I44iSSO+2A6+rM/Ke1nzD3hE5tXuzEfwf8Xx8eCK9AhDCL65taXDUixi5b/NA9owjm55kwx5C/7it4R1XPzCCOFwtwA08YTqB4cf9flV4n09u4652Uv6Fd47REQEgtE+znXj3S/0XnpItL+d6QDgC7kQHItjHF/xSMzBavl8UHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780694712; c=relaxed/simple; bh=sF4x1L9HWcqRrNKk7Ot8KP45ljpq3o4/di0LfNuVCJ4=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=pmqXmvFFbPlMfyQ59NtRajV0gwWUNihs9aj0vvQYMoic1lxbP/qhyA+o4DFufkbvkX3n63cW/jVLbgn/rnoNwKfWSxQLx6ZMIqrc2SR6WkZtrPQ1AiFMABnWCn66Hoe8vz0xcmEPRFFbv+pGElKd107pywytIrFXvdwDr6hgiro= 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=mgZf3fkC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9cN1x7dD; 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="mgZf3fkC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9cN1x7dD" Date: Fri, 05 Jun 2026 21:25:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780694710; 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=R20PXMi72bZ4a4krfx5JEwInwluoM9St9xNvG3cw2YY=; b=mgZf3fkCxSNZdvmOySyZiIqCE9Og0WkeVveDB60130CxeLzA6IgiTyLGN3p8mxt1BX7uc0 F761yh6QKro1QZmfbqkzj638ZFJeBcec5233YGlUhTbQ8Bu5Rp+lQZkHNB5MbdTQU0NQxK i33I+0GvfDZObzRIMMShrb8K99iU6N9+5ZD8x9LDXp8/tAWdGqSi82zn4guCyjO4OoRC8a gY29KvsLhXjsFxAH0qFEC8IGlIytgm94TfLLEgVPzlm+aja95lQdmOlSCMI2Zwf4aZBfql rjl0V/VMSm2ZH1u72JpW0TNc4zPNFECm1j0L0bxNR/k75VFP+NVyfDWlaQw2Cw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780694710; 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=R20PXMi72bZ4a4krfx5JEwInwluoM9St9xNvG3cw2YY=; b=9cN1x7dDzptJd8AGCIYxf7t6KotSlhtwB8IoYmtjjuxPprAEjkrRoWS4KREhw2k5K8c4+9 HZUb/dYDzK3tpMAw== 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: <178069470859.710.12841368944767241297.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: 8d1376e6b0e6d98bed8e7d14fa8587a1d1139e93 Gitweb: https://git.kernel.org/tip/8d1376e6b0e6d98bed8e7d14fa8587a1d= 1139e93 Author: Dave Hansen AuthorDate: Fri, 22 May 2026 08:56:29 -07:00 Committer: Dave Hansen CommitterDate: Wed, 03 Jun 2026 08:59:44 -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