From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Douglas Gilbert <dgilbert@interlog.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] block: Allocate a sense buffer before executing an SG_IO ioctl
Date: Wed, 23 Jan 2019 16:04:25 -0800 [thread overview]
Message-ID: <1548288265.9266.75.camel@acm.org> (raw)
In-Reply-To: <20190123190645.119109-1-bvanassche@acm.org>
On Wed, 2019-01-23 at 11:06 -0800, Bart Van Assche wrote:
> Some time ago blk_execute_rq() was modified such that it no longer
> allocates a sense buffer. Make sg_io() allocate and use a sense buffer.
> This patch avoids that the following bug is triggered when running the
> libiscsi tests against the scsi_debug driver:
>
> usercopy: Kernel memory exposure attempt detected from null address (offset 0, size 18)!
> ------------[ cut here ]------------
> kernel BUG at mm/usercopy.c:102!
> CPU: 5 PID: 693 Comm: iscsi-test-cu Not tainted 5.0.0-rc3-dbg+ #3
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
> RIP: 0010:usercopy_abort+0x7a/0x7c
> Call Trace:
> __check_object_size.cold.1+0x37/0x3d
> sg_io+0x5a2/0x700
> scsi_cmd_ioctl+0x4d4/0x540
> scsi_cmd_blk_ioctl+0x7b/0x8b
> sd_ioctl+0xba/0x150
> blkdev_ioctl+0x6e1/0xea0
> block_ioctl+0x79/0x90
> do_vfs_ioctl+0x12b/0x9b0
> ksys_ioctl+0x41/0x80
> __x64_sys_ioctl+0x43/0x50
> do_syscall_64+0x71/0x210
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: Douglas Gilbert <dgilbert@interlog.com>
> Cc: <stable@vger.kernel.org> # v4.11+
> Fixes: 82ed4db499b8 ("block: split scsi_request out of struct request")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> block/scsi_ioctl.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
> index 533f4aee8567..066929ec0d61 100644
> --- a/block/scsi_ioctl.c
> +++ b/block/scsi_ioctl.c
> @@ -299,6 +299,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
> struct request *rq;
> struct scsi_request *req;
> struct bio *bio;
> + u8 sense[SCSI_SENSE_BUFFERSIZE];
>
> if (hdr->interface_id != 'S')
> return -EINVAL;
> @@ -361,6 +362,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
>
> bio = rq->bio;
> req->retries = 0;
> + req->sense = sense;
>
> start_time = jiffies;
Please ignore this patch - I just realized that this is not the right way to
fix the reported issue.
Bart.
prev parent reply other threads:[~2019-01-24 0:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 19:06 [PATCH] block: Allocate a sense buffer before executing an SG_IO ioctl Bart Van Assche
2019-01-24 0:04 ` Bart Van Assche [this message]
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=1548288265.9266.75.camel@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=dgilbert@interlog.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.org \
/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).