Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1656997imm; Thu, 20 Sep 2018 00:19:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYWwAVURtzqFdvcGnhqExTe4hEZA/9E+s5QZgtN8/3RhgR5lg1g3qg9O9pi2LdTD53fNuiZ X-Received: by 2002:a17:902:7c8c:: with SMTP id y12-v6mr38369511pll.283.1537427994051; Thu, 20 Sep 2018 00:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537427994; cv=none; d=google.com; s=arc-20160816; b=uTqvuOZP/rrhAM4z6/sk/NyeDYgpFGrfvLm6myqsMMFV/m3oMXnlzkgU75P3hUC7lq 7wXHIspeRJleIWSUm4S0xKUp/0UDkHB9brVXdgHzGWYoKZ1QJkobFoRwiCjST8lr37qs qSW4el4zf7UhAsBwwAioGVDwtLXzMx7Qz9xAh7EnVFaJGsabw0CRxZ2j+48IdZxSxjHT Yg7fY+AlgkhxNNAEtWhVxspa0vyJ95hCUOWpSkEOz+QcQea0kRWg4cUQWvJCXjGIvZVU cV4m3+KfqHvjnJ9LDCoLgPqRaq/AMKZCSMvawf9jLxHeapkPZ8kba5hca9Wty/bMY33A iAOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=ZbD7pzWJ/hjX1DM+OdcvX6DfxmRf3rkGxJ1k9x+Levg=; b=P06YRT00/w51saDqstfC+ecrVV8z5FbtpDqd0OfoMOU8LjnkNB+xeAgUmSBXPlV3+x 3yjCbA0jsgyw15+NJ5qFbDPfXVo733Jwtnr0sC4ovSheT3+yDCCzHOXwdvvwj4/X312t efibsM6WDwjhH7CjwTC0m9NmFZtWsKablBOpFTlWLJMKQoYvRjtmDc3pR5ogQ72CUW+y t7kz/jKOE9wlSBsJtRYrg6pSxYzwF+taqWdUDm6OkG767wRnMUlyn1dfS2O2l+VlhsCI 1iiSHMN0zSlm7tIbPqoqBb0sd49jxjB3WV1jWGRHvWRKNByWSaJOege58dp1lmMXepPq ME0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k63-v6si4510071pge.142.2018.09.20.00.19.38; Thu, 20 Sep 2018 00:19:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731621AbeITNBQ (ORCPT + 99 others); Thu, 20 Sep 2018 09:01:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:59510 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726014AbeITNBP (ORCPT ); Thu, 20 Sep 2018 09:01:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 404F0B049; Thu, 20 Sep 2018 07:19:13 +0000 (UTC) From: Johannes Thumshirn To: "Martin K . Petersen" Cc: Linux Kernel Mailinglist , Linux SCSI Mailinglist , Johannes Thumshirn , Hannes Reinecke , Bart Van Assche , Christoph Hellwig Subject: [PATCH] scsi: sd: don't crash the host on invalid commands Date: Thu, 20 Sep 2018 09:19:07 +0200 Message-Id: <20180920071907.10102-1-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Hannes Reinecke Cc: Bart Van Assche Cc: Christoph Hellwig --- 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