public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] storvsc: do not assume SG list is continuous when doing bounce buffers (for 4.1 stable only)
@ 2017-08-22  5:31 Long Li
  2017-08-22  6:28 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Long Li @ 2017-08-22  5:31 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, James E.J. Bottomley, devel,
	linux-scsi, linux-kernel, stable

From: Long Li <longli@microsoft.com>

This patch is for linux-stable 4.1 branch only.

storvsc checks the SG list for gaps before passing them to Hyper-v device.
If there are gaps, data is copied to a bounce buffer and a continuous data
buffer is passed to Hyper-V.

The check on gaps assumes SG list is continuous, and not chained. This is
 not always true. Failing the check may result in incorrect I/O data
passed to the Hyper-v device.

This code path is not used post Linux 4.1.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/scsi/storvsc_drv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 6c52d14..14dc5c6 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -584,17 +584,18 @@ static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count)
 	for (i = 0; i < sg_count; i++) {
 		if (i == 0) {
 			/* make sure 1st one does not have hole */
-			if (sgl[i].offset + sgl[i].length != PAGE_SIZE)
+			if (sgl->offset + sgl->length != PAGE_SIZE)
 				return i;
 		} else if (i == sg_count - 1) {
 			/* make sure last one does not have hole */
-			if (sgl[i].offset != 0)
+			if (sgl->offset != 0)
 				return i;
 		} else {
 			/* make sure no hole in the middle */
-			if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0)
+			if (sgl->length != PAGE_SIZE || sgl->offset != 0)
 				return i;
 		}
+		sgl = sg_next(sgl);
 	}
 	return -1;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-09 23:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22  5:31 [PATCH] storvsc: do not assume SG list is continuous when doing bounce buffers (for 4.1 stable only) Long Li
2017-08-22  6:28 ` Christoph Hellwig
2017-08-22 19:11   ` Long Li
2017-08-23  6:43     ` Christoph Hellwig
2017-08-23 13:41       ` Greg KH
2017-08-23 15:22       ` Martin K. Petersen
2018-01-09 23:04         ` Long Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox