Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2019872imm; Thu, 24 May 2018 04:37:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp/rGqEGvMPxPfNaSc1nXtrJS2Dsfr7YLuDHVTHnJawVLvi7hTX/73zHE20Z46yffqWTzC2 X-Received: by 2002:a17:902:b216:: with SMTP id t22-v6mr7073221plr.105.1527161874541; Thu, 24 May 2018 04:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161874; cv=none; d=google.com; s=arc-20160816; b=OxRrWelE+GzPnv8fhe/1b48es/PiWzUCxhu0AgMmZlmzWx/9F7KAOtu2YrX7Lkz6v7 MWTH4fb8QxBlAoKjFlI4voBXuIgX63MT3hOEPMhV2DjvVX/c8rUYc3sQ8Tb3G1XMyJEs LYeHEo57yH4jHcvHp4CDpaZbGCH/DwvBou/54VX+0d0iWjtL2xkLAAN8VVPjka1BqEA6 RjsYS8LJ0rQOG48svy72hlgR6Xge/DrqEAZ73v8jMXgfVqkmciCWMUX9tqOmpg+pe5qz IF7UcNjytT7itXecvl9PbaAx79V/R7Qnzdn5z7xuQ1eQx+TYCZtoHpfQCFeklfjlOk4a SVFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ML0/HXVcnq6V/l4y82ocu/w9ttSmrog05Bv41Tbufbo=; b=gmW8cov5/j368Sv3yuG+YozMbMnspytsMuNYmBP3g92/iWD71UHL3EUGYpEuWj1IDn GVs6bwEV+YvOlpr45il+t1WaDpJokbfIXuvsVLSHCeMk1OLtUMLubCY2whoAMdGTC7hk rlgh+6ZZDS1B3mQqfERL+MkmDtR3hZcoQD6QwVsmoqjWFez3V4KFs1h1oeh4Yvw2oG6W swxODXYanXbif1sMcmlBH7b/2oe8AoYb64D6EZW/3Rn5xeWTDGeCeQArLTFLZ9viyxaj 4JS/su0mov7NhHqPjGSr0KiTkH7SRcLNLcU5ahWqWBhF2PC3NpdT1cTJRD8LCfNblKtP KrCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IBesWQ+I; 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 k14-v6si5239226pgr.206.2018.05.24.04.37.39; Thu, 24 May 2018 04:37: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; dkim=pass header.i=@kernel.org header.s=default header.b=IBesWQ+I; 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 S969098AbeEXLg7 (ORCPT + 99 others); Thu, 24 May 2018 07:36:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:38798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967421AbeEXJtj (ORCPT ); Thu, 24 May 2018 05:49:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 67AB6208AE; Thu, 24 May 2018 09:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155378; bh=UlUqtLpCe7XgRf+yRoya1GxSTM+J+HRk9hUZA/g8tog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBesWQ+ImayaeYfPX12DqcWC6XiuKmCgBcZ1Yhq7bsTi9WwIbl/jMjGHyD+FM1LmX b8/U0zt9kJnZ7z2gh05UFfT7R4GfDxpxsqmXjW0GubdJVSlK43NdzlXd25PiMJwKYx 8EPA0zxInklUfF9gTkHhO7YZHdDMkbxsdQrViaXI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fredrik Noring , Alan Stern , Sasha Levin Subject: [PATCH 4.9 31/96] USB: OHCI: Fix NULL dereference in HCDs using HCD_LOCAL_MEM Date: Thu, 24 May 2018 11:38:14 +0200 Message-Id: <20180524093607.335454929@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fredrik Noring [ Upstream commit d6c931ea32dc08ac2665bb5f009f9c40ad1bbdb3 ] Scatter-gather needs to be disabled when using dma_declare_coherent_memory and HCD_LOCAL_MEM. Andrea Righi made the equivalent fix for EHCI drivers in commit 4307a28eb01284 "USB: EHCI: fix NULL pointer dererence in HCDs that use HCD_LOCAL_MEM". The following NULL pointer WARN_ON_ONCE triggered with OHCI drivers: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 49 at drivers/usb/core/hcd.c:1379 hcd_alloc_coherent+0x4c/0xc8 Modules linked in: CPU: 0 PID: 49 Comm: usb-storage Not tainted 4.15.0+ #1014 Stack : 00000000 00000000 805a78d2 0000003a 81f5c2cc 8053d367 804d77fc 00000031 805a3a08 00000563 81ee9400 805a0000 00000000 10058c00 81f61b10 805c0000 00000000 00000000 805a0000 00d9038e 00000004 803ee818 00000006 312e3420 805c0000 00000000 00000073 81f61958 00000000 00000000 802eb380 804fd538 00000009 00000563 81ee9400 805a0000 00000002 80056148 00000000 805a0000 ... Call Trace: [<578af360>] show_stack+0x74/0x104 [<2f3702c6>] __warn+0x118/0x120 [] warn_slowpath_null+0x44/0x58 [] hcd_alloc_coherent+0x4c/0xc8 [<3578fa36>] usb_hcd_map_urb_for_dma+0x4d8/0x534 [<110bc94c>] usb_hcd_submit_urb+0x82c/0x834 [<02eb5baf>] usb_sg_wait+0x14c/0x1a0 [] usb_stor_bulk_transfer_sglist.part.1+0xac/0x124 [<87a5c34c>] usb_stor_bulk_srb+0x40/0x60 [] usb_stor_Bulk_transport+0x160/0x37c [] usb_stor_invoke_transport+0x3c/0x500 [<004754f4>] usb_stor_control_thread+0x258/0x28c [<22edf42e>] kthread+0x134/0x13c [] ret_from_kernel_thread+0x14/0x1c ---[ end trace bcdb825805eefdcc ]--- Signed-off-by: Fredrik Noring Acked-by: Alan Stern Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-hcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -446,7 +446,8 @@ static int ohci_init (struct ohci_hcd *o struct usb_hcd *hcd = ohci_to_hcd(ohci); /* Accept arbitrarily long scatter-gather lists */ - hcd->self.sg_tablesize = ~0; + if (!(hcd->driver->flags & HCD_LOCAL_MEM)) + hcd->self.sg_tablesize = ~0; if (distrust_firmware) ohci->flags |= OHCI_QUIRK_HUB_POWER;