linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] scsi: sd: don't crash the host on invalid commands
@ 2018-09-21  7:01 Johannes Thumshirn
  2018-09-21 13:52 ` Bart Van Assche
  2018-09-26  0:52 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2018-09-21  7:01 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>
Reviewed-by: Christoph Hellwig <hch@lst.de>

---
Changes since v1:
- Use WARN_ON_ONCE() (Bart)
---
 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..f2e41f04e40b 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_ONCE(1);
+		return BLKPREP_KILL;
 	}
 }
 
-- 
2.16.4


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

* Re: [PATCH v2] scsi: sd: don't crash the host on invalid commands
  2018-09-21  7:01 [PATCH v2] scsi: sd: don't crash the host on invalid commands Johannes Thumshirn
@ 2018-09-21 13:52 ` Bart Van Assche
  2018-09-26  0:52 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2018-09-21 13:52 UTC (permalink / raw)
  To: Johannes Thumshirn, Martin K . Petersen
  Cc: Linux Kernel Mailinglist, Linux SCSI Mailinglist,
	Hannes Reinecke, Christoph Hellwig

On 9/21/18 12:01 AM, Johannes Thumshirn wrote:
> 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.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

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

* Re: [PATCH v2] scsi: sd: don't crash the host on invalid commands
  2018-09-21  7:01 [PATCH v2] scsi: sd: don't crash the host on invalid commands Johannes Thumshirn
  2018-09-21 13:52 ` Bart Van Assche
@ 2018-09-26  0:52 ` Martin K. Petersen
  2018-09-26  6:51   ` Johannes Thumshirn
  1 sibling, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2018-09-26  0:52 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Martin K . Petersen, Linux Kernel Mailinglist,
	Linux SCSI Mailinglist, Hannes Reinecke, Bart Van Assche,
	Christoph Hellwig


Johannes,

> 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.

Looks like a bunch of my merge mails didn't make it out last week.

For the record, I did merge this into 4.19/scsi-fixes and it has made
its way upstream.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v2] scsi: sd: don't crash the host on invalid commands
  2018-09-26  0:52 ` Martin K. Petersen
@ 2018-09-26  6:51   ` Johannes Thumshirn
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2018-09-26  6:51 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Linux Kernel Mailinglist, Linux SCSI Mailinglist,
	Hannes Reinecke, Bart Van Assche, Christoph Hellwig

On Tue, Sep 25, 2018 at 08:52:58PM -0400, Martin K. Petersen wrote:
> Looks like a bunch of my merge mails didn't make it out last week.
> 
> For the record, I did merge this into 4.19/scsi-fixes and it has made
> its way upstream.

Thanks for the info.

Byte,
	Johannes
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21  7:01 [PATCH v2] scsi: sd: don't crash the host on invalid commands Johannes Thumshirn
2018-09-21 13:52 ` Bart Van Assche
2018-09-26  0:52 ` Martin K. Petersen
2018-09-26  6:51   ` 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).