Blob Blame History Raw
From: Christoph Hellwig <hch@lst.de>
Date: Sat, 31 Jul 2021 09:40:26 +0200
Subject: [PATCH] scsi: bsg: Fix commands without data transfer in
Git-commit: 5c0f61377b765e650b1bc85298b79add1148c97f
Patch-mainline: v5.15-rc1
References: jsc#PED-1559
 scsi_bsg_sg_io_fn()

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

Link: https://lore.kernel.org/r/20210731074027.1185545-2-hch@lst.de
Fixes: 75ca56409e5b ("scsi: bsg: Move the whole request execution into the SCSI/transport handlers")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_bsg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/scsi_bsg.c b/drivers/scsi/scsi_bsg.c
index d13a67b82429..81c3853a2a80 100644
--- a/drivers/scsi/scsi_bsg.c
+++ b/drivers/scsi/scsi_bsg.c
@@ -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);
-- 
2.35.3