linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Tadeusz Struk <tadeusz.struk@intel.com>
Cc: "James Bottomley" <James.Bottomley@HansenPartnership.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 15:59:26 +0200	[thread overview]
Message-ID: <20190313135926.GA6862@linux.intel.com> (raw)
In-Reply-To: <14297706-74ef-f178-3b65-e63289919117@intel.com>

On Tue, Mar 12, 2019 at 03:42:00PM -0700, Tadeusz Struk wrote:
> Hi Jarkko,
> On 3/11/19 6:09 AM, Jarkko Sakkinen wrote:
> > Tadeusz, why on earth the code does not lock buffer_mutex?? Just noticed
> > when I checked the function in question. It is an awful bug alone.
> 
> Because the tpm_common_poll() just reads the flags and doesn't modify
> them, so the logic was that if the response_length is not 0 or
> response_read is flase then the first poll should return EPOLLIN
> and if not, the application should call the poll again and only call read
> if the EPOLLIN is set in the mask. It looks like the tpm_timeout_work()
> kicks in and messes things out.

1. You have *two* variables that you read, which can lead up reading
   a partial state.
2. You are not using atomic_t even if there was one variable.

> Looking at it again I think the response_read flag is redundant
> and only the response_length should be used.

Please provide a minimal fix to the issue. Only the fix for lock is
needed and send a proper patch (did not read the code below).

/Jarkko

  parent reply	other threads:[~2019-03-13 13:59 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
2019-03-13 13:59         ` Jarkko Sakkinen [this message]
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=20190313135926.GA6862@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).