Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3728323imm; Mon, 8 Oct 2018 08:35:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV63qqGIX5sHVBsgQLGqi3ncjXiHyg9fY0KEAxUnedtJHgPRqk0FhTUmGiupn41mnLYenkkjs X-Received: by 2002:a17:902:4181:: with SMTP id f1-v6mr23970707pld.248.1539012958197; Mon, 08 Oct 2018 08:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539012958; cv=none; d=google.com; s=arc-20160816; b=0zui4SmBJZGfGYlDc+TGSIrFQibadKVzQj0WcnmTgPKSm9oyLr8T0K7agd0Poh+N+P 2UvbE+UT/4751pJ9VyZZXv17Wt96ovBEkmcRlclXiuVw5xA0UGpx60Nm704zu359hedQ JVgP2c6QFVK3Db4uI9Pn5WQYf6NGunJZdwKfIZrdZdf0Y1KUC/s81r+Hn0spHWWOZpvW XF2TCSzJ/7JNbv27T9wuYO18jWYIlolQFxOTn/TSzWGW2oC2vzMbr/Pl3jZnTxDuF2HC YOj5YZuGdiEoyl8kOzBp/V4j7jJaqF3ESc8X9EOhSzPEpDcTH+SOZYeZM8orJS1ELSyj PJRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=14Nz0WrmabjLo5LFJRkdXPJY2Pj1YoWUppAsDU0yMrQ=; b=yAAETtmOKHJfdCZ2q6rg5YY2E7e/k6uwzQ8rQ/wM79ubB6ZHREUdvv3jY36xrUHT9r kKrZOAJfKeAO3JtTrTv3fmFjrzSNHJW5NGM8C4/74CMEpsc1AdMbltZKG1T80NovcTUf HDsA63Z5DasXhxA8DljGZ6FN5i7yZ5ZYMqN9Oj1oKlvryfM3SSl3bF0yr6qQBCan/dUk iKmdZ5iSEdKWA7kceOAnSwEVODS/fHxO4DmYrBKnsB40sGyJPzo6SWOzF9yfNnvfke4U 1lMt5Dq178Pe6MgOY1aMK6ndw6Yx0GmkxVdHvLvKKfUokaRCQUKV8ApnBAdfUseTGEin KSxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h4F9xc0l; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h63-v6si19253743pfd.228.2018.10.08.08.35.42; Mon, 08 Oct 2018 08:35:58 -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; dkim=pass header.i=@kernel.org header.s=default header.b=h4F9xc0l; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbeJHWiY (ORCPT + 99 others); Mon, 8 Oct 2018 18:38:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbeJHWiX (ORCPT ); Mon, 8 Oct 2018 18:38:23 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34C24214FF; Mon, 8 Oct 2018 15:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012368; bh=Kxdz2FMheazQ7bfbYa+j9PFYOkN37ZvsaLMSwIvU5FE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4F9xc0lao5QWh6v+JlJWn870xIYzoEiU0u0hfEp34jkZxJfJ9M80K0fdTMc2E4/s oqWv2XdZ+DO2Y/ZV8Ugruszzx1elVuXBEwFby1MxR49R0DOR2X325svLoe0lK/IJMt RALYB0sODGh2W+NQwetquS6rHomTQnfDp4FpLxFs= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Johannes Thumshirn , Hannes Reinecke , Bart Van Assche , Christoph Hellwig , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 43/58] scsi: sd: don't crash the host on invalid commands Date: Mon, 8 Oct 2018 11:25:08 -0400 Message-Id: <20181008152523.70705-43-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Thumshirn [ Upstream commit f1f1fadacaf08b7cf11714c0c29f8fa4d4ef68a9 ] When sd_init_command() get's a command 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 Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- 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 9421d9877730..0949d3db56e7 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1277,7 +1277,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.17.1