From patchwork Sun Feb 4 04:33:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10199263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1F26F6056F for ; Sun, 4 Feb 2018 04:33:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DE1928F97 for ; Sun, 4 Feb 2018 04:33:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02EB628FD8; Sun, 4 Feb 2018 04:33:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5966728FD7 for ; Sun, 4 Feb 2018 04:33:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbeBDEdq (ORCPT ); Sat, 3 Feb 2018 23:33:46 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38498 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbeBDEdp (ORCPT ); Sat, 3 Feb 2018 23:33:45 -0500 Received: by mail-pf0-f196.google.com with SMTP id q79so2918361pfl.5; Sat, 03 Feb 2018 20:33:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JUvbsiRXske4h6v9bfrFHhiWMC0zUeLoPDXUtYVAvMA=; b=ifYpYJVqrzoZ/4bf4n0MynCOuWnE/PlrSQB9pVoGdzCLBWXFGIqOX091nZ5/8BaXaw qsdWbkAvIHLPmHzhlMQAueyojaIu/gi2IsyAHfg+6yQpQtWltJqEO4TzF2dbwfV0tPtt MRqD5gHWECY8F/InPl1McBCC4uIKH9Zs6BniEf/70G5BEJ4VWFSKGLF+6pD1qBlI5931 lEymRLmFho0ojb/IJ4zDlfgbr7dcCQWCD1v4G2cEhxPlUaE2vpCDV0TsoImAVDMsSgNu VOkqvXgj4NOj0MfXjXrASF4m/BCG3OrPHsDsv2x/IB2aPEXCM2GVQJZPdm6Ft5sTsTqt FDnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JUvbsiRXske4h6v9bfrFHhiWMC0zUeLoPDXUtYVAvMA=; b=KmwkRHm31zgC4lmeD44HnKijPfFY43bkBS4nriDdjwFrQOkCXYVoRBf+3rmU8TKLbP 9GOt9pH+stY1WEOaj29lw59onaczN3qlmvNZ1brSH0PNujr7pZBAQiK+LbEt87UjmpOM ewU/sbztyjcF35yRwzyXuMtCe+XigWEv8dvhpKfcUTFPw1v+A5yObzB8Iho8FIGCfPW/ WHZYD7HzjwBOL1HYi0PVkk3zqCWfTaw9p4seAyb8g319GAj5zBe+NdzH4nMPMA4v8C7Y vvOjAWw+yPyJtSDtI46JS0/S9PsuO5BiO71f/DBesKOGUQY0hDWODMmSq0m4iSvx31mf nkxA== X-Gm-Message-State: APf1xPAww54IiJjasP+4Y3Me4EErQn8Il5UMDGSmHUU8Li1ZNrb6ubHq /T8fNSyY3Pax3XlQYubmKKH/p4oG X-Google-Smtp-Source: AH8x225pIQ+jf5AVxwsCHVgtJK6pa17Qphw8mqXYLGX92bmAzNfP3BWTM9AbWJfiaN98ShEGqJJ1gA== X-Received: by 10.99.109.203 with SMTP id i194mr2807156pgc.4.1517718824563; Sat, 03 Feb 2018 20:33:44 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id z125sm10401035pfz.27.2018.02.03.20.33.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Feb 2018 20:33:44 -0800 (PST) From: Eric Biggers To: linux-ide@vger.kernel.org, Tejun Heo Cc: linux-scsi@vger.kernel.org, syzkaller-bugs@googlegroups.com, Eric Biggers Subject: [PATCH] libata: remove WARN() for DMA or PIO command without data Date: Sat, 3 Feb 2018 20:33:27 -0800 Message-Id: <20180204043327.16760-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <001a11425956f5f3d0055c82f08d@google.com> References: <001a11425956f5f3d0055c82f08d@google.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers syzkaller hit a WARN() in ata_qc_issue() when writing to /dev/sg0. This happened because it issued a READ_6 command with no data buffer. Just remove the WARN(), as it doesn't appear indicate a kernel bug. The expected behavior is to fail the command, which the code does. Here's a reproducer that works in QEMU when /dev/sg0 refers to a disk of the default type ("82371SB PIIX3 IDE"): #include #include int main() { char buf[42] = { [36] = 0x8 /* READ_6 */ }; write(open("/dev/sg0", O_RDWR), buf, sizeof(buf)); } Fixes: f92a26365a72 ("libata: change ATA_QCFLAG_DMAMAP semantics") Reported-by: syzbot+f7b556d1766502a69d85071d2ff08bd87be53d0f@syzkaller.appspotmail.com Cc: # v2.6.25+ Signed-off-by: Eric Biggers --- drivers/ata/libata-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 3c09122bf0382..61b09968d0326 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5401,8 +5401,7 @@ void ata_qc_issue(struct ata_queued_cmd *qc) * We guarantee to LLDs that they will have at least one * non-zero sg if the command is a data command. */ - if (WARN_ON_ONCE(ata_is_data(prot) && - (!qc->sg || !qc->n_elem || !qc->nbytes))) + if (ata_is_data(prot) && (!qc->sg || !qc->n_elem || !qc->nbytes)) goto sys_err; if (ata_is_dma(prot) || (ata_is_pio(prot) &&