From: Ming Lei <ming.lei@redhat.com>
To: James Bottomley <jejb@linux.vnet.ibm.com>
Cc: Bart Van Assche <Bart.VanAssche@wdc.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"jthumshirn@suse.de" <jthumshirn@suse.de>,
"hch@lst.de" <hch@lst.de>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"hare@suse.com" <hare@suse.com>
Subject: Re: [PATCH 1/2] scsi-mq: Only show the CDB if available
Date: Wed, 6 Dec 2017 09:16:43 +0800 [thread overview]
Message-ID: <20171206011641.GA26512@ming.t460p> (raw)
In-Reply-To: <1512492229.3019.25.camel@linux.vnet.ibm.com>
On Tue, Dec 05, 2017 at 08:43:49AM -0800, James Bottomley wrote:
> On Wed, 2017-12-06 at 00:38 +0800, Ming Lei wrote:
> > On Tue, Dec 05, 2017 at 04:22:33PM +0000, Bart Van Assche wrote:
> > >
> > > On Tue, 2017-12-05 at 13:00 +0800, Ming Lei wrote:
> > > >
> > > > No, do not mix two different things in one patch, especially the
> > > > fix part need to be backported to stable.
> > > >
> > > > The fix part should aim at V4.15, and the other part can be a
> > > > V4.16 stuff.
> > >
> > > Does this mean that you do not plan to post a v5 of your patch and
> > > that you want me to rework this patch series? I can do that.
> >
> > I believe V4 has been OK for merge, actually the only concern from
> > James is that 'set the cmnd to NULL *before* calling free so we
> > narrow the race window.', but that isn't required as I explained,
> > even though you don't do that in this patch too.
> >
> > https://marc.info/?t=151030464300003&r=1&w=2
> >
> > I will work on V5 if Martin/James thinks it is needed.
>
> I don't buy that it isn't needed. �The point (and the pattern) is for a
> destructive action set the signal *before* you execute the action not
> after. �The reason should be obvious: if you set it after you invite a
> race where the check says OK but the object has gone. �Even if the race
Even you do that, the race is still highly likely there:
1) mempool_free() can be much quicker than scsi_show_rq() because it is
a local free, and scsi_show_rq() can be run from remote CPU wrt. the
allocated 'cmd->cmnd', and access to remote NUMA node should be slower
than mempool_free(), so use-after-free is triggered.
2) any preemption or local IRQ in scsi_show_rq() can make it touch
a freed buffer, and sd_uninit_command() is run from irq context.
3) no any barrier is applied, so the actual write can be reordered
in sd_uninit_command()
So setting the cmd->cmnd as NULL before mempool_free() can't avoid
the use-after-free, scsi_show_rq() has to survive that, then
do we really need to add the unnecessary change in sd_uninit_command()?
Not mention the change will make the debug info disappear too early, is
that what we need?
> is highly unlikely, the pattern point still holds.
--
Ming
next prev parent reply other threads:[~2017-12-06 1:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 0:38 [PATCH 0/2] Show commands stuck in a timeout handler in debugfs Bart Van Assche
2017-12-05 0:38 ` [PATCH 1/2] scsi-mq: Only show the CDB if available Bart Van Assche
2017-12-05 1:15 ` Ming Lei
2017-12-05 1:59 ` Bart Van Assche
2017-12-05 5:00 ` Ming Lei
2017-12-05 16:22 ` Bart Van Assche
2017-12-05 16:38 ` Ming Lei
2017-12-05 16:43 ` James Bottomley
2017-12-06 1:16 ` Ming Lei [this message]
2017-12-05 17:51 ` Bart Van Assche
2017-12-05 3:42 ` Martin K. Petersen
2017-12-05 4:00 ` Ming Lei
2017-12-05 0:38 ` [PATCH 2/2] blk-mq-debugfs: Also show requests that have not yet been started Bart Van Assche
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=20171206011641.GA26512@ming.t460p \
--to=ming.lei@redhat.com \
--cc=Bart.VanAssche@wdc.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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).