<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/char/tpm/tpm2-cmd.c, branch master</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=master</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-12-05T04:42:51Z</updated>
<entry>
<title>tpm2-sessions: Open code tpm_buf_append_hmac_session()</title>
<updated>2025-12-05T04:42:51Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2025-09-30T20:44:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b7960b90486139022d2d39caad90db252c469bab'/>
<id>urn:sha1:b7960b90486139022d2d39caad90db252c469bab</id>
<content type='text'>
Open code 'tpm_buf_append_hmac_session_opt' to the call site, as it only
masks a call sequence and does otherwise nothing particularly useful.

Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@opinsys.com&gt;
Reviewed-by: Jonathan McDowell &lt;noodles@meta.com&gt;
</content>
</entry>
<entry>
<title>tpm2-sessions: Remove 'attributes' parameter from tpm_buf_append_auth</title>
<updated>2025-12-05T04:42:51Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2025-09-30T13:07:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bc677a9216e1396322e42692e9c01cce04a7afc0'/>
<id>urn:sha1:bc677a9216e1396322e42692e9c01cce04a7afc0</id>
<content type='text'>
Remove 'attributes' parameter from 'tpm_buf_append_auth', as it is not used
by the function.

Fixes: 27184f8905ba ("tpm: Opt-in in disable PCR integrity protection")
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@opinsys.com&gt;
Reviewed-by: Jonathan McDowell &lt;noodles@meta.com&gt;
</content>
</entry>
<entry>
<title>tpm2-sessions: Fix tpm2_read_public range checks</title>
<updated>2025-12-05T04:42:44Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2025-12-01T13:38:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bda1cbf73c6e241267c286427f2ed52b5735d872'/>
<id>urn:sha1:bda1cbf73c6e241267c286427f2ed52b5735d872</id>
<content type='text'>
tpm2_read_public() has some rudimentary range checks but the function does
not ensure that the response buffer has enough bytes for the full TPMT_HA
payload.

Re-implement the function with necessary checks and validation, and return
name and name size for all handle types back to the caller.

Cc: stable@vger.kernel.org # v6.10+
Fixes: d0a25bb961e6 ("tpm: Add HMAC session name/handle append")
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Reviewed-by: Jonathan McDowell &lt;noodles@meta.com&gt;
</content>
</entry>
<entry>
<title>tpm2-sessions: Fix out of range indexing in name_size</title>
<updated>2025-12-05T04:31:07Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2025-11-30T19:07:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6e9722e9a7bfe1bbad649937c811076acf86e1fd'/>
<id>urn:sha1:6e9722e9a7bfe1bbad649937c811076acf86e1fd</id>
<content type='text'>
'name_size' does not have any range checks, and it just directly indexes
with TPM_ALG_ID, which could lead into memory corruption at worst.

Address the issue by only processing known values and returning -EINVAL for
unrecognized values.

Make also 'tpm_buf_append_name' and 'tpm_buf_fill_hmac_session' fallible so
that errors are detected before causing any spurious TPM traffic.

End also the authorization session on failure in both of the functions, as
the session state would be then by definition corrupted.

Cc: stable@vger.kernel.org # v6.10+
Fixes: 1085b8276bb4 ("tpm: Add the rest of the session HMAC API")
Reviewed-by: Jonathan McDowell &lt;noodles@meta.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: Cap the number of PCR banks</title>
<updated>2025-12-03T20:55:28Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2025-09-30T12:58:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=faf07e611dfa464b201223a7253e9dc5ee0f3c9e'/>
<id>urn:sha1:faf07e611dfa464b201223a7253e9dc5ee0f3c9e</id>
<content type='text'>
tpm2_get_pcr_allocation() does not cap any upper limit for the number of
banks. Cap the limit to eight banks so that out of bounds values coming
from external I/O cause on only limited harm.

Cc: stable@vger.kernel.org # v5.10+
Fixes: bcfff8384f6c ("tpm: dynamically allocate the allocated_banks array")
Tested-by: Lai Yi &lt;yi1.lai@linux.intel.com&gt;
Reviewed-by: Jonathan McDowell &lt;noodles@meta.com&gt;
Reviewed-by: Roberto Sassu &lt;roberto.sassu@huawei.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@opinsys.com&gt;
</content>
</entry>
<entry>
<title>KEYS: trusted: Replace a redundant instance of tpm2_hash_map</title>
<updated>2025-11-29T20:57:30Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2025-10-18T17:41:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=127fa2ae9e2b1f9b9d876dfaa39fe3640cec5764'/>
<id>urn:sha1:127fa2ae9e2b1f9b9d876dfaa39fe3640cec5764</id>
<content type='text'>
'trusted_tpm2' duplicates 'tpm2_hash_map' originally part of the TPN
driver, which is suboptimal.

Implement and export `tpm2_find_hash_alg()` in the driver, and substitute
the redundant code in 'trusted_tpm2' with a call to the new function.

Reviewed-by: Jonathan McDowell &lt;noodles@meta.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: use a map for tpm2_calc_ordinal_duration()</title>
<updated>2025-10-10T05:21:45Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2025-09-18T19:30:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=207696b17f38e869e59889b44d395ab24bb678d3'/>
<id>urn:sha1:207696b17f38e869e59889b44d395ab24bb678d3</id>
<content type='text'>
The current shenanigans for duration calculation introduce too much
complexity for a trivial problem, and further the code is hard to patch and
maintain.

Address these issues with a flat look-up table, which is easy to understand
and patch. If leaf driver specific patching is required in future, it is
easy enough to make a copy of this table during driver initialization and
add the chip parameter back.

'chip-&gt;duration' is retained for TPM 1.x.

As the first entry for this new behavior address TCG spec update mentioned
in this issue:

https://github.com/raspberrypi/linux/issues/7054

Therefore, for TPM_SelfTest the duration is set to 3000 ms.

This does not categorize a as bug, given that this is introduced to the
spec after the feature was originally made.

Reviewed-by: Serge Hallyn &lt;serge@hallyn.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: Lazily flush auth session when getting random data</title>
<updated>2025-03-27T13:34:04Z</updated>
<author>
<name>Jonathan McDowell</name>
</author>
<published>2025-03-07T10:58:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=668f953bb4dfeddad854c0141a77b1738cdc1fdf'/>
<id>urn:sha1:668f953bb4dfeddad854c0141a77b1738cdc1fdf</id>
<content type='text'>
Lazy flushing of TPM auth sessions was introduced to speed up IMA
measurments into the TPM. Make use of it in tpm2_get_random as well,
which has the added benefit of not needlessly cleaning up the session
that IMA is using when there are no userspace accesses taking place.

Command trace before for every call:

hwrng (0x00000161): 14 (52965242 ns)
hwrng (0x00000176): 48 (161612432 ns)
hwrng (0x00000165): 10 (2410494 ns)
hwrng (0x0000017B): 117 (70699883 ns)
hwrng (0x0000017B): 117 (70959666 ns)
hwrng (0x00000165): 10 (2756827 ns)

After, with repeated calls showing no setup:

hwrng (0x00000161): 14 (53044582 ns)
hwrng (0x00000176): 48 (160491333 ns)
hwrng (0x00000165): 10 (2408220 ns)
hwrng (0x0000017B): 117 (70695037 ns)
hwrng (0x0000017B): 117 (70994984 ns)
hwrng (0x0000017B): 117 (70195388 ns)
hwrng (0x0000017B): 117 (70973835 ns)

Signed-off-by: Jonathan McDowell &lt;noodles@meta.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: Opt-in in disable PCR integrity protection</title>
<updated>2024-11-13T19:10:45Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2024-11-13T05:54:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=27184f8905ba680f22abf1707fbed24036a67119'/>
<id>urn:sha1:27184f8905ba680f22abf1707fbed24036a67119</id>
<content type='text'>
The initial HMAC session feature added TPM bus encryption and/or integrity
protection to various in-kernel TPM operations. This can cause performance
bottlenecks with IMA, as it heavily utilizes PCR extend operations.

In order to mitigate this performance issue, introduce a kernel
command-line parameter to the TPM driver for disabling the integrity
protection for PCR extend operations (i.e. TPM2_PCR_Extend).

Cc: James Bottomley &lt;James.Bottomley@HansenPartnership.com&gt;
Link: https://lore.kernel.org/linux-integrity/20241015193916.59964-1-zohar@linux.ibm.com/
Fixes: 6519fea6fd37 ("tpm: add hmac checks to tpm2_pcr_extend()")
Tested-by: Mimi Zohar &lt;zohar@linux.ibm.com&gt;
Co-developed-by: Roberto Sassu &lt;roberto.sassu@huawei.com&gt;
Signed-off-by: Roberto Sassu &lt;roberto.sassu@huawei.com&gt;
Co-developed-by: Mimi Zohar &lt;zohar@linux.ibm.com&gt;
Signed-off-by: Mimi Zohar &lt;zohar@linux.ibm.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: Open code tpm_buf_parameters()</title>
<updated>2024-05-28T10:03:57Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2024-05-27T10:56:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f3d7ba9e1bc0c9080834f263d4887bd9c9ea491f'/>
<id>urn:sha1:f3d7ba9e1bc0c9080834f263d4887bd9c9ea491f</id>
<content type='text'>
With only single call site, this makes no sense (slipped out of the
radar during the review). Open code and document the action directly
to the site, to make it more readable.

Fixes: 1b6d7f9eb150 ("tpm: add session encryption protection to tpm2_get_random()")
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
</feed>
