From: Jarkko Sakkinen <jarkko@kernel.org>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: peterhuewe@gmx.de, jgg@ziepe.ca, p.rosenberger@kunbus.com,
linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] tpm: fix potential NULL pointer access in tpm_del_char_device
Date: Wed, 29 Dec 2021 03:46:36 +0200 [thread overview]
Message-ID: <Ycu9/C1IKQveozL6@iki.fi> (raw)
In-Reply-To: <185a096b-96f1-cc99-52e8-08a35151e347@gmx.de>
On Wed, Dec 29, 2021 at 02:41:52AM +0100, Lino Sanfilippo wrote:
> Hi,
>
> On 29.12.21 at 01:13, Jarkko Sakkinen wrote:
> > On Mon, Dec 20, 2021 at 04:06:35PM +0100, Lino Sanfilippo wrote:
> >> Some SPI controller drivers unregister the controller in the shutdown
> >> handler (e.g. BCM2835). If such a controller is used with a TPM 2 slave
> >> chip->ops may be accessed when it is already NULL:
> >>
> >> At system shutdown the pre-shutdown handler tpm_class_shutdown() shuts down
> >> TPM 2 and sets chip->ops to NULL. Then at SPI controller unregistration
> >> tpm_tis_spi_remove() is called and eventually calls tpm_del_char_device()
> >> which tries to shut down TPM 2 again. Thereby it accesses chip->ops again:
> >> (tpm_del_char_device calls tpm_chip_start which calls tpm_clk_enable which
> >> calls chip->ops->clk_enable).
> >>
> >> Avoid the NULL pointer access by testing if chip->ops is valid and skipping
> >> the TPM 2 shutdown procedure in case it is NULL.
> >>
> >> Fixes: dcbeab1946454 ("tpm: fix crash in tpm_tis deinitialization")
> >> Cc: stable@vger.kernel.org
> >> Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
> >
> > Thank you.
> >
> > Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> >
> > BR,
> > Jarkko
> >
>
> Thanks a lot for the review. Please note that the latest version is v3 which
> contains one more Fixes tag and also a tag for the review by Stefan. I also
> adjusted the source code comment in that version which I somehow messed up in v2.
Since there is no functional difference, I rather do not swap it.
I fixed a glitch:
+
+ /*
A multi-line commit needs to have this as the very first line.
You can check if the all tags were pulled by b4.
/Jarkko
next prev parent reply other threads:[~2021-12-29 1:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-20 15:06 [PATCH v2] tpm: fix potential NULL pointer access in tpm_del_char_device Lino Sanfilippo
2021-12-21 19:16 ` Lino Sanfilippo
2021-12-22 4:53 ` Stefan Berger
2021-12-22 6:56 ` Lino Sanfilippo
2021-12-29 0:13 ` Jarkko Sakkinen
2021-12-29 1:41 ` Lino Sanfilippo
2021-12-29 1:46 ` Jarkko Sakkinen [this message]
2021-12-29 1:51 ` Lino Sanfilippo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ycu9/C1IKQveozL6@iki.fi \
--to=jarkko@kernel.org \
--cc=LinoSanfilippo@gmx.de \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.rosenberger@kunbus.com \
--cc=peterhuewe@gmx.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox