From: Ming Lei <ming.lei@redhat.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Jens Axboe <axboe@fb.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
John Garry <john.garry@huawei.com>,
Bart Van Assche <bart.vanassche@sandisk.com>,
Omar Sandoval <osandov@fb.com>, Hannes Reinecke <hare@suse.com>
Subject: Re: [PATCH V4] scsi_debugfs: fix crash in scsi_show_rq()
Date: Wed, 15 Nov 2017 18:09:51 +0800 [thread overview]
Message-ID: <20171115100949.GC908@ming.t460p> (raw)
In-Reply-To: <1510683292.3077.3.camel@HansenPartnership.com>
On Tue, Nov 14, 2017 at 10:14:52AM -0800, James Bottomley wrote:
> On Tue, 2017-11-14 at 08:55 +0800, Ming Lei wrote:
> > Hi James,
> >
> > On Mon, Nov 13, 2017 at 10:55:52AM -0800, James Bottomley wrote:
> > >
> > > On Sat, 2017-11-11 at 10:43 +0800, Ming Lei wrote:
> > > >
> > > > So from CPU1's review, cmd->cmnd is in a remote NUMA node,
> > > > __scsi_format_command() is executed much slower than
> > > > mempool_free().
> > > > So when mempool_free() returns, __scsi_format_command() may not
> > > > fetched the buffer in L1 cache yet, then use-after-free
> > > > is still triggered.
> > > >
> > > > That is why I say this use-after-free is inevitable no matter
> > > > 'setting SCpnt->cmnd to NULL before calling mempool_free()' or
> > > > not.
> > >
> > > The bottom line is that there are several creative ways around this
> > > but the proposed code is currently broken and simply putting a
> > > comment in saying so doesn't make it acceptable.
> >
> > As I explained above, I didn't see one really workable way. Or please
> > correct it if I am wrong.
>
> I simply can't believe it's beyond the wit of man to solve a use after
> free race. About 40% of kernel techniques are devoted to this. All I
> really care about is not losing the PI information we previously had.
> I agree with Bart that NULL cmnd is a good indicator, so it seems
> reasonable to use it. If you have another mechanism, feel free to
> propose it.
Hi James,
This patch is my proposal, no others thought of yet.
We can fix the use-after-free easily via lock, rcu and ..., but some cost
has to pay. In this case, we can't wait too long in show_rq(), otherwise
we may lose important debug info, so I do not have better way.
IMO this use-after-free is actually no harm, I don't think we have to fix
it, but it should be better to not let utility warn on this case.
Thanks,
Ming
next prev parent reply other threads:[~2017-11-15 10:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 9:01 [PATCH V4] scsi_debugfs: fix crash in scsi_show_rq() Ming Lei
2017-11-10 16:51 ` James Bottomley
2017-11-11 2:43 ` Ming Lei
2017-11-13 18:55 ` James Bottomley
2017-11-14 0:55 ` Ming Lei
2017-11-14 18:14 ` James Bottomley
2017-11-15 10:09 ` Ming Lei [this message]
2017-11-15 10:28 ` James Bottomley
2017-11-15 12:04 ` Ming Lei
2017-12-05 16:55 ` Ming Lei
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=20171115100949.GC908@ming.t460p \
--to=ming.lei@redhat.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@fb.com \
--cc=bart.vanassche@sandisk.com \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=osandov@fb.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).