diff mbox

target: fix crash with iscsi target and dvd

Message ID 20180416094841.30212-1-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ming Lei April 16, 2018, 9:48 a.m. UTC
When the current page can't be added to bio, one new bio should be
created for adding this page again, instead of ignoring this page.

This patch fixes kernel crash with iscsi target and dvd, as reported
by Wakko.

Cc: Wakko Warner <wakko@animx.eu.org>
Cc: Bart Van Assche <Bart.VanAssche@wdc.com>
Cc: target-devel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Christoph Hellwig <hch@lst.de>
Fixes: 84c8590646d5b35804 ("target: avoid accessing .bi_vcnt directly")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/target/target_core_pscsi.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Christoph Hellwig April 17, 2018, 3:15 p.m. UTC | #1
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Btw, seems like someone needs to volunteer for putting together a pull
request with target fixes for Linus - I haven't heard from Nic for
a while, and we've got quite a few fixes out on the list.
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin K. Petersen April 19, 2018, 3:27 a.m. UTC | #2
Christoph,

> Btw, seems like someone needs to volunteer for putting together a pull
> request with target fixes for Linus - I haven't heard from Nic for a
> while, and we've got quite a few fixes out on the list.

Still happy to take things through SCSI if Nic doesn't materialize.
Bart Van Assche April 19, 2018, 3:40 a.m. UTC | #3
On Wed, 2018-04-18 at 23:27 -0400, Martin K. Petersen wrote:
> Christoph,

> 

> > Btw, seems like someone needs to volunteer for putting together a pull

> > request with target fixes for Linus - I haven't heard from Nic for a

> > while, and we've got quite a few fixes out on the list.

> 

> Still happy to take things through SCSI if Nic doesn't materialize.


Hello Martin,

Can you have a look at the following patch series: "[PATCH 00/14] SCSI target
patches for kernel v4.17" (https://www.spinics.net/lists/target-devel/msg16523.html /
https://patchwork.kernel.org/project/target-devel/list/). Please let me know if you
want me to repost that patch series.

Thanks,

Bart.
Martin K. Petersen April 19, 2018, 4:41 a.m. UTC | #4
Ming,

> When the current page can't be added to bio, one new bio should be
> created for adding this page again, instead of ignoring this page.
>
> This patch fixes kernel crash with iscsi target and dvd, as reported
> by Wakko.

I queued this up in 4.17/scsi-fixes.
diff mbox

Patch

diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 0d99b242e82e..6cb933ecc084 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -890,6 +890,7 @@  pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
 			bytes = min(bytes, data_len);
 
 			if (!bio) {
+new_bio:
 				nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages);
 				nr_pages -= nr_vecs;
 				/*
@@ -931,6 +932,7 @@  pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
 				 * be allocated with pscsi_get_bio() above.
 				 */
 				bio = NULL;
+				goto new_bio;
 			}
 
 			data_len -= bytes;