public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: sd: don't crash the host on invalid commands
@ 2018-09-20  7:19 Johannes Thumshirn
  2018-09-20  7:33 ` Christoph Hellwig
  2018-09-20 18:18 ` Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2018-09-20  7:19 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Linux Kernel Mailinglist, Linux SCSI Mailinglist,
	Johannes Thumshirn, Hannes Reinecke, Bart Van Assche,
	Christoph Hellwig

When sd_init_command() get's a with a unknown req_op() it crashes the
system via BUG().

This makes debugging the actual reason for the broken request
cmd_flags pretty hard as the system is down before it's able to write
out debugging data on the serial console or the trace buffer.

Change the BUG() to a WARN_ON() and return BLKPREP_KILL to fail
gracefully and return an I/O error to the producer of the request.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>
---
Fixed Typo in Bart's mail, sorry for this.

 drivers/scsi/sd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b79b366a94f7..19f28962d65b 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1276,7 +1276,8 @@ static int sd_init_command(struct scsi_cmnd *cmd)
 	case REQ_OP_ZONE_RESET:
 		return sd_zbc_setup_reset_cmnd(cmd);
 	default:
-		BUG();
+		WARN_ON(1);
+		return BLKPREP_KILL;
 	}
 }
 
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] scsi: sd: don't crash the host on invalid commands
@ 2018-09-20  7:15 Johannes Thumshirn
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2018-09-20  7:15 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Linux Kernel Mailinglist, Linux SCSI Mailinglist,
	Johannes Thumshirn, Hannes Reinecke, Bart Van Asche,
	Christoph Hellwig

When sd_init_command() get's a with a unknown req_op() it crashes the
system via BUG().

This makes debugging the actual reason for the broken request
cmd_flags pretty hard as the system is down before it's able to write
out debugging data on the serial console or the trace buffer.

Change the BUG() to a WARN_ON() and return BLKPREP_KILL to fail
gracefully and return an I/O error to the producer of the request.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Bart Van Asche <bvanasche@acm.org>
Cc: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/sd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b79b366a94f7..19f28962d65b 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1276,7 +1276,8 @@ static int sd_init_command(struct scsi_cmnd *cmd)
 	case REQ_OP_ZONE_RESET:
 		return sd_zbc_setup_reset_cmnd(cmd);
 	default:
-		BUG();
+		WARN_ON(1);
+		return BLKPREP_KILL;
 	}
 }
 
-- 
2.16.4

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

end of thread, other threads:[~2018-09-21  6:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-20  7:19 [PATCH] scsi: sd: don't crash the host on invalid commands Johannes Thumshirn
2018-09-20  7:33 ` Christoph Hellwig
2018-09-20 18:18 ` Bart Van Assche
2018-09-21  6:29   ` Johannes Thumshirn
  -- strict thread matches above, loose matches on Subject: below --
2018-09-20  7:15 Johannes Thumshirn

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