All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Dąbroś" <jsd@semihalf.com>
To: Tim Van Patten <timvp@google.com>
Cc: linux-integrity@vger.kernel.org, jarkko@kernel.org,
	peterhuewe@gmx.de, jgg@ziepe.ca, gregkh@linuxfoundation.org,
	arnd@arndb.de, rrangel@chromium.org, apronin@google.com,
	mw@semihalf.com, upstream@semihalf.com
Subject: Re: [PATCH 1/3] char: tpm: Protect tpm_pm_suspend with locks
Date: Wed, 2 Nov 2022 22:28:36 +0100	[thread overview]
Message-ID: <CAOtMz3Od-r03EigmuEAG_q27bvifRS8ZV8YPOUHrayEW6YXO-Q@mail.gmail.com> (raw)
In-Reply-To: <CANkg5eyWqhReHJd7Bj5EEG5chz89M-PKCnak91qPRWZEzm3NRw@mail.gmail.com>

> > -       if (!tpm_chip_start(chip)) {
> > +       rc = tpm_try_get_ops(chip);
> > +       if (!rc) {
> >                 if (chip->flags & TPM_CHIP_FLAG_TPM2)
> >                         tpm2_shutdown(chip, TPM2_SU_STATE);
> >                 else
> >                         rc = tpm1_pm_suspend(chip, tpm_suspend_pcr);
>
> This if-else block is still interacting with the TPM even though
> you're not guaranteed to have the lock, which could lead to
> racy/inchorent results. Would it be better to just bail out entirely
> since we can't safely attempt any recovery at this point. If it's
> still worth attempting the shutdown command, it would at least be good
> to add a comment admitting that we have no choice but to communicate
> with the TPM without a lock.

If tpm_try_get_ops() returns 0 it means that we have a lock. And if we
don't have a lock, then we are not executing any TPM commands. Are you
referring to tpm_mutex or something different?

Best Regards,
Jan

  reply	other threads:[~2022-11-02 21:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01  2:03 [PATCH 0/3] char: tpm: Adjust cr50_i2c locking mechanism Jan Dabros
2022-11-01  2:03 ` [PATCH 1/3] char: tpm: Protect tpm_pm_suspend with locks Jan Dabros
2022-11-01 15:53   ` Tim Van Patten
2022-11-02 21:28     ` Jan Dąbroś [this message]
2022-11-03 22:36       ` Tim Van Patten
2022-11-01  2:03 ` [PATCH 2/3] char: tpm: cr50: Use generic request/relinquish locality ops Jan Dabros
2022-11-01 16:04   ` Tim Van Patten
2022-11-02 21:42     ` Jan Dąbroś
2022-11-01  2:03 ` [PATCH 3/3] char: tpm: cr50: Move i2c locking to " Jan Dabros

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=CAOtMz3Od-r03EigmuEAG_q27bvifRS8ZV8YPOUHrayEW6YXO-Q@mail.gmail.com \
    --to=jsd@semihalf.com \
    --cc=apronin@google.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=mw@semihalf.com \
    --cc=peterhuewe@gmx.de \
    --cc=rrangel@chromium.org \
    --cc=timvp@google.com \
    --cc=upstream@semihalf.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.