Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2330312imm; Thu, 20 Sep 2018 11:18:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdayN27sjFMg+/tF6/m4/5FO2W5oRajOtnH2Myhtejjr3GL7MYM4MtvYOpYkBOZyKSHpfAE/ X-Received: by 2002:a17:902:925:: with SMTP id 34-v6mr40956038plm.307.1537467524156; Thu, 20 Sep 2018 11:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537467524; cv=none; d=google.com; s=arc-20160816; b=xtAYXWpetbhh0X4QaZf/u7sGfBd0mLxZbjfO/0KGtydKbhmZfnI3vJkVk/rtv6GCbB szI25CyDHxJ9HvHsHMYR4BJApQByjzRYqtecGLZiHjcED8CYAA2avW81XBHhaaPeD4/c WO+hjFSDDM/BC1x85lCgTZFVyIYrsz/x62kxg03VY8M75Fkklfk0IUkpkh74Te7WtGnP qGnrqwWr81xKKZNiI6aY72MiKuQUzJFQUcJKD43Z35ci3rfr8MrwryVX05nNIiFkgJ0q u2v2tcoFH4806t3uFK/XeqvZLVVsYlru5VWq9qQ4x4ElgQokwH95z3tjWzZ3bnyFpbyr YmEA== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=JCcavlPVPvdBxcaFEW9JLUDAXKXmk3ocVqWd2XRCOzg=; b=eS+Oy/x/q8kmhavk4F1yO0jtjw5vAXtQarLcwlU8UMc9iTrKEl5uV2blwCouDj79L9 J/z3ihZxKr+/+v2Pf9FSPifcEvWGxMmQzZDlFIsbox4zA7UTzveobxk6+gdKqdUpTwpb KxN3xm1tj7b8y4cIkPg4yR0j/l/jFZ5znb4xpEdjusfuceTD9QOOc2Xb1vWbX0qCeEzS ipXv6qK+lmTs7i8+sMusAhwkVMsN8/apUN9Fe7CrFgzEH3+VgynHLVymcwDEq6t0sxMP 5r58fuUMnM2ZcvUd3XChmB1h9es1416P0JjcvXdeZ4gi4aChkeq+TW/ExEI3m8s7H9vd aA0Q== 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 v9-v6si26306919pfg.123.2018.09.20.11.18.28; Thu, 20 Sep 2018 11:18:44 -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 S1733117AbeIUADH (ORCPT + 99 others); Thu, 20 Sep 2018 20:03:07 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38371 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727094AbeIUADH (ORCPT ); Thu, 20 Sep 2018 20:03:07 -0400 Received: by mail-pf1-f193.google.com with SMTP id x17-v6so4754596pfh.5; Thu, 20 Sep 2018 11:18:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=JCcavlPVPvdBxcaFEW9JLUDAXKXmk3ocVqWd2XRCOzg=; b=rwzBAEgs/rqwi5QZVBoL937TAgeItVDTROh47DdEkCfboFTQaA/o/E0RknUu0gmgol 9lJ3qYbTQAv1EAWdF6XdJEqj1CrMCNzMjsRyyuKoocxnGHG/PtYMnuxEP3B/Xj6gqpjs 6P6jme0caxykJF8b9cMENw8ewlJPi54P9fXE1f625a2LSD1lQ/jjFyKS2C6tZruJC2K0 jEugp45AqwEJA0l+uK9jwSIS/HICFl0R1P0xX4zjsEr9Vd4ImkE8JlFOqCZQKzMqNyMZ 3fAcL3rpQXTeYvZwtw7yUz8vc6PIpBhr7Ud4wGxGOPiJBgRSXM9HDpAT22G+KwNilYdn hN8A== X-Gm-Message-State: APzg51CA/JApXYlb3s6CQIYQTdhcH0THNIacT+gZrrGFEF+t513vLPCy GWPgo/pSZzVGd6p9z4wtvq8= X-Received: by 2002:aa7:818f:: with SMTP id g15-v6mr42303810pfi.71.1537467502071; Thu, 20 Sep 2018 11:18:22 -0700 (PDT) Received: from ?IPv6:2620:15c:2cd:203:5cdc:422c:7b28:ebb5? ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id t14-v6sm26244720pgu.0.2018.09.20.11.18.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 11:18:21 -0700 (PDT) Message-ID: <1537467499.224533.21.camel@acm.org> Subject: Re: [PATCH] scsi: sd: don't crash the host on invalid commands From: Bart Van Assche To: Johannes Thumshirn , "Martin K . Petersen" Cc: Linux Kernel Mailinglist , Linux SCSI Mailinglist , Hannes Reinecke , Christoph Hellwig Date: Thu, 20 Sep 2018 11:18:19 -0700 In-Reply-To: <20180920071907.10102-1-jthumshirn@suse.de> References: <20180920071907.10102-1-jthumshirn@suse.de> Content-Type: text/plain; charset="UTF-7" X-Mailer: Evolution 3.26.2-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-09-20 at 09:19 +-0200, Johannes Thumshirn wrote: +AD4 When sd+AF8-init+AF8-command() get's a with a unknown req+AF8-op() it crashes the +AD4 system via BUG(). +AD4 +AD4 This makes debugging the actual reason for the broken request +AD4 cmd+AF8-flags pretty hard as the system is down before it's able to write +AD4 out debugging data on the serial console or the trace buffer. +AD4 +AD4 Change the BUG() to a WARN+AF8-ON() and return BLKPREP+AF8-KILL to fail +AD4 gracefully and return an I/O error to the producer of the request. +AD4 +AD4 Signed-off-by: Johannes Thumshirn +ADw-jthumshirn+AEA-suse.de+AD4 +AD4 Cc: Hannes Reinecke +ADw-hare+AEA-suse.de+AD4 +AD4 Cc: Bart Van Assche +ADw-bvanassche+AEA-acm.org+AD4 +AD4 Cc: Christoph Hellwig +ADw-hch+AEA-lst.de+AD4 +AD4 --- +AD4 Fixed Typo in Bart's mail, sorry for this. +AD4 +AD4 drivers/scsi/sd.c +AHw 3 +-+-- +AD4 1 file changed, 2 insertions(+-), 1 deletion(-) +AD4 +AD4 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c +AD4 index b79b366a94f7..19f28962d65b 100644 +AD4 --- a/drivers/scsi/sd.c +AD4 +-+-+- b/drivers/scsi/sd.c +AD4 +AEAAQA -1276,7 +-1276,8 +AEAAQA static int sd+AF8-init+AF8-command(struct scsi+AF8-cmnd +ACo-cmd) +AD4 case REQ+AF8-OP+AF8-ZONE+AF8-RESET: +AD4 return sd+AF8-zbc+AF8-setup+AF8-reset+AF8-cmnd(cmd)+ADs +AD4 default: +AD4 - BUG()+ADs +AD4 +- WARN+AF8-ON(1)+ADs +AD4 +- return BLKPREP+AF8-KILL+ADs +AD4 +AH0 +AD4 +AH0 Have you considered to use WARN+AF8-ON+AF8-ONCE() instead of WARN+AF8-ON(1)? Otherwise this patch looks good to me. Thanks, Bart.