From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: "Tadeusz Struk" <tadeusz.struk@intel.com>,
"Mantas Mikulėnas" <grawity@gmail.com>,
linux-integrity@vger.kernel.org
Subject: Re: Kernel 5.0 regression in /dev/tpm0 access
Date: Wed, 13 Mar 2019 16:00:22 +0200 [thread overview]
Message-ID: <20190313140022.GB6862@linux.intel.com> (raw)
In-Reply-To: <1552431049.14432.42.camel@HansenPartnership.com>
On Tue, Mar 12, 2019 at 03:50:49PM -0700, James Bottomley wrote:
> On Tue, 2019-03-12 at 15:42 -0700, Tadeusz Struk wrote:
> > @@ -202,13 +196,15 @@ __poll_t tpm_common_poll(struct file *file,
> > poll_table *wait)
> > struct file_priv *priv = file->private_data;
> > __poll_t mask = 0;
> >
> > + mutex_lock(&priv->buffer_mutex);
> > poll_wait(file, &priv->async_wait, wait);
> >
> > - if (!priv->response_read || priv->response_length)
> > + if (priv->response_length)
> > mask = EPOLLIN | EPOLLRDNORM;
> > else
> > mask = EPOLLOUT | EPOLLWRNORM;
> >
> > + mutex_unlock(&priv->buffer_mutex);
>
> Isn't this setting us up for a deadlock? If the work queued by write
> hasn't run by the time you call poll, you take the buffer mutex and
> sleep. Now if the work runs, it blocks acquiring the mutex in
> tpm_async_work and never calls wakeup on async_wait.
Yes, the lock should be taken after poll_wait().
/Jarkko
next prev parent reply other threads:[~2019-03-13 14:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-09 20:48 Kernel 5.0 regression in /dev/tpm0 access Mantas Mikulėnas
2019-03-09 22:01 ` James Bottomley
2019-03-09 22:44 ` James Bottomley
2019-03-11 13:09 ` Jarkko Sakkinen
2019-03-12 22:42 ` Tadeusz Struk
2019-03-12 22:50 ` James Bottomley
2019-03-13 14:00 ` Jarkko Sakkinen [this message]
2019-03-13 13:59 ` Jarkko Sakkinen
2019-03-17 13:22 ` Jarkko Sakkinen
2019-03-18 15:50 ` Tadeusz Struk
2019-03-20 9:58 ` 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=20190313140022.GB6862@linux.intel.com \
--to=jarkko.sakkinen@linux.intel.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=grawity@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=tadeusz.struk@intel.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).