From: Stefan Berger <stefanb@linux.ibm.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Tyrel Datwyler <tyreld@linux.ibm.com>,
jarkko@kernel.org, peterhuewe@gmx.de,
linux-integrity@vger.kernel.org, Korrapati.Likhitha@ibm.com,
pavrampu@in.ibm.com, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, gcwilson@us.ibm.com,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] tpm: Fix kexec crash due to access to ops NULL pointer (powerpc)
Date: Mon, 20 Dec 2021 20:31:27 -0500 [thread overview]
Message-ID: <f80e33d2-948d-f885-b063-245eb37de8c1@linux.ibm.com> (raw)
In-Reply-To: <20211221011320.GM6467@ziepe.ca>
On 12/20/21 20:13, Jason Gunthorpe wrote:
> On Mon, Dec 20, 2021 at 08:05:58PM -0500, Stefan Berger wrote:
>
>> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
>> index ddaeceb7e109..4cb908349b31 100644
>> +++ b/drivers/char/tpm/tpm-chip.c
>> @@ -473,15 +473,8 @@ static void tpm_del_char_device(struct tpm_chip *chip)
>> mutex_unlock(&idr_lock);
>>
>> /* Make the driver uncallable. */
>> - down_write(&chip->ops_sem);
>> - if (chip->flags & TPM_CHIP_FLAG_TPM2) {
>> - if (!tpm_chip_start(chip)) {
>> - tpm2_shutdown(chip, TPM2_SU_CLEAR);
>> - tpm_chip_stop(chip);
>> - }
>> - }
>> - chip->ops = NULL;
>> - up_write(&chip->ops_sem);
>> + if (chip->ops)
> ops cannot be read without locking
This here could be an alternative:
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index ddaeceb7e109..7772b475ebc0 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -474,7 +474,7 @@ static void tpm_del_char_device(struct tpm_chip *chip)
/* Make the driver uncallable. */
down_write(&chip->ops_sem);
- if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+ if (chip->ops && chip->flags & TPM_CHIP_FLAG_TPM2) {
if (!tpm_chip_start(chip)) {
tpm2_shutdown(chip, TPM2_SU_CLEAR);
tpm_chip_stop(chip);
Stefan
>
> Jason
next prev parent reply other threads:[~2021-12-21 1:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-12 1:28 [PATCH] tpm: Fix kexec crash due to access to ops NULL pointer (powerpc) Stefan Berger
2021-12-20 5:17 ` Sachin Sant
2021-12-21 0:39 ` Tyrel Datwyler
2021-12-21 1:05 ` Stefan Berger
2021-12-21 1:13 ` Jason Gunthorpe
2021-12-21 1:31 ` Stefan Berger [this message]
2021-12-21 1:37 ` Tyrel Datwyler
2021-12-21 1:34 ` Tyrel Datwyler
2021-12-21 8:47 ` Jarkko Sakkinen
2021-12-21 14:01 ` Stefan Berger
2021-12-21 14:17 ` Stefan Berger
2021-12-29 0:10 ` Jarkko Sakkinen
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=f80e33d2-948d-f885-b063-245eb37de8c1@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=Korrapati.Likhitha@ibm.com \
--cc=gcwilson@us.ibm.com \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=pavrampu@in.ibm.com \
--cc=peterhuewe@gmx.de \
--cc=tyreld@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).