Skip to contentSkip to conversation

two bsg fixes

PATCH New Christoph Hellwig 2 participants 4 messages Jul 31, 2021 – Aug 1, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Martin,

this series contains two small fixes for commands without data transfer for the recent bsg changes.

#1 lore raw

PATCH 1/2 scsi: bsg: fix commands without data transfer in scsi_bsg_sg_io_fn

Set ret to 0 after the initial permission checks to avoid leaking -EPERM for commands without data transfer.

Fixes 75ca56409e5b ("scsi: bsg: Move the whole request execution into the SCSI/transport handlers")
---
 drivers/scsi/scsi_bsg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/scsi_bsg.c +1 -0
index d13a67b82429..81c3853a2a80 100644
@@ -47,6 +47,7 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
 	if (!scsi_cmd_allowed(sreq->cmd, mode))
 		goto out_free_cmd;
 
+	ret = 0;
 	if (hdr->dout_xfer_len) {
 		ret = blk_rq_map_user(rq->q, rq, NULL, uptr64(hdr->dout_xferp),
 				hdr->dout_xfer_len, GFP_KERNEL);
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 bsg-lib: fix commands without data transfer in bsg_transport_sg_io_fn

In reply to Christoph Hellwig

Set ret to 0 after the initial permission checks to avoid leaking -EPERM for commands without data transfer.

Fixes 75ca56409e5b ("scsi: bsg: Move the whole request execution into the SCSI/transport

handlers")

---
 block/bsg-lib.c | 1 +
 1 file changed, 1 insertion(+)
block/bsg-lib.c +1 -0
index 239ebf747141..ccb98276c964 100644
@@ -72,6 +72,7 @@ static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
 		job->bidi_bio = NULL;
 	}
 
+	ret = 0;
 	if (hdr->dout_xfer_len) {
 		ret = blk_rq_map_user(rq->q, rq, NULL, uptr64(hdr->dout_xferp),
 				hdr->dout_xfer_len, GFP_KERNEL);
Signature · 1 line
2.30.2
#3 lore raw
In reply to Christoph Hellwig

Christoph,

Quoted 2 lines

this series contains two small fixes for commands without data transfer for the recent bsg changes.

Applied to 5.15/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering