All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	linux-block@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: [PATCH 1/2] scsi: bsg: fix commands without data transfer in scsi_bsg_sg_io_fn
Date: Sat, 31 Jul 2021 09:40:26 +0200	[thread overview]
Message-ID: <20210731074027.1185545-2-hch@lst.de> (raw)
In-Reply-To: <20210731074027.1185545-1-hch@lst.de>

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")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 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.30.2


  reply	other threads:[~2021-07-31  7:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31  7:40 two bsg fixes Christoph Hellwig
2021-07-31  7:40 ` Christoph Hellwig [this message]
2021-07-31  7:40 ` [PATCH 2/2] bsg-lib: fix commands without data transfer in bsg_transport_sg_io_fn Christoph Hellwig
2021-08-01 17:22 ` two bsg fixes Martin K. Petersen

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=20210731074027.1185545-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.