Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp717994ybl; Fri, 31 Jan 2020 06:50:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxb/Zysq+ThlAy9q/2tcsHbAR7qsIM5IIwizG1ADr0xdTk3XPQPa5bwoeLHartswoXrIx9j X-Received: by 2002:aca:4d06:: with SMTP id a6mr5679269oib.27.1580482221331; Fri, 31 Jan 2020 06:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580482221; cv=none; d=google.com; s=arc-20160816; b=yucaXCelt2r7/0/A5W4fgG08VBTPfhX5fP3BLCxG4PT/OpK0GCrX46CkPJYuVsYJN5 9w2eeOZU5wIbs41yT2IvLzZMAVJ1Kj1jJK1kwO9s8qBi3MVA4X6NDGFXtqHuV9CWLiO/ QzlCuaWeOBuC276Tu+9uhuh1ikhDp7z7J74JdHHkijMgCFNTpVRuRIQrTpH4X7drzX4g QEOlgesFB/YCtxG9yVk0ot3TbqWo5wwLwBHsa8M5TLJBJonoipdNwrxNXxmoEpm/9Unv 4PVQ22PyNp4ABeYQE4RuSphM6p1f4pwKRmBqAbCMuSP1G7HrEY04O0u8akAdxWmU73ll /veA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LRvmjjnGMRc/iuSjkuvn5oar3nJBeMYtfzuIdPRJBF8=; b=LT9QyvUOGmoeZwmRHvTrq5+9GII5cQ3cfboepKR2D25pA0X8RQJ1Xx5bhMtAVtuLGw M4TbucVZGmqMAeBO78+MHH3lftXsDSROQ+JlKwfvjQk0IfYPn/4lhtcw0ok7FFJE1TpD c9kxzpgZRnDhnmd2fyr7ySIjFq17NYwgX+mPlj2g5ymzAdo0Vf7FImuWIHhlrEp3SBSb zKLuG7P62CEf1N3CDFCVinIZayhwlRz67uueNnM29lAdp/4uPjfKxdqhyBZNE3TnTfx9 lq0SET0y+N2Y6VPk8cA45QBgrbYhkObJ8nYRe2IKRjpP3puqXb1bAnawjl+qIpbi/O9o 9/wA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si4305303oii.60.2020.01.31.06.50.09; Fri, 31 Jan 2020 06:50:21 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbgAaOsA (ORCPT + 99 others); Fri, 31 Jan 2020 09:48:00 -0500 Received: from mga06.intel.com ([134.134.136.31]:50390 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729090AbgAaOsA (ORCPT ); Fri, 31 Jan 2020 09:48:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2020 06:47:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,386,1574150400"; d="scan'208";a="310020734" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.170]) ([10.237.72.170]) by orsmga001.jf.intel.com with ESMTP; 31 Jan 2020 06:47:56 -0800 Subject: Re: [PATCH] xhci-mtk: Fix NULL pointer dereference with xhci_irq() for shared_hcd To: Macpaul Lin , Mathias Nyman , Greg Kroah-Hartman , Matthias Brugger , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Chunfeng Yun Cc: Mediatek WSD Upstream , Sriharsha Allenki References: <1579246910-22736-1-git-send-email-macpaul.lin@mediatek.com> From: Mathias Nyman Message-ID: <08f69bab-2ada-d6ab-7bf7-d960e9f148a0@linux.intel.com> Date: Fri, 31 Jan 2020 16:50:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <1579246910-22736-1-git-send-email-macpaul.lin@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17.1.2020 9.41, Macpaul Lin wrote: > According to NULL pointer fix: https://tinyurl.com/uqft5ra > xhci: Fix NULL pointer dereference with xhci_irq() for shared_hcd > The similar issue has also been found in QC activities in Mediatek. > > Here quote the description from the referenced patch as follows. > "Commit ("f068090426ea xhci: Fix leaking USB3 shared_hcd > at xhci removal") sets xhci_shared_hcd to NULL without > stopping xhci host. This results into a race condition > where shared_hcd (super speed roothub) related interrupts > are being handled with xhci_irq happens when the > xhci_plat_remove is called and shared_hcd is set to NULL. > Fix this by setting the shared_hcd to NULL only after the > controller is halted and no interrupts are generated." > > Signed-off-by: Sriharsha Allenki > Signed-off-by: Macpaul Lin > --- > drivers/usb/host/xhci-mtk.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c > index b18a6baef204..c227c67f5dc5 100644 > --- a/drivers/usb/host/xhci-mtk.c > +++ b/drivers/usb/host/xhci-mtk.c > @@ -593,11 +593,11 @@ static int xhci_mtk_remove(struct platform_device *dev) > struct usb_hcd *shared_hcd = xhci->shared_hcd; > > usb_remove_hcd(shared_hcd); > - xhci->shared_hcd = NULL; > device_init_wakeup(&dev->dev, false); > > usb_remove_hcd(hcd); > usb_put_hcd(shared_hcd); > + xhci->shared_hcd = NULL; > usb_put_hcd(hcd); > xhci_mtk_sch_exit(mtk); > xhci_mtk_clks_disable(mtk); > Could you share details of the NULL pointer dereference, (backtrace). The USB3 hcd is already removed when xhci->shared_hcd is set to NULL. We might want to add some checks to make sure we are not using the removed hcd anymore in that codepath anymore. -Mathias