Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2224265imm; Thu, 18 Oct 2018 10:59:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV62rt7y3FJZl+byDIjnmGROFwC1kzsAeEisIuDHfuip9Wtm0RuzKP5VC4Bil69IRtOvpjqEf X-Received: by 2002:a62:6f43:: with SMTP id k64-v6mr30481195pfc.87.1539885558148; Thu, 18 Oct 2018 10:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539885558; cv=none; d=google.com; s=arc-20160816; b=CyMGm1+9XbT9/u92tO/Hro+ovJCeH79ql2xaOB1PTPpA2bwaMrUicCKrpFNe41Gbmh LgfP8TlkasLdklai5HpO4rqNRzNMj3ZgHFVXq9aA9oGeEgtDk/s2KTWlDH1rCc2uQh1p yVRsSPVyBoPOS4TtavKWmIFnUr4vZmzISrrEYZk19aaX7bfOy/HpexDu1k+tkvqgD1uu UclDT3spuRi6qXITnaaRuQlaxFv/c9gH1iYOjHPHwA6lZm7a7L80wEjRx2KeJz85iZbM Q5horUDbXCCk57l/76xyNMQqFSYrv/igl/FxTsi2jnYq1/k8RTBQZFcUolPypxvjnQ9b Z4zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZiNv+L7K5VfrCF+ERaM7/IVd8VvnLtfCN8csor3XoyA=; b=VE+oNYw/pIFeuHuMD0GvI1HkMTLuxLTVIeuAyvUoUrJa57RnvC3J23+t8XzgA3uvmA UPFFbRhBlFSFYwk2r7r3RouzZhYfImF2247KUPCG5cK2RX0XtxQEUv8OJVg83C01dgz4 ZJeWHPRCVyE4MvUKS9qIglVs9SBVFBYXZyPoCE7eIEPNyRfknQO5KPa+Ph3p28X5f1Dc x4ZXq+fwtM4b/nVjFH4V3hvFXdoWmUiV8vM1oW3jZDvHlnPC7D5tyc7XPUnlFyIJOc9W Vt+PwMLow1/vrIpOF0hdP/+W6WIK8+kF9DC19Z+6Y++Dty5PKN8PIOJx+6FaqxKWgL7t 8HWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DF021Tkj; 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 r13-v6si20932150pfb.43.2018.10.18.10.59.02; Thu, 18 Oct 2018 10:59:18 -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=DF021Tkj; 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 S1728959AbeJSCAC (ORCPT + 99 others); Thu, 18 Oct 2018 22:00:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:47684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728572AbeJSCAB (ORCPT ); Thu, 18 Oct 2018 22:00:01 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A13121476; Thu, 18 Oct 2018 17:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885476; bh=PJpztucavY2ev6RVxGFQSYPNnQWBHcD0FyURJ/PvTvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DF021TkjWfX3i+KCuLyzVERNQXSQpFzp27YBhZE2FLEwDG3024pr/oEfM6aEYyzc2 IPFze++mg1q7Pshg38X2xz9LI7yR16jGBmF9fLCK04CpSgPOU35pd9A4cu5gc6npsO ROSGfIpp0q8yBo/fc7sKTaeGmoXajEDRuxkxyTDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Hannes Reinecke , Bart Van Assche , Christoph Hellwig , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.18 35/53] scsi: sd: dont crash the host on invalid commands Date: Thu, 18 Oct 2018 19:54:28 +0200 Message-Id: <20181018175422.756667694@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175416.561567978@linuxfoundation.org> References: <20181018175416.561567978@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1277,7 +1277,8 @@ static int sd_init_command(struct scsi_c case REQ_OP_ZONE_RESET: return sd_zbc_setup_reset_cmnd(cmd); default: - BUG(); + WARN_ON_ONCE(1); + return BLKPREP_KILL; } }