Message ID | 20171026101015.29855-1-bart.vanassche@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Oct 26, 2017 at 12:10:15PM +0200, Bart Van Assche wrote: > Avoid that submitting an SG_IO ioctl triggers a kernel oops that > is preceded by: > > usercopy: kernel memory overwrite attempt detected to (null) (<null>) (6 bytes) > kernel BUG at mm/usercopy.c:72! > > Reported-by: Dann Frazier <dann.frazier@canonical.com> > Fixes: commit ca18d6f769d2 ("block: Make most scsi_req_init() calls implicit") > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> > Cc: Michael S. Tsirkin <mst@redhat.com> > Cc: Dann Frazier <dann.frazier@canonical.com> > Cc: <stable@vger.kernel.org> # v4.13 > --- > drivers/block/virtio_blk.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c > index 34e17ee799be..e477d4a5181e 100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -593,10 +593,20 @@ static int virtblk_map_queues(struct blk_mq_tag_set *set) > return blk_mq_virtio_map_queues(set, vblk->vdev, 0); > } > > +static void virtblk_initialize_rq(struct request *req) > +{ > + struct virtblk_req *vbr = blk_mq_rq_to_pdu(req); > + > +#ifdef CONFIG_VIRTIO_BLK_SCSI > + scsi_req_init(&vbr->sreq); > +#endif How about only defininig the initialize_rq method and implementation if CONFIG_VIRTIO_BLK_SCSI is set? Else looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On 10/27/2017 12:39 AM, Christoph Hellwig wrote: > On Thu, Oct 26, 2017 at 12:10:15PM +0200, Bart Van Assche wrote: >> Avoid that submitting an SG_IO ioctl triggers a kernel oops that >> is preceded by: >> >> usercopy: kernel memory overwrite attempt detected to (null) (<null>) (6 bytes) >> kernel BUG at mm/usercopy.c:72! >> >> Reported-by: Dann Frazier <dann.frazier@canonical.com> >> Fixes: commit ca18d6f769d2 ("block: Make most scsi_req_init() calls implicit") >> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> >> Cc: Michael S. Tsirkin <mst@redhat.com> >> Cc: Dann Frazier <dann.frazier@canonical.com> >> Cc: <stable@vger.kernel.org> # v4.13 >> --- >> drivers/block/virtio_blk.c | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c >> index 34e17ee799be..e477d4a5181e 100644 >> --- a/drivers/block/virtio_blk.c >> +++ b/drivers/block/virtio_blk.c >> @@ -593,10 +593,20 @@ static int virtblk_map_queues(struct blk_mq_tag_set *set) >> return blk_mq_virtio_map_queues(set, vblk->vdev, 0); >> } >> >> +static void virtblk_initialize_rq(struct request *req) >> +{ >> + struct virtblk_req *vbr = blk_mq_rq_to_pdu(req); >> + >> +#ifdef CONFIG_VIRTIO_BLK_SCSI >> + scsi_req_init(&vbr->sreq); >> +#endif > > How about only defininig the initialize_rq method and implementation > if CONFIG_VIRTIO_BLK_SCSI is set? > > Else looks good: > > Reviewed-by: Christoph Hellwig <hch@lst.de> I did that while merging it.
On Fri, 2017-10-27 at 08:24 -0600, Jens Axboe wrote: > On 10/27/2017 12:39 AM, Christoph Hellwig wrote: > > How about only defininig the initialize_rq method and implementation > > if CONFIG_VIRTIO_BLK_SCSI is set? > > I did that while merging it. Thanks Jens and Christoph! Bart.
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 34e17ee799be..e477d4a5181e 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -593,10 +593,20 @@ static int virtblk_map_queues(struct blk_mq_tag_set *set) return blk_mq_virtio_map_queues(set, vblk->vdev, 0); } +static void virtblk_initialize_rq(struct request *req) +{ + struct virtblk_req *vbr = blk_mq_rq_to_pdu(req); + +#ifdef CONFIG_VIRTIO_BLK_SCSI + scsi_req_init(&vbr->sreq); +#endif +} + static const struct blk_mq_ops virtio_mq_ops = { .queue_rq = virtio_queue_rq, .complete = virtblk_request_done, .init_request = virtblk_init_request, + .initialize_rq_fn = virtblk_initialize_rq, .map_queues = virtblk_map_queues, };
Avoid that submitting an SG_IO ioctl triggers a kernel oops that is preceded by: usercopy: kernel memory overwrite attempt detected to (null) (<null>) (6 bytes) kernel BUG at mm/usercopy.c:72! Reported-by: Dann Frazier <dann.frazier@canonical.com> Fixes: commit ca18d6f769d2 ("block: Make most scsi_req_init() calls implicit") Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Dann Frazier <dann.frazier@canonical.com> Cc: <stable@vger.kernel.org> # v4.13 --- drivers/block/virtio_blk.c | 10 ++++++++++ 1 file changed, 10 insertions(+)