From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,URIBL_DBL_ABUSE_MALW, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43D27C2D0DB for ; Fri, 31 Jan 2020 14:48:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 193E2206D5 for ; Fri, 31 Jan 2020 14:48:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uYVthB0Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 193E2206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=O86akHI4NXMoouTuL9288O+9y9WsLlAAacjuyR6Yrok=; b=uYVthB0YPffcHvbvxvzQ9TZlh XW1/Jp3lERhQ8whEoS9Zor2VzZAJpmGdnrAXEkRhD2LOkWM98CZ4tyAUwaI28KWj0R8+0y3QtkGA/ in/w+1HvqAaM9ryrjROEtPUe7wwNYUobc85ZZx8sPEQwbY93lk7MdiwSiUtywVidG3TmS2WY3dyFQ XNeBD/NGWKIqOXu4EdQ5bJZrDab+fAHdzWuohK/9MGm1E/7D0zg439FRXjS9sc2LRTGOKPhn4DC2i t4OX7oMAmcCqgVuVgFc4qCzVyX9L+GqTZWmIs03b03WdiNdgHR4DHnODlCfc4wWGbD4XUUGq55PSc ozaThLO5Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixXaY-0002Me-Ql; Fri, 31 Jan 2020 14:48:06 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixXaV-0002Kc-JE; Fri, 31 Jan 2020 14:48:05 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2020 06:48:00 -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 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-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200131_064803_645033_AC49B3D5 X-CRM114-Status: GOOD ( 21.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sriharsha Allenki , Mediatek WSD Upstream Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel