linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Tai <thomas.tai@oracle.com>
To: Keith Busch <keith.busch@intel.com>, Bjorn Helgaas <helgaas@kernel.org>
Cc: bhelgaas@google.com, poza@codeaurora.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH V2, 0/1] PCI/AER: fix use-after-free in pcie_do_fatal_recovery
Date: Mon, 16 Jul 2018 10:06:31 -0400	[thread overview]
Message-ID: <dbc4ae62-4e96-db73-9b47-7bff8343c8dd@oracle.com> (raw)
In-Reply-To: <20180712215700.GA17092@localhost.localdomain>



On 07/12/2018 05:57 PM, Keith Busch wrote:
> On Thu, Jul 12, 2018 at 04:51:51PM -0500, Bjorn Helgaas wrote:
>> However, I think we're also slightly exposed in dpc_work(), in basically
>> the same (possibly harmless) way.
>>
>>    dpc_irq
>>      schedule_work(&dpc->work)
>>    ...
>>    dpc_work
>>      pdev = dpc->dev->port
>>      pcie_do_fatal_recovery(pdev)
>>
>> pdev may be removed by pcie_do_fatal_recovery(), but dpc_work() is still
>> holding onto a pointer (which it never uses again).
>>
>> The DPC driver should be holding a reference to pdev (through some black
>> magic I don't understand), but that would be released when pdev is removed,
>> and I don't know what ensures that dpc_work() runs before that release.
>>
>> Bjorn
> 
> Yep, you're right on that point. There's different ways we can fix
> that. The most recent one I proposed was to replace the scheduled work
> with the threaded irq[1]. That should make it safe since the lifetime of
> when bottom half can be executed is tied to the lifetime of the device
> that registered it.
> 
>   1. https://patchwork.kernel.org/patch/10478755/

Hi Bjorn, Keith and Poza,
I like the idea of using threaded irq if it can hold the device until 
the bottom half finished. It makes the AER and DPC driver codes more 
consistent. One problem I hit when changing the AER to threaded irq is 
that the error injection module aer_inject won't work anymore because it 
call the aer_irq directly and didn't go thru the threaded_irq path. I 
would have to fix that also. Will keep you posted.

Cheers,
Thomas

> 

  reply	other threads:[~2018-07-16 14:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 17:33 [PATCH V2, 0/1] PCI/AER: fix use-after-free in pcie_do_fatal_recovery Thomas Tai
2018-07-12 17:33 ` [PATCH V2, 1/1] " Thomas Tai
2018-07-12 21:51 ` [PATCH V2, 0/1] " Bjorn Helgaas
2018-07-12 21:57   ` Keith Busch
2018-07-16 14:06     ` Thomas Tai [this message]
2018-07-18 21:16     ` Bjorn Helgaas
2018-07-18 21:43       ` Thomas Tai
2018-07-18 21:57         ` Bjorn Helgaas
2018-07-15 18:55   ` poza
2018-07-16 14:00     ` Keith Busch
2018-07-16 14:17     ` Thomas Tai
2018-07-18 21:32   ` Thomas Tai

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=dbc4ae62-4e96-db73-9b47-7bff8343c8dd@oracle.com \
    --to=thomas.tai@oracle.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=keith.busch@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=poza@codeaurora.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 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).