stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: sg: fix SG_DXFER_FROM_DEV transfers
@ 2017-07-18  7:42 Johannes Thumshirn
  2017-07-18  7:50 ` Greg Kroah-Hartman
  2017-07-18 15:45 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2017-07-18  7:42 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, Johannes Thumshirn, Douglas Gilbert,
	Martin K . Petersen

(commit 68c59fcea1f2c6a54c62aa896cc623c1b5bc9b47 upstream)

SG_DXFER_FROM_DEV transfers do not necessarily have a dxferp as we set
it to NULL for the old sg_io read/write interface, but must have a
length bigger than 0. This fixes a regression introduced by commit
28676d869bbb ("scsi: sg: check for valid direction before starting the
request")

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Fixes: 28676d869bbb ("scsi: sg: check for valid direction before starting the request")
Reported-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 drivers/scsi/sg.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 21225d62b0c1..1e82d4128a84 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -758,8 +758,11 @@ static bool sg_is_valid_dxfer(sg_io_hdr_t *hp)
 		if (hp->dxferp || hp->dxfer_len > 0)
 			return false;
 		return true;
-	case SG_DXFER_TO_DEV:
 	case SG_DXFER_FROM_DEV:
+		if (hp->dxfer_len < 0)
+			return false;
+		return true;
+	case SG_DXFER_TO_DEV:
 	case SG_DXFER_TO_FROM_DEV:
 		if (!hp->dxferp || hp->dxfer_len == 0)
 			return false;
-- 
2.12.3

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

end of thread, other threads:[~2017-07-19  6:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-18  7:42 [PATCH] scsi: sg: fix SG_DXFER_FROM_DEV transfers Johannes Thumshirn
2017-07-18  7:50 ` Greg Kroah-Hartman
2017-07-18  7:52   ` Johannes Thumshirn
2017-07-18 15:45 ` Greg Kroah-Hartman
2017-07-18 15:54   ` Martin K. Petersen
2017-07-18 16:18     ` Greg Kroah-Hartman
2017-07-19  6:48       ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).