From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Jarkko Sakkinen
<jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/3] tpm: Hold the kref during tpm_chip_find_get
Date: Sat, 13 Feb 2016 23:50:08 -0700 [thread overview]
Message-ID: <20160214065008.GC9551@obsidianresearch.com> (raw)
In-Reply-To: <20160214045512.GA7777-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On Sun, Feb 14, 2016 at 06:55:12AM +0200, Jarkko Sakkinen wrote:
> On Fri, Feb 12, 2016 at 05:04:29PM -0700, Jason Gunthorpe wrote:
> > This was missed during the struct device conversion, we
> > need to hold a kref on the chip to make sure it isn't freed.
> >
> > Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
>
> I'm bit confused about this patch. What is the regression if this
> needs
The patch is simply totally broken, the placement of the get_device is
wrong:
> > @@ -53,6 +53,8 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
> > chip = pos;
> > break;
> > }
> > +
> > + get_device(&chip->dev);
It needs to be moved up two lines before the break, into the if
statement.
As for the urgency - today the tpm core relies on module locking to
try and prevent tpm_chip_unregister from racing with stuff like the
above. That is totally broken in modern kernels, but it is what the
core tries to do. Within that framework the get/put are not needed
because of the module locking.
The only time these additional get/put do anything is when we are
racing with tpm_unregister, but if we are racing with unregister then
there are much bigger problems and things will crash anyhow.
So, this patch is just a tiny step.
The revised version of this patch with the rw_sem attempts to address
the complete race.
Jason
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org,
Stefan Berger <stefanb@us.ibm.com>,
Peter Huewe <peterhuewe@gmx.de>
Subject: Re: [PATCH 1/3] tpm: Hold the kref during tpm_chip_find_get
Date: Sat, 13 Feb 2016 23:50:08 -0700 [thread overview]
Message-ID: <20160214065008.GC9551@obsidianresearch.com> (raw)
In-Reply-To: <20160214045512.GA7777@intel.com>
On Sun, Feb 14, 2016 at 06:55:12AM +0200, Jarkko Sakkinen wrote:
> On Fri, Feb 12, 2016 at 05:04:29PM -0700, Jason Gunthorpe wrote:
> > This was missed during the struct device conversion, we
> > need to hold a kref on the chip to make sure it isn't freed.
> >
> > Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
>
> I'm bit confused about this patch. What is the regression if this
> needs
The patch is simply totally broken, the placement of the get_device is
wrong:
> > @@ -53,6 +53,8 @@ struct tpm_chip *tpm_chip_find_get(int chip_num)
> > chip = pos;
> > break;
> > }
> > +
> > + get_device(&chip->dev);
It needs to be moved up two lines before the break, into the if
statement.
As for the urgency - today the tpm core relies on module locking to
try and prevent tpm_chip_unregister from racing with stuff like the
above. That is totally broken in modern kernels, but it is what the
core tries to do. Within that framework the get/put are not needed
because of the module locking.
The only time these additional get/put do anything is when we are
racing with tpm_unregister, but if we are racing with unregister then
there are much bigger problems and things will crash anyhow.
So, this patch is just a tiny step.
The revised version of this patch with the rw_sem attempts to address
the complete race.
Jason
next prev parent reply other threads:[~2016-02-14 6:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-13 0:04 [PATCH 0/3] Various struct device cleanups Jason Gunthorpe
2016-02-13 0:04 ` Jason Gunthorpe
[not found] ` <1455321871-28296-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-02-13 0:04 ` [PATCH 1/3] tpm: Hold the kref during tpm_chip_find_get Jason Gunthorpe
2016-02-13 0:04 ` Jason Gunthorpe
[not found] ` <1455321871-28296-2-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-02-13 10:08 ` Jarkko Sakkinen
2016-02-13 10:08 ` Jarkko Sakkinen
[not found] ` <20160213100818.GA12607-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-13 15:45 ` Jason Gunthorpe
2016-02-13 15:45 ` Jason Gunthorpe
2016-02-14 4:55 ` Jarkko Sakkinen
2016-02-14 4:55 ` Jarkko Sakkinen
[not found] ` <20160214045512.GA7777-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-14 6:50 ` Jason Gunthorpe [this message]
2016-02-14 6:50 ` Jason Gunthorpe
2016-02-14 8:02 ` Jarkko Sakkinen
2016-02-13 0:04 ` [PATCH 2/3] tpm: Get rid of chip->pdev Jason Gunthorpe
2016-02-13 0:04 ` Jason Gunthorpe
[not found] ` <201602130037.u1D0bDEN029756@d01av04.pok.ibm.com>
2016-02-13 1:11 ` Jason Gunthorpe
[not found] ` <20160213011130.GA2547-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-02-13 1:31 ` Stefan Berger
[not found] ` <201602130128.u1D1S2Xn006955@d01av05.pok.ibm.com>
[not found] ` <201602130128.u1D1S2Xn006955-8DuMPbUlb4HImUpY6SP3GEEOCMrvLtNR@public.gmane.org>
2016-02-13 2:00 ` Jason Gunthorpe
2016-02-13 2:00 ` Jason Gunthorpe
2016-02-13 3:33 ` Jason Gunthorpe
2016-02-13 3:33 ` Jason Gunthorpe
2016-02-14 5:24 ` Jarkko Sakkinen
[not found] ` <20160214052414.GB8065-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-14 6:57 ` Jason Gunthorpe
2016-02-14 6:57 ` Jason Gunthorpe
[not found] ` <20160214065724.GD9551-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-02-14 8:03 ` Jarkko Sakkinen
2016-02-14 8:03 ` Jarkko Sakkinen
[not found] ` <1455321871-28296-3-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-02-13 0:37 ` Stefan Berger
2016-02-13 15:39 ` Stefan Berger
2016-02-13 15:39 ` [tpmdd-devel] " Stefan Berger
[not found] ` <56BF4E1F.2030208-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-02-14 7:06 ` Jason Gunthorpe
2016-02-14 7:06 ` [tpmdd-devel] " Jason Gunthorpe
2016-02-14 5:13 ` Jarkko Sakkinen
2016-02-14 5:13 ` Jarkko Sakkinen
2016-02-13 0:04 ` [PATCH 3/3] tpm: Get rid of devname Jason Gunthorpe
[not found] ` <1455321871-28296-4-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-02-13 1:01 ` kbuild test robot
2016-02-13 1:01 ` kbuild test robot
[not found] ` <201602130853.47ON3KAx%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-02-13 1:13 ` Jason Gunthorpe
2016-02-13 1:13 ` Jason Gunthorpe
2016-02-14 5:16 ` Jarkko Sakkinen
2016-02-14 5:16 ` 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=20160214065008.GC9551@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/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.