Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2987747ybl; Sun, 2 Feb 2020 11:30:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyZFdp2P6KAVXs5i3MVgMClwt3C6ECFWf25wWavkl/9ogLO5rauEUvs0CM5XhTVXMrj9rkX X-Received: by 2002:aca:b483:: with SMTP id d125mr13042734oif.167.1580671827558; Sun, 02 Feb 2020 11:30:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580671827; cv=none; d=google.com; s=arc-20160816; b=bGo0EEVTOoWNtxviYPm8uqOoFPRePWqxjXyZli/701x1IN43DQt6Aytv1JZLhqGB7v 1UV1Ul0gU97fhPzv/Nvo3M0tZY+bFwI3XoFBe9Bvz5KkIuqbmwtNQKe1cX+BfeLlSeWD Ib/UuGlhy2rC0m1LOQKbqthf8pUxbW7j0O/jgEpzX38++WzeMSlws62D2EHFhM+A2zFZ 2yplgXXIFF6T7p2ywsbHBKW8ACJb3wBEYqZ8OxqFNwwFBvQD8S3s/NhCfeG+Tb8Usxrb 9MLz0QC2tBCgXxV6oxbWNrx6W7yhG6bMiH1c3/RiB8w5nVDoXSfSNpvcnWasOVFrY6+p INgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=83XBXAdF60qQhjfbLi9bwa5VGB/pa56aRpXZec7GZUQ=; b=KagLB0Wtn1wAw9IIYuMYFArwrf4jarSfYmYZPRc09MEm5Y/tHVdaeFomzYdAcWHe2T 8FyiA5B6RJuzellBa/RPz8ZLIGATUG1c0NFqNQwyseqwrn7xVglvDvzIddmas/aLEed4 5XoYIcgRNz9H7OWQgav+4F8VASaPFbJvsQSnI8KWJLKy0Gt/sLYCzdsT82jHJbRkwMuC mswKEPP6yvCeM8blziPHmH1tMmzfdYebY/tIizN2ZUkeLyc/tRq+tO9MqIvv2PPdxhVv 94N7lGpEeigSbiGpr1DlEjyDQPdZE0bWu6EzZwpapodgGn4eguoQXxEIZy2gqe0Y7B+b 5+ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=phTQ09+j; 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 a20si7790008otf.271.2020.02.02.11.30.13; Sun, 02 Feb 2020 11:30:27 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=phTQ09+j; 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 S1726943AbgBBT3P (ORCPT + 99 others); Sun, 2 Feb 2020 14:29:15 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38222 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726290AbgBBT3O (ORCPT ); Sun, 2 Feb 2020 14:29:14 -0500 Received: by mail-pg1-f193.google.com with SMTP id a33so6600961pgm.5; Sun, 02 Feb 2020 11:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=83XBXAdF60qQhjfbLi9bwa5VGB/pa56aRpXZec7GZUQ=; b=phTQ09+j8Vr2PTCfUXpoYipZuNKH07aPv2Zc4kKmqWltkBWIFf9lbdsKaJi04tqGKB 89O9EaYkOjA51Y7sM+LHx35FD96pzQrI8ycxQF5cEY/yC1ssICLlZEQUycHoZWIVUWt2 q16FVK+zhYaWdLk8XAHU1LN0lvwpKUL99e4YsRBtm7+KfvKJwYQvUyk+CtcydCMaq+ET 221+uh0dgiGXI2gstojGhDXQ1o8QOETUOOtvRTfRA68FI1vzrH0FMON1RKItRVa6CRuq g8b3vyU06z53cNAR6K9+60lftqNVoGeOuyjvd2bJRGZh6EoIfJa1jV/TIfNInWanSkyq RaVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=83XBXAdF60qQhjfbLi9bwa5VGB/pa56aRpXZec7GZUQ=; b=VN8H8mCN2nmRVpbvUQ1jbu9U5uQDwy8dP6fwvMAMeAKOHWyxQE000z3BAmfxISjkF2 1l5ci0nmLwrhnKJmjaGCVJHzxQfFqHKYIuuIE4d4kHGx5W/EdgprH34JdKuANGQVKTJf 3RaMHW+bg8gU7EXOR1ciT9vXFIBQ8JIky8mm5CCvUYOzyH8HMk4DY3qqnqOfu9MAA74m 5ddu6PqJmmdfMxipSHcw7W72GA693MqMxZ49n9rak8xYEWvuWa3otYvjQ6Fk18AJWDcG T/4j0jKfc5+tQnt7qMSmrIq3qd76u9mHknroHOzrgDapaPiwi5VArSjPH8UvE1+lcvb7 3oKg== X-Gm-Message-State: APjAAAXIYN+rIn9rYVJ+yBqCkllJuwprJWOO/UYQ6H4LTLQxKJrozHfK aWmhrFDa6SJv74qkUlAFZhQWiFnG X-Received: by 2002:a63:8dc4:: with SMTP id z187mr5569042pgd.68.1580671754231; Sun, 02 Feb 2020 11:29:14 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b4sm17987390pfd.18.2020.02.02.11.29.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Feb 2020 11:29:13 -0800 (PST) Date: Sun, 2 Feb 2020 11:29:12 -0800 From: Guenter Roeck To: Macpaul Lin Cc: 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 , Mediatek WSD Upstream , Sriharsha Allenki Subject: Re: [PATCH] xhci-mtk: Fix NULL pointer dereference with xhci_irq() for shared_hcd Message-ID: <20200202192912.GA20763@roeck-us.net> References: <1579246910-22736-1-git-send-email-macpaul.lin@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1579246910-22736-1-git-send-email-macpaul.lin@mediatek.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 17, 2020 at 03:41:50PM +0800, 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; I may be wrong, but I have some concerns that this replaces the NULL pointer access with a UAF. Guenter > usb_put_hcd(hcd); > xhci_mtk_sch_exit(mtk); > xhci_mtk_clks_disable(mtk); > -- > 2.18.0