<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/char/tpm/tpm-dev-common.c, branch linux-5.17.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.17.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.17.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-03-28T08:03:18Z</updated>
<entry>
<title>tpm: Fix error handling in async work</title>
<updated>2022-03-28T08:03:18Z</updated>
<author>
<name>Tadeusz Struk</name>
</author>
<published>2022-01-16T01:26:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0d15c66771bbdd00676361e58e98bc1c59e6f3d8'/>
<id>urn:sha1:0d15c66771bbdd00676361e58e98bc1c59e6f3d8</id>
<content type='text'>
commit 2e8e4c8f6673247e22efc7985ce5497accd16f88 upstream.

When an invalid (non existing) handle is used in a TPM command,
that uses the resource manager interface (/dev/tpmrm0) the resource
manager tries to load it from its internal cache, but fails and
the tpm_dev_transmit returns an -EINVAL error to the caller.
The existing async handler doesn't handle these error cases
currently and the condition in the poll handler never returns
mask with EPOLLIN set.
The result is that the poll call blocks and the application gets stuck
until the user_read_timer wakes it up after 120 sec.
Change the tpm_dev_async_work function to handle error conditions
returned from tpm_dev_transmit they are also reflected in the poll mask
and a correct error code could passed back to the caller.

Cc: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Cc: Jason Gunthorpe &lt;jgg@ziepe.ca&gt;
Cc: &lt;linux-integrity@vger.kernel.org&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Cc: &lt;linux-kernel@vger.kernel.org&gt;

Fixes: 9e1b74a63f77 ("tpm: add support for nonblocking operation")
Tested-by: Jarkko Sakkinen&lt;jarkko@kernel.org&gt;
Signed-off-by: Tadeusz Struk &lt;tstruk@gmail.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
Cc: Tadeusz Struk &lt;tadeusz.struk@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tpm: Remove tpm_dev_wq_lock</title>
<updated>2021-02-16T08:40:27Z</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
</author>
<published>2020-12-14T22:07:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=724eaba40ef623194196323c05baa6a0b4bd0210'/>
<id>urn:sha1:724eaba40ef623194196323c05baa6a0b4bd0210</id>
<content type='text'>
Never used since it was added.

Fixes: 9e1b74a63f776 ("tpm: add support for nonblocking operation")
Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-integrity@vger.kernel.org
Cc: Jason Gunthorpe &lt;jgg@ziepe.ca&gt;
Cc: Philip Tricca &lt;philip.b.tricca@intel.com&gt;
Cc: Tadeusz Struk &lt;tadeusz.struk@intel.com&gt;
Cc: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko@kernel.org&gt;
</content>
</entry>
<entry>
<title>tpm: Fix TIS locality timeout problems</title>
<updated>2020-07-02T14:48:59Z</updated>
<author>
<name>James Bottomley</name>
</author>
<published>2020-05-28T18:10:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7862840219058436b80029a0263fd1ef065fb1b3'/>
<id>urn:sha1:7862840219058436b80029a0263fd1ef065fb1b3</id>
<content type='text'>
It has been reported that some TIS based TPMs are giving unexpected
errors when using the O_NONBLOCK path of the TPM device. The problem
is that some TPMs don't like it when you get and then relinquish a
locality (as the tpm_try_get_ops()/tpm_put_ops() pair does) without
sending a command.  This currently happens all the time in the
O_NONBLOCK write path. Fix this by moving the tpm_try_get_ops()
further down the code to after the O_NONBLOCK determination is made.
This is safe because the priv-&gt;buffer_mutex still protects the priv
state being modified.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206275
Fixes: d23d12484307 ("tpm: fix invalid locking in NONBLOCKING mode")
Reported-by: Mario Limonciello &lt;Mario.Limonciello@dell.com&gt;
Tested-by: Alex Guzman &lt;alex@guzman.io&gt;
Cc: stable@vger.kernel.org
Reviewed-by: Jerry Snitselaar &lt;jsnitsel@redhat.com&gt;
Signed-off-by: James Bottomley &lt;James.Bottomley@HansenPartnership.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>tpm: Handle negative priv-&gt;response_len in tpm_common_read()</title>
<updated>2020-01-08T16:11:09Z</updated>
<author>
<name>Tadeusz Struk</name>
</author>
<published>2020-01-07T22:04:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a430e67d9a2c62a8c7b315b99e74de02018d0a96'/>
<id>urn:sha1:a430e67d9a2c62a8c7b315b99e74de02018d0a96</id>
<content type='text'>
The priv-&gt;response_length can hold the size of an response or an negative
error code, and the tpm_common_read() needs to handle both cases correctly.
Changed the type of response_length to signed and accounted for negative
value in tpm_common_read().

Cc: stable@vger.kernel.org
Fixes: d23d12484307 ("tpm: fix invalid locking in NONBLOCKING mode")
Reported-by: Laura Abbott &lt;labbott@redhat.com&gt;
Signed-off-by: Tadeusz Struk &lt;tadeusz.struk@intel.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>tpm: fix invalid locking in NONBLOCKING mode</title>
<updated>2019-12-17T10:20:04Z</updated>
<author>
<name>Tadeusz Struk</name>
</author>
<published>2019-12-12T17:48:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d23d12484307b40eea549b8a858f5fffad913897'/>
<id>urn:sha1:d23d12484307b40eea549b8a858f5fffad913897</id>
<content type='text'>
When an application sends TPM commands in NONBLOCKING mode
the driver holds chip-&gt;tpm_mutex returning from write(),
which triggers: "WARNING: lock held when returning to user space".
To fix this issue the driver needs to release the mutex before
returning and acquire it again in tpm_dev_async_work() before
sending the command.

Cc: stable@vger.kernel.org
Fixes: 9e1b74a63f776 (tpm: add support for nonblocking operation)
Reported-by: Jeffrin Jose T &lt;jeffrin@rajagiritech.edu.in&gt;
Tested-by: Jeffrin Jose T &lt;jeffrin@rajagiritech.edu.in&gt;
Signed-off-by: Tadeusz Struk &lt;tadeusz.struk@intel.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441</title>
<updated>2019-06-05T15:37:17Z</updated>
<author>
<name>Thomas Gleixner</name>
</author>
<published>2019-06-01T08:08:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b886d83c5b621abc84ff9616f14c529be3f6b147'/>
<id>urn:sha1:b886d83c5b621abc84ff9616f14c529be3f6b147</id>
<content type='text'>
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation version 2 of the license

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 315 file(s).

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Allison Randal &lt;allison@lohutok.net&gt;
Reviewed-by: Armijn Hemel &lt;armijn@tjaldur.nl&gt;
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190531190115.503150771@linutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tpm: fix an invalid condition in tpm_common_poll</title>
<updated>2019-04-08T22:58:53Z</updated>
<author>
<name>Tadeusz Struk</name>
</author>
<published>2019-03-27T18:32:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7110629263469b4664d00b38ef80a656eddf3637'/>
<id>urn:sha1:7110629263469b4664d00b38ef80a656eddf3637</id>
<content type='text'>
The poll condition should only check response_length,
because reads should only be issued if there is data to read.
The response_read flag only prevents double writes.
The problem was that the write set the response_read to false,
enqued a tpm job, and returned. Then application called poll
which checked the response_read flag and returned EPOLLIN.
Then the application called read, but got nothing.
After all that the async_work kicked in.
Added also mutex_lock around the poll check to prevent
other possible race conditions.

Fixes: 9488585b21bef0df12 ("tpm: add support for partial reads")
Reported-by: Mantas Mikulėnas &lt;grawity@gmail.com&gt;
Tested-by: Mantas Mikulėnas &lt;grawity@gmail.com&gt;
Signed-off-by: Tadeusz Struk &lt;tadeusz.struk@intel.com&gt;
Reviewed-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Signed-off-by: James Morris &lt;james.morris@microsoft.com&gt;
</content>
</entry>
<entry>
<title>tpm: remove @flags from tpm_transmit()</title>
<updated>2019-02-13T07:48:46Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2018-11-05T01:02:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=47a6c28b6861b14a69e36ba974d2ffa1746e8e6f'/>
<id>urn:sha1:47a6c28b6861b14a69e36ba974d2ffa1746e8e6f</id>
<content type='text'>
Remove @flags from tpm_transmit() API. It is no longer used for
anything.

Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Reviewed-by: Stefan Berger &lt;stefanb@linux.ibm.com&gt;
Tested-by: Stefan Berger &lt;stefanb@linux.ibm.com&gt;
Reviewed-by: Jerry Snitselaar &lt;jsnitsel@redhat.com&gt;
Reviewed-by: James Bottomley &lt;James.Bottomley@HansenPartnership.com&gt;
Tested-by: Alexander Steffen &lt;Alexander.Steffen@infineon.com&gt;
</content>
</entry>
<entry>
<title>tpm: remove TPM_TRANSMIT_UNLOCKED flag</title>
<updated>2019-02-13T07:48:28Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2018-11-04T18:01:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2f257402ee981720d65080b1e3ce19f693f5c9c3'/>
<id>urn:sha1:2f257402ee981720d65080b1e3ce19f693f5c9c3</id>
<content type='text'>
Added locking as part of tpm_try_get_ops() and tpm_put_ops() as they are
anyway used in most of the call sites except in tpmrm_release() where we
take the locks manually.

Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Reviewed-by: Stefan Berger &lt;stefanb@linux.ibm.com&gt;
Tested-by: Stefan Berger &lt;stefanb@linux.ibm.com&gt;
Reviewed-by: Jerry Snitselaar &lt;jsnitsel@redhat.com&gt;
Reviewed-by: James Bottomley &lt;James.Bottomley@HansenPartnership.com&gt;
Tested-by: Alexander Steffen &lt;Alexander.Steffen@infineon.com&gt;
</content>
</entry>
<entry>
<title>tpm: remove @space from tpm_transmit()</title>
<updated>2019-02-13T07:48:12Z</updated>
<author>
<name>Jarkko Sakkinen</name>
</author>
<published>2018-11-03T13:15:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5faafbab77e37290daa023ba2002e0d611682397'/>
<id>urn:sha1:5faafbab77e37290daa023ba2002e0d611682397</id>
<content type='text'>
Remove @space from tpm_transmit() API` in order to completely remove the
bound between low-level transmission functionality and TPM spaces. The
only real dependency existing is the amount of data saved before trying
to send a command to the TPM.

It doesn't really matter if we save always a bit more than needed so
this commit changes the amount saved always to be the size of the TPM
header and three handles.

Cc: James Bottomley &lt;James.Bottomley@HansenPartnership.com&gt;
Signed-off-by: Jarkko Sakkinen &lt;jarkko.sakkinen@linux.intel.com&gt;
Reviewed-by: Stefan Berger &lt;stefanb@linux.ibm.com&gt;
Tested-by: Stefan Berger &lt;stefanb@linux.ibm.com&gt;
Reviewed-by: Jerry Snitselaar &lt;jsnitsel@redhat.com&gt;
Reviewed-by: James Bottomley &lt;James.Bottomley@HansenPartnership.com&gt;
Tested-by: Alexander Steffen &lt;Alexander.Steffen@infineon.com&gt;
</content>
</entry>
</feed>
