Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9f97264 authored by Bart Van Assche's avatar Bart Van Assche Committed by Jens Axboe
Browse files

bsg: Check queue type before attaching to a queue



Since BSG only supports request queues for which struct scsi_request
is the first member of their private request data, refuse to register
block layer queues for which struct scsi_request is not the first
member of their private data.

References: commit bd1599d9 ("scsi_transport_sas: fix BSG ioctl memory corruption")
References: commit 82ed4db4 ("block: split scsi_request out of struct request")
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Omar Sandoval <osandov@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 9efc160f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -750,6 +750,12 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
#ifdef BSG_DEBUG
	unsigned char buf[32];
#endif

	if (!blk_queue_scsi_passthrough(rq)) {
		WARN_ONCE(true, "Attempt to register a non-SCSI queue\n");
		return ERR_PTR(-EINVAL);
	}

	if (!blk_get_queue(rq))
		return ERR_PTR(-ENXIO);