<feed xmlns='http://www.w3.org/2005/Atom'>
<title>laptop-kernel/drivers/char/tpm, branch master</title>
<subtitle>Linux kernel tree for laptop</subtitle>
<id>https://git.zx2c4.com/laptop-kernel/atom/drivers/char/tpm?h=master</id>
<link rel='self' href='https://git.zx2c4.com/laptop-kernel/atom/drivers/char/tpm?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/'/>
<updated>2026-09-29T19:15:21Z</updated>
<entry>
<title>tpm: Disable TPM on null key name mismatch</title>
<updated>2026-09-29T19:15:21Z</updated>
<author>
<name>Surendran Kanagaraj</name>
<email>surenkj@amazon.com</email>
</author>
<published>2026-09-18T00:07:31Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=015fb29a748342a186f37b602ac70017098c8251'/>
<id>urn:sha1:015fb29a748342a186f37b602ac70017098c8251</id>
<content type='text'>
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 &lt;surenkj@amazon.com&gt;
Link: https://lore.kernel.org/r/20260918000731.48657-1-surenkj@amazon.com
Reviewed-by: Gunnar Kudrjavets &lt;gunnarku@amazon.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: fix off-by-four bounds check in tpm2_get_random()</title>
<updated>2026-09-29T19:15:21Z</updated>
<author>
<name>Jiangshan Yi</name>
<email>yijiangshan@kylinos.cn</email>
</author>
<published>2026-09-03T03:58:37Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=9b522400bf5c082feb9a0037a053ea822a2c7e4d'/>
<id>urn:sha1:9b522400bf5c082feb9a0037a053ea822a2c7e4d</id>
<content type='text'>
When the response carries the TPM2_ST_SESSIONS tag, tpm2_get_random()
skips the 4-byte parameter size field before locating the random data,
but the bounds check still validates the response length against
TPM_HEADER_SIZE.  A truncated response can pass the check and make
memcpy() read up to 4 bytes past the response end, so stale buffer
contents end up in the caller's random bytes.

Fix this by checking the response length against 'offset', which
already includes the skipped parameter size field.

Cc: stable@vger.kernel.org #  v6.12+
Fixes: 1b6d7f9eb150 ("tpm: add session encryption protection to tpm2_get_random()")
Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Closes: https://sashiko.dev/#/patchset/20260902074839.417419-1-yijiangshan%40kylinos.cn
Signed-off-by: Jiangshan Yi &lt;yijiangshan@kylinos.cn&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Link: https://lore.kernel.org/r/20260903035837.219284-1-yijiangshan@kylinos.cn
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: Fix auth session leak in tpm2_get_random() error path</title>
<updated>2026-09-29T19:15:21Z</updated>
<author>
<name>Jiangshan Yi</name>
<email>yijiangshan@kylinos.cn</email>
</author>
<published>2026-09-02T07:48:39Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=1e2f9a611b334ce6ed1dc4a9e1587c7a11d2be30'/>
<id>urn:sha1:1e2f9a611b334ce6ed1dc4a9e1587c7a11d2be30</id>
<content type='text'>
When tpm_buf_fill_hmac_session() fails in tpm2_get_random(), the error
path returns without calling tpm2_end_auth_session(), leaking the auth
session. All other error paths in the function handle this correctly.

Fixes: 3d9e043dab0a ("tpm-buf: Memory-safe allocations")
Cc: stable@vger.kernel.orga # v6.12+
Signed-off-by: Jiangshan Yi &lt;yijiangshan@kylinos.cn&gt;
Link: https://lore.kernel.org/r/20260902074839.417419-1-yijiangshan@kylinos.cn
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: Fix heap buffer overflow in tpm_transmit_cmd()</title>
<updated>2026-09-29T19:15:20Z</updated>
<author>
<name>Jiangshan Yi</name>
<email>yijiangshan@kylinos.cn</email>
</author>
<published>2026-09-01T14:30:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=1a70f0b71826fb764e8490dda55bb1b853e0d1de'/>
<id>urn:sha1:1a70f0b71826fb764e8490dda55bb1b853e0d1de</id>
<content type='text'>
struct tpm_buf now uses an embedded flexible array for data, which is
6 bytes shorter than TPM_BUFSIZE due to the struct header. But
tpm_transmit_cmd() still passes PAGE_SIZE to tpm_transmit(), and after
clamping to TPM_BUFSIZE in tpm_try_transmit(), chip-&gt;ops-&gt;recv() can
write past the end of data[] by 6 bytes.

Pass buf-&gt;capacity to tpm_transmit() instead.

Fixes: 3d9e043dab0a ("tpm-buf: Memory-safe allocations")
Signed-off-by: Jiangshan Yi &lt;yijiangshan@kylinos.cn&gt;
Link: https://lore.kernel.org/r/20260901062850.379870-1-yijiangshan@kylinos.cn
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm-buf: Add TPM buffer support header for standalone reuse</title>
<updated>2026-08-25T15:13:37Z</updated>
<author>
<name>Ross Philipson</name>
<email>ross.philipson@gmail.com</email>
</author>
<published>2026-07-11T16:01:10Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=55ba91d4c54ab31ee8387bae40e799de467f8269'/>
<id>urn:sha1:55ba91d4c54ab31ee8387bae40e799de467f8269</id>
<content type='text'>
Extract all the functions and definitions for TPM buffer handling
and separate them into their own header.

Signed-off-by: Ross Philipson &lt;ross.philipson@gmail.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm-buf: Memory-safe allocations</title>
<updated>2026-08-25T15:13:36Z</updated>
<author>
<name>Jarkko Sakkinen</name>
<email>jarkko.sakkinen@opinsys.com</email>
</author>
<published>2026-07-11T16:01:09Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=3d9e043dab0a038a53a43570f60bbf4b1e27d63f'/>
<id>urn:sha1:3d9e043dab0a038a53a43570f60bbf4b1e27d63f</id>
<content type='text'>
Decouple kzalloc from buffer creation, so that a managed allocation can be
used:

	struct tpm_buf *buf __free(kfree) buf = kzalloc(TPM_BUFSIZE,
						GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	tpm_buf_init(buf, TPM_BUFSIZE);

Alternatively, other allocations are also possible (static data, stack,
etc) for example:

	u8 buf_data[512];
	struct tpm_buf *buf = (struct tpm_buf *)buf_data;
	tpm_buf_init(buf, sizeof(buf_data));

This is achieved by embedding buffer's header inside the allocated blob,
instead of having an outer wrapper.

Reviewed-by: Stefan Berger &lt;stefanb@linux.ibm.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@opinsys.com&gt;
Tested-by: Srish Srinivasan &lt;ssrish@linux.ibm.com&gt;
Message-ID: &lt;20260522013555.1063716-1-jarkko@kernel.org&gt;
Signed-off-by: Ross Philipson &lt;ross.philipson@oracle.com&gt;
</content>
</entry>
<entry>
<title>tpm-buf: Remove chip parameter from tpm_buf_append_handle()</title>
<updated>2026-08-25T15:13:36Z</updated>
<author>
<name>Jarkko Sakkinen</name>
<email>jarkko.sakkinen@opinsys.com</email>
</author>
<published>2026-07-11T16:01:08Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=065cfba1f4545e5948a2ddc5888a27c7641d5bfc'/>
<id>urn:sha1:065cfba1f4545e5948a2ddc5888a27c7641d5bfc</id>
<content type='text'>
Remove the TPM driver chip parameter from the function
tpm_buf_append_handle(). The chip parameter is only for error logging
which can be done with other facilities like WARN().

Message-ID: &lt;20260125192526.782202-11-jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@opinsys.com&gt;
Signed-off-by: Ross Philipson &lt;ross.philipson@gmail.com&gt;
</content>
</entry>
<entry>
<title>tpm-buf: Merge TPM_BUF_BOUNDARY_ERROR and TPM_BUF_OVERFLOW</title>
<updated>2026-08-25T15:13:36Z</updated>
<author>
<name>Jarkko Sakkinen</name>
<email>jarkko.sakkinen@opinsys.com</email>
</author>
<published>2026-07-11T16:01:07Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=0b9551c189518544b65000a234277298e931c8f3'/>
<id>urn:sha1:0b9551c189518544b65000a234277298e931c8f3</id>
<content type='text'>
Merge TPM_BUF_BOUNDARY_ERROR and TPM_BUF_OVERFLOW flags into
the TPM_BUF_INVALID flag, as their behavior is identical (the only
difference being the associated log messages).

Message-ID: &lt;20260125192526.782202-11-jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@opinsys.com&gt;
Reviewed-by: Jonathan McDowell &lt;noodles@meta.com&gt;
Signed-off-by: Ross Philipson &lt;ross.philipson@gmail.com&gt;
</content>
</entry>
<entry>
<title>tpm: Move platform specific definitions to the new PTP header</title>
<updated>2026-08-25T15:13:35Z</updated>
<author>
<name>Ross Philipson</name>
<email>ross.philipson@gmail.com</email>
</author>
<published>2026-07-11T16:01:05Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=5467ade151973477742af922cc33bb30e816af42'/>
<id>urn:sha1:5467ade151973477742af922cc33bb30e816af42</id>
<content type='text'>
These are definitions for TPM 2.0 interface and interactions with
the platform as defined in the TCG specification:

These definitions are located here in a separate file to avoid conflicts
with vendor specific TIS/FIFO definition (e.g. STMicroelectronics,
Infineon Technologies, etc). This allows the TCG defined TIS/FIFO
interface to be in a public header while the former chip specific
implementations contain their own definitions. TPM 1.x family chips
that adhere to the TCG specifications use the TIS/FIFO interface as
defined here.

TCG PC Client Platform TPM Profile (PTP) Specification
 - https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/

Co-developed-by: Daniel P. Smith &lt;dpsmith@apertussolutions.com&gt;
Signed-off-by: Daniel P. Smith &lt;dpsmith@apertussolutions.com&gt;
Co-developed-by: Alec Brown &lt;alec.r.brown@oracle.com&gt;
Signed-off-by: Alec Brown &lt;alec.r.brown@oracle.com&gt;
Signed-off-by: Ross Philipson &lt;ross.philipson@gmail.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: Move TPM common base definitions to the command header</title>
<updated>2026-08-25T15:13:35Z</updated>
<author>
<name>Ross Philipson</name>
<email>ross.philipson@gmail.com</email>
</author>
<published>2026-07-11T16:01:04Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/laptop-kernel/commit/?id=88c5a62c3af7ca6f36dc6ffc52bcfb29cd2990cb'/>
<id>urn:sha1:88c5a62c3af7ca6f36dc6ffc52bcfb29cd2990cb</id>
<content type='text'>
These are top level definitions shared by both TPM 1 and 2
family chips. This includes core definitions like TPM localities,
common crypto algorithm IDs, and the base TPM command header.

Co-developed-by: Daniel P. Smith &lt;dpsmith@apertussolutions.com&gt;
Signed-off-by: Daniel P. Smith &lt;dpsmith@apertussolutions.com&gt;
Co-developed-by: Alec Brown &lt;alec.r.brown@oracle.com&gt;
Signed-off-by: Alec Brown &lt;alec.r.brown@oracle.com&gt;
Signed-off-by: Ross Philipson &lt;ross.philipson@gmail.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
</feed>
