mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yingjie Wang <x-professor@outlook.com>
To: "Martin K . Petersen" <mkp@kernel.org>,
	"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	Bart Van Assche <bvanassche@acm.org>,
	Yang Xiuwei <yangxiuwei@kylinos.cn>, Jens Axboe <axboe@kernel.dk>,
	"io-uring@vger.kernel.org" <io-uring@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 5/6] scsi: bsg: clear io_uring sense length on copy failure
Date: Mon, 26 Oct 2026 08:29:39 +0000	[thread overview]
Message-ID: <43ee84525e456f95cc0efbb6b65c2074cc874e1e.1793003363.git.x-professor@outlook.com> (raw)
In-Reply-To: <cover.1793003363.git.x-professor@outlook.com>

From: Yingjie Wang <x-professor@outlook.com>

The SCSI BSG io_uring completion reports sense_len_wr in res2 as the
number of sense bytes written to the response buffer. If copy_to_user()
fails, the callback returns -EFAULT but leaves that field nonzero.

Clear the reported sense length on a failed copy, matching the
synchronous BSG and SG_IO interfaces. This reporting error predates the
request-lifetime changes and can be fixed independently.

Fixes: 7b6d3255e7f8 ("scsi: bsg: add io_uring passthrough handler")
Link: https://lore.kernel.org/r/20261022.scsi-copyback-review.31b8d6a70f4c@outlook.com
Signed-off-by: Yingjie Wang <x-professor@outlook.com>
---
 drivers/scsi/scsi_bsg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_bsg.c b/drivers/scsi/scsi_bsg.c
index 650facb16ed23..98c9db1cae653 100644
--- a/drivers/scsi/scsi_bsg.c
+++ b/drivers/scsi/scsi_bsg.c
@@ -52,8 +52,10 @@ static void scsi_bsg_uring_task_cb(struct io_tw_req tw_req, io_tw_token_t tw)
 
 	if (sense_len_wr) {
 		if (copy_to_user(uptr64(pdu->response_addr), scmd->sense_buffer,
-				 sense_len_wr))
+				 sense_len_wr)) {
 			ret = -EFAULT;
+			sense_len_wr = 0;
+		}
 	}
 
 	res2 = bsg_scsi_res2_build(status_byte(scmd->result), driver_status,
-- 
2.43.0


  parent reply	other threads:[~2026-10-26  8:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26  8:29 [PATCH v2 0/6] scsi: release completed passthrough requests before user copyback Yingjie Wang
2026-10-26  8:29 ` [PATCH v2 1/6] scsi: core: release SG_IO request " Yingjie Wang
2026-10-26  8:29 ` [PATCH v2 2/6] scsi: core: release legacy ioctl " Yingjie Wang
2026-10-26  8:29 ` [PATCH v2 3/6] scsi: sr: release CDDA " Yingjie Wang
2026-10-26  8:29 ` [PATCH v2 4/6] scsi: bsg: release synchronous " Yingjie Wang
2026-10-26  8:29 ` Yingjie Wang [this message]
2026-10-26  9:40   ` [PATCH v2 5/6] scsi: bsg: clear io_uring sense length on copy failure Yang Xiuwei
2026-10-26  8:29 ` [PATCH v2 6/6] scsi: bsg: release io_uring requests in end-I/O Yingjie Wang
2026-10-26  9:40   ` Yang Xiuwei
2026-10-27  9:35     ` Yang Xiuwei
2026-10-29 16:39       ` Yingjie Wang
2026-10-26 15:56   ` Bart Van Assche

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=43ee84525e456f95cc0efbb6b65c2074cc874e1e.1793003363.git.x-professor@outlook.com \
    --to=x-professor@outlook.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkp@kernel.org \
    --cc=yangxiuwei@kylinos.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®