virtio_blk: Fix an SG_IO regression
Subsystems (6)
PATCH 1/1 virtio_blk: Fix an SG_IO regression
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!
Additionally, make it easier to diagnose crashes like the one fixed by this patch.
Reported-by Dann Frazier <[email protected]>
Fixes commit ca18d6f769d2 ("block: Make most scsi_req_init() calls implicit")
Signed-off-by Bart Van Assche <[email protected]>
Tested-by Dann Frazier <[email protected]>
Cc Dann Frazier <[email protected]>
Cc Martin K. Petersen <[email protected]>
Cc <[email protected]> # v4.13
--- drivers/block/virtio_blk.c | 1 + drivers/scsi/sg.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/block/virtio_blk.c +1 -0
@@ -597,6 +597,7 @@ 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 = scsi_initialize_rq, .map_queues = virtblk_map_queues, };
drivers/scsi/sg.c +2 -0
@@ -1722,6 +1722,8 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) } req =scsi_req (rq); +WARN_ON_ONCE (!req->cmd); +if (hp->cmd_len >BLK_MAX_CDB ) req->cmd = long_cmdp;memcpy (req->cmd, cmd, hp->cmd_len);
Signature · 1 line
2.14.2
Jens Axboe
maintainerQuoted 8 lines · Bart Van Assche
Avoid that submitting an
SG_IOioctl 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!Additionally, make it easier to diagnose crashes like the one fixed by this patch.
This really should have been two patches... Anyway, applied for 4.14.
Signature · 1 line
Jens Axboe