From: Christoph Hellwig <hch@lst.de>
To: Benjamin Block <bblock@linux.vnet.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>,
"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-scsi@vger.kernel.org,
Johannes Thumshirn <jthumshirn@suse.de>,
Steffen Maier <maier@linux.vnet.ibm.com>,
open-iscsi@googlegroups.com
Subject: Re: [RFC PATCH 1/6] bsg: fix kernel panic resulting from missing allocation of a reply-buffer
Date: Wed, 16 Aug 2017 12:53:18 +0200 [thread overview]
Message-ID: <20170816105318.GA30759@lst.de> (raw)
In-Reply-To: <20170814163217.GA18228@bblock-ThinkPad-W530>
On Mon, Aug 14, 2017 at 06:32:17PM +0200, Benjamin Block wrote:
> > - blk_end_request_all(rq, BLK_STS_OK);
> > -
> > put_device(job->dev); /* release reference for the request */
> >
> > kfree(job->request_payload.sg_list);
> > kfree(job->reply_payload.sg_list);
> > - kfree(job);
> > + blk_end_request_all(rq, BLK_STS_OK);
>
> What is the reason for moving that last line? Just wondering whether
> that might change the behavior somehow, although it doesn't look like it
> from the code.
The job is now allocated as part of the request, so we must fre
it last. The only change in behavior is that the reference gets dropped
a bit earlier, but once ownership is handed to the block layer
it's not needed, as are the memory allocations for the S/G lists.
> > +{
> > + struct bsg_job *job = blk_mq_rq_to_pdu(req);
> > +
> > + memset(job, 0, sizeof(*job));
> > + job->req = req;
> > + job->request = job->sreq.cmd;
>
> That doesn't work with bsg.c if the request submitted by the user is
> bigger than BLK_MAX_CDB. There is code in blk_fill_sgv4_hdr_rq() that
> will reassign the req->cmd point in that case to something else.
>
> This is maybe wrong in the same vein as my Patch 1 is. If not for the
> legacy code in bsg.c, setting this here, will miss changes to that
> pointer between request-allocation and job-submission.
>
> So maybe just move this to bsg_create_job().
Yes, this should be in indeed.
>
> > + job->dd_data = job + 1;
> > + job->reply = job->sreq.sense = kzalloc(job->reply_len, gfp);
>
> job->reply_len will be 0 here, won't it? You probably have to pull the
> "job->reply_len = SCSI_SENSE_BUFFERSIZE" here from bsg_create_job().
True.
next prev parent reply other threads:[~2017-08-16 10:53 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 14:11 [RFC PATCH 0/6] bsg: fix regression resulting in panics when sending commands via BSG and some sanity cleanups Benjamin Block
2017-08-09 14:11 ` [RFC PATCH 1/6] bsg: fix kernel panic resulting from missing allocation of a reply-buffer Benjamin Block
2017-08-10 9:32 ` Christoph Hellwig
2017-08-10 22:10 ` Benjamin Block
2017-08-10 22:45 ` Benjamin Block
2017-08-11 8:38 ` Christoph Hellwig
2017-08-11 9:14 ` Christoph Hellwig
2017-08-11 13:49 ` Benjamin Block
2017-08-11 14:36 ` Christoph Hellwig
2017-08-11 15:32 ` Benjamin Block
2017-08-11 15:35 ` Christoph Hellwig
2017-08-11 16:01 ` Benjamin Block
2017-08-13 14:39 ` Christoph Hellwig
2017-08-14 16:33 ` Benjamin Block
2017-08-14 16:32 ` Benjamin Block
2017-08-16 10:53 ` Christoph Hellwig [this message]
2017-08-09 14:11 ` [RFC PATCH 2/6] bsg: assign sense_len instead of fixed SCSI_SENSE_BUFFERSIZE Benjamin Block
2017-08-10 9:32 ` Christoph Hellwig
2017-08-09 14:11 ` [RFC PATCH 3/6] bsg: scsi-transport: add compile-tests to prevent reply-buffer overflows Benjamin Block
2017-08-10 9:32 ` Christoph Hellwig
2017-08-09 14:11 ` [RFC PATCH 4/6] bsg: refactor ioctl to use regular BSG-command infrastructure for SG_IO Benjamin Block
2017-08-10 8:24 ` Johannes Thumshirn
2017-08-10 9:34 ` Christoph Hellwig
2017-08-10 22:12 ` Benjamin Block
2017-08-09 14:11 ` [RFC PATCH 5/6] bsg: reduce unnecessary arguments for bsg_map_hdr() Benjamin Block
2017-08-10 8:26 ` Johannes Thumshirn
2017-08-10 9:35 ` Christoph Hellwig
2017-08-10 22:19 ` Benjamin Block
2017-08-09 14:11 ` [RFC PATCH 6/6] bsg: reduce unnecessary arguments for blk_complete_sgv4_hdr_rq() Benjamin Block
2017-08-10 8:27 ` Johannes Thumshirn
2017-08-10 9:35 ` Christoph Hellwig
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=20170816105318.GA30759@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=bblock@linux.vnet.ibm.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=maier@linux.vnet.ibm.com \
--cc=martin.petersen@oracle.com \
--cc=open-iscsi@googlegroups.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
Powered by JetHome