From: Vladislav Bolkhovitin <vst@vlnb.net>
To: Andrew Vasquez <andrew.vasquez@qlogic.com>
Cc: linux-driver@qlogic.com, Gal Rosen <galr@storwize.com>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
linux-scsi@vger.kernel.org, scst-devel@lists.sourceforge.net
Subject: Re: [PATCH] qla2xxx: Fix dpc_thread race on the module unload
Date: Fri, 01 Aug 2008 16:28:03 +0400 [thread overview]
Message-ID: <48930153.5090609@vlnb.net> (raw)
In-Reply-To: <20080731175544.GB80258@elab5.qlogic.org>
Andrew Vasquez wrote:
> On Thu, 31 Jul 2008, Vladislav Bolkhovitin wrote:
>
>>> The changes above are large (170k diffs so far), and at this point are
>>> being run-through our testing. The hope is to get the changes
>>> upstream during one of the next two merge windows.
>>>
>>> Given the infrustructure mods and our focus on that front, if there's
>>> something small and contained you can offer above what I've proposed
>>> we'll be interested in reviewing any patches you'd push forward.
>> Then, I believe, my patch should go in as a temporal measure. I don't think
>> we should crash users for 2 more major releases.
>
> So the 'online' check concerns you? So, add an 'unloading' flag, set
> it on remove_one(), save a copy of dpc_thread at qla2xxx_wake_dpc(),
> then wake_up() saved value if not 'unloading'. Of course the direct
> wake_up() in request_acqusition should be modded to call
> qla2xxx_wake_dpc(). We're not talking about some huge window here.
My main concern is not about the 'online' flag, but about that your
patch doesn't fix the race, which it's intended to fix, because:
1. It doesn't handle possibility of CPU to reorder commands. Hence, it
could be possible that other CPUs can see 'online' flag set to 0 *after*
dpc_thread set to NULL, despite in the code "ha->flags.online = 0"
precede "ha->dpc_thread = NULL". To address that the corresponding
memory barriers around ha->flags.online assignment and reading are needed.
2. More importantly, it doesn't handle possibility for task_struct, to
which dpc_thread field refers, to be destroyed exactly between lines
if (ha->flags.online && t)
wake_up_process(t);
or inside wake_up_process(). Hence, already freed and possibly reused
data will be accessed by wake_up_process() with all corresponding bad
consequences.
>> The same is true for my
>> other patch "Proposed protection of fcports field of struct scsi_qla_host"
>> as well, because without it there should be no big problems to crash the
>> driver via sysfs.
>
> We're still looking through your patches... So how exactly would it
> be 'be no big problems to crash the driver via sysfs.'???
Example scenario: one or many applications read in a loop any sysfs
entry, which go over fcports list, and at the same time DPC thread adds
to it new entries. If CPU can reorder commands (most modern CPUs can) it
is possible that list_for_each_entry() will access partially inserted
entry => NULL pointer dereference.
To see better what I mean look at the difference between list_add() and
list_add_rcu() as well as between list_for_each_entry() and
list_for_each_entry_rcu().
Vlad
next prev parent reply other threads:[~2008-08-01 12:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 17:33 [PATCH] qla2xxx: Fix dpc_thread race on the module unload Vladislav Bolkhovitin
2008-07-28 17:41 ` Andrew Vasquez
2008-07-28 17:49 ` Vladislav Bolkhovitin
2008-07-28 17:56 ` James Bottomley
2008-07-28 18:14 ` Vladislav Bolkhovitin
2008-07-29 7:30 ` Gal Rosen
2008-07-30 7:10 ` Gal Rosen
2008-07-31 6:12 ` Gal Rosen
2008-07-31 9:11 ` Vladislav Bolkhovitin
2008-07-31 16:02 ` Andrew Vasquez
2008-07-31 17:41 ` Vladislav Bolkhovitin
2008-07-31 17:55 ` Andrew Vasquez
2008-08-01 12:28 ` Vladislav Bolkhovitin [this message]
2008-07-29 4:27 ` Christoph Hellwig
2008-07-29 9:32 ` Vladislav Bolkhovitin
2008-07-28 18:07 ` Andrew Vasquez
2008-07-29 9:32 ` Vladislav Bolkhovitin
2008-07-29 14:40 ` James Bottomley
2008-07-29 15:13 ` Vladislav Bolkhovitin
2008-07-29 15:28 ` James Bottomley
2008-07-29 15:36 ` Vladislav Bolkhovitin
2008-07-30 10:30 ` Andrew Vasquez
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=48930153.5090609@vlnb.net \
--to=vst@vlnb.net \
--cc=James.Bottomley@HansenPartnership.com \
--cc=andrew.vasquez@qlogic.com \
--cc=galr@storwize.com \
--cc=linux-driver@qlogic.com \
--cc=linux-scsi@vger.kernel.org \
--cc=scst-devel@lists.sourceforge.net \
/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