All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: Avoid crashing if device uses DIX but adapter does not support it
@ 2015-01-14 21:13 Ewan D. Milne
  2015-01-15  1:18 ` Martin K. Petersen
  0 siblings, 1 reply; 3+ messages in thread
From: Ewan D. Milne @ 2015-01-14 21:13 UTC (permalink / raw)
  To: linux-scsi

From: "Ewan D. Milne" <emilne@redhat.com>

This can happen if a multipathed device uses DIX and another path is
added via an adapter that does not support it.  Multipath should not
allow this path to be added, but we should not depend upon that to avoid
crashing.

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
---
 drivers/scsi/scsi_lib.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 6d5c0b8..4f14f4a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1143,7 +1143,17 @@ int scsi_init_io(struct scsi_cmnd *cmd)
 		struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
 		int ivecs, count;
 
-		BUG_ON(prot_sdb == NULL);
+		if (prot_sdb == NULL) {
+			/*
+			 * This can happen if someone (e.g. multipath)
+			 * queues a command to a device on an adapter
+			 * that does not support T10 PI.
+			 */
+			WARN_ON_ONCE(1);
+			error = BLKPREP_KILL;
+			goto err_exit;
+		}
+
 		ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio);
 
 		if (scsi_alloc_sgtable(prot_sdb, ivecs, is_mq)) {
-- 
1.7.11.7


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

* Re: [PATCH] scsi: Avoid crashing if device uses DIX but adapter does not support it
  2015-01-14 21:13 [PATCH] scsi: Avoid crashing if device uses DIX but adapter does not support it Ewan D. Milne
@ 2015-01-15  1:18 ` Martin K. Petersen
  2015-01-15 13:32   ` Ewan Milne
  0 siblings, 1 reply; 3+ messages in thread
From: Martin K. Petersen @ 2015-01-15  1:18 UTC (permalink / raw)
  To: Ewan D. Milne; +Cc: linux-scsi

>>>>> "Ewan" == Ewan D Milne <emilne@redhat.com> writes:

Ewan> This can happen if a multipathed device uses DIX and another path
Ewan> is added via an adapter that does not support it.  Multipath
Ewan> should not allow this path to be added,

No it shouldn't :)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 6d5c0b8..4f14f4a 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1143,7 +1143,17 @@ int scsi_init_io(struct scsi_cmnd *cmd)
 		struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
 		int ivecs, count;
 
-		BUG_ON(prot_sdb == NULL);
+		if (prot_sdb == NULL) {
+			/*
+			 * This can happen if someone (e.g. multipath)
+			 * queues a command to a device on an adapter
+			 * that does not support T10 PI.

s/T10 PI/DIX/

+			 */
+			WARN_ON_ONCE(1);
+			error = BLKPREP_KILL;
+			goto err_exit;
+		}
+
 		ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio);
 
 		if (scsi_alloc_sgtable(prot_sdb, ivecs, is_mq)) {

Failing more gracefully is OK with me.

Acked-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: Avoid crashing if device uses DIX but adapter does not support it
  2015-01-15  1:18 ` Martin K. Petersen
@ 2015-01-15 13:32   ` Ewan Milne
  0 siblings, 0 replies; 3+ messages in thread
From: Ewan Milne @ 2015-01-15 13:32 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: linux-scsi

On Wed, 2015-01-14 at 20:18 -0500, Martin K. Petersen wrote:
> >>>>> "Ewan" == Ewan D Milne <emilne@redhat.com> writes:
> 
> Ewan> This can happen if a multipathed device uses DIX and another path
> Ewan> is added via an adapter that does not support it.  Multipath
> Ewan> should not allow this path to be added,
> 
> No it shouldn't :)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 6d5c0b8..4f14f4a 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1143,7 +1143,17 @@ int scsi_init_io(struct scsi_cmnd *cmd)
>  		struct scsi_data_buffer *prot_sdb = cmd->prot_sdb;
>  		int ivecs, count;
>  
> -		BUG_ON(prot_sdb == NULL);
> +		if (prot_sdb == NULL) {
> +			/*
> +			 * This can happen if someone (e.g. multipath)
> +			 * queues a command to a device on an adapter
> +			 * that does not support T10 PI.
> 
> s/T10 PI/DIX/

Good point.  I'll submit a v2 to change the comment.

> 
> +			 */
> +			WARN_ON_ONCE(1);
> +			error = BLKPREP_KILL;
> +			goto err_exit;
> +		}
> +
>  		ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio);
>  
>  		if (scsi_alloc_sgtable(prot_sdb, ivecs, is_mq)) {
> 
> Failing more gracefully is OK with me.
> 
> Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
> 



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

end of thread, other threads:[~2015-01-15 13:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14 21:13 [PATCH] scsi: Avoid crashing if device uses DIX but adapter does not support it Ewan D. Milne
2015-01-15  1:18 ` Martin K. Petersen
2015-01-15 13:32   ` Ewan Milne

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.