Re: [PATCH v2] tpm: Allow system suspend to continue when TPM suspend fails
From: Jarkko Sakkinen
Date: Fri Jan 20 2023 - 19:07:20 EST
On Mon, Jan 16, 2023 at 03:03:17PM +0100, Jason A. Donenfeld wrote:
> Hi Jarkko,
>
> On Mon, Jan 16, 2023 at 9:12 AM Jarkko Sakkinen <jarkko@xxxxxxxxxx> wrote:
> > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> > > index d69905233aff..6df9067ef7f9 100644
> > > --- a/drivers/char/tpm/tpm-interface.c
> > > +++ b/drivers/char/tpm/tpm-interface.c
> > > @@ -412,7 +412,10 @@ int tpm_pm_suspend(struct device *dev)
> > > }
> > >
> > > suspended:
> > > - return rc;
> > > + if (rc)
> > > + pr_err("Unable to suspend tpm-%d (error %d), but continuing system suspend\n",
> > > + chip->dev_num, rc);
> > > + return 0;
> > > }
> > > EXPORT_SYMBOL_GPL(tpm_pm_suspend);
> > >
> > > --
> > > 2.39.0
> > >
> >
> > Let me read all the threads through starting from the original report. I've
> > had emails piling up because of getting sick before holiday, and holiday
> > season after that.
> >
> > This looks sane
>
> No, not really. I mean, it was sane under the circumstances of, "I'm
> not going to spend time fixing this for real if the maintainers aren't
> around," and it fixed the suspend issue. But it doesn't actually fix
> any real tpm issue. The real issue, AFAICT, is there's some sort of
> race between the tpm rng read command and either suspend or wakeup or
> selftest. One of these is missing some locking. And then commands step
> on each other and the tpm gets upset. This is probably something that
> should be fixed. I assume the "Fixes: ..." tag will actually go quite
> far back, with recent things only unearthing a somewhat old bug. But
> just a hunch.
>
> Jason
See my response to Vlastimil:
https://lore.kernel.org/linux-integrity/Y8sr7YJ8e8eSpPFv@xxxxxxxxxx/
Can you try what happens if you do not call tpm_add_hwrng()?
BR, Jarkko