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 CE28A4E2F1B; Fri, 9 Oct 2026 14:21:22 +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=1791555683; cv=none; b=Dtr3zd1zT+DLLs+4eVfz7M94L2xA2bPzsZWEyEMkLezCKWybpmsBZZJa+JbX+ijYtmbRdIr+YPC/rtfKYDOwEPpaIHxy9ozh2Bag4MmRm8qqp/MT5veHDcvkbQLXw0mBLbDGpuv4xuXhx8vim2eaQeyuqCm068vqjkoOiPdAgkk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791555683; c=relaxed/simple; bh=kcAs9IMUspENw1XwcZlC1AdUQydBQkB8OPy6ptB7QuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=US7OzAn1O5MVb8FNJ1HzS5iN9nlAwaRlCHoYVJRYCVvoWMQV/dho1zy6TXqfYhD7nkuwXP66RxEUdNrECFL6L7xudISnFmisqKI1K00bD3dVKk7z4H7nEysEIlsQPKvSV+YXJq9uvIOMXxw58imhVpkSkmYY2JNRk6JuQUu/iAs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Fy0sK07R; 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="Fy0sK07R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C3891F000FF; Fri, 9 Oct 2026 14:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791555682; bh=sqsIvZU2CLNGGq08v2jKp76WPbjfB6sUO1obBd2tS8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Fy0sK07RzY3j9CPhEQ2SKth9lpVL1Ol86Hz29tqywKf2THzMyvRyHW5zytv3KRTN9 XTUE7Rz3DlPieom4GYko7UkHKv2Bku7Kvlphuo60NkZRS9WFpkH3HGd1LQiG11XJCU t40qZ7CSuDOJiHK2In7WzmTJBWV3pE7qryhDXCkU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Surendran Kanagaraj , Gunnar Kudrjavets , Jarkko Sakkinen Subject: [PATCH 7.2 048/428] tpm: Disable TPM on null key name mismatch Date: Fri, 9 Oct 2026 16:06:25 +0200 Message-ID: <20261009140947.168415009@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140946.008206689@linuxfoundation.org> References: <20261009140946.008206689@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Surendran Kanagaraj commit 015fb29a748342a186f37b602ac70017098c8251 upstream. The null key name check exists to protect against TPM reset attacks, so a mismatch should stop the device from serving further requests. Currently it does not disable the chip when it finds a mismatch. The mismatch is logged: tpm tpm0: null key integrity check failed but the chip keeps serving commands: / # tpm2_getcap -c properties-fixed TPM_PT_FAMILY_INDICATOR: as UINT32: 0x08322e3000 as string: "2.0" ... tpm2_load_null() where the null key name check is run sets the chip as disabled only if the rc is non zero. When the mismatch is seen, rc is zero at that point and it returns success. The other issue is that the caller expects the null key handle to be populated when the function returns 0 which it does here without writing the handle and proceeds assuming the null key handle is valid. During the test, I noticed that tpm2_start_auth_session() uses the uninitialized stack value as the key handle since tpm2_load_null() returns 0 despite the integrity failure and proceeds with TPM2_CC_START_AUTH_SESS with this value as salt key handle. Set rc to -ENODEV on the mismatch. The error path then disables the chip and returns the correct code to the caller. Tested in QEMU with swtpm and CONFIG_TCG_TPM2_HMAC=y by making TPM2_CC_CONTEXT_LOAD fail with TPM2_RC_INTEGRITY and changing the name of the re-created null key. The chip is now disabled on the mismatch. Fixes: cc7d8594342a ("tpm: Rollback tpm2_load_null()") Fixes: 423893fcbe7e ("tpm: Disable TPM on tpm2_create_primary() failure") Cc: stable@vger.kernel.org # v6.12+ Assisted-by: LLM Signed-off-by: Surendran Kanagaraj Link: https://lore.kernel.org/r/20260918000731.48657-1-surenkj@amazon.com Reviewed-by: Gunnar Kudrjavets Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm2-sessions.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/char/tpm/tpm2-sessions.c +++ b/drivers/char/tpm/tpm2-sessions.c @@ -985,6 +985,7 @@ static int tpm2_load_null(struct tpm_chi /* Deduce from the name change TPM interference: */ dev_err(&chip->dev, "null key integrity check failed\n"); tpm2_flush_context(chip, tmp_null_key); + rc = -ENODEV; err: if (rc) {