Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2652223rwl; Thu, 13 Apr 2023 09:07:15 -0700 (PDT) X-Google-Smtp-Source: AKy350bPaOvfE1RnYjjsN5uOtVU97NksMznlPJHz1yBTbV30xvrIfiwZKD01Hevr9lllqT/QVQF0 X-Received: by 2002:a17:90a:b881:b0:240:d275:d61d with SMTP id o1-20020a17090ab88100b00240d275d61dmr2578773pjr.29.1681402034762; Thu, 13 Apr 2023 09:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681402034; cv=none; d=google.com; s=arc-20160816; b=Y0YniEEf/eY9ij5mFSJFKEc8hfbT7/DEkRnerNJIpdvdbfFpxtWMpgFgHSJJamC0Tn QqWmUTzn37FH4aftW/1cotqenWzsd3ElhcSL8qeaJ4iksB/ZOBBtjKcCQadUWFVl/zgQ s/6DA37UMOPT2ke/2tsdgbjSDsl65Z27DobrggvEYFsHt/Ctu4oqsnisphSmDfVUCoAI 2J17FmwUpedx6NaQSeieDjEhhBy6DIzuYQLPSMF5d1ZBV3jN9WjKzPlz3225+errLjL9 iKA3B4jCt6UWLjpomkTkoI4BpW1f2YZdqaumutcy2+zgIfe3bDkgDFD0XjR/yPHn8SF7 juRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=X7AAcEanyR1W6xLQCqRYB/QUZkJQIUsilrPVW5cyfFA=; b=CEpH/fXNgLDNxBYzssGOv/vubUV05hvV2wUKA0UrmxQVKWoGU0jhHUX1v/m2r7Cn7p i+DiaRNm5rsnxGPnuoEZkdOHqroIdg2QWrIj4wuHZKsJe3Uwn/zRJBtiykTi5S333hlK Z9oaZOkZTmt0Q8n6uHjkdlcTYpAczxc5ECl9CAMiNTQHsGK4n5to0W3UPfo9qLXsOSId O6QHuEZcZ2Q8Zt713DmLYSowHq6e3PChwJuqWdbWVUjtfykkhruDx0//v8Q5O8x2LpGb BI5650P6z8IlTdnDJbvyhGpJOaQPituyfmAeMQodpxo9J8ihDmdKfkW3VW/su0th0UUw aHiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=js+O8dI4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob3-20020a17090b390300b0023d53736026si2489631pjb.125.2023.04.13.09.06.57; Thu, 13 Apr 2023 09:07:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=js+O8dI4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbjDMP4M (ORCPT + 99 others); Thu, 13 Apr 2023 11:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjDMP4M (ORCPT ); Thu, 13 Apr 2023 11:56:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98E437EC2 for ; Thu, 13 Apr 2023 08:56:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3371A6159E for ; Thu, 13 Apr 2023 15:56:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46ABFC433EF; Thu, 13 Apr 2023 15:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1681401369; bh=ACf+iowbWo51ZjxMlapcfgzDPSEkREe6jY3O508f0Bc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=js+O8dI4chDOmFbKjiyVbkZkD8m7rJGZ1GlLmuYB05ZS/4xBPecyfzMSD0GhorrQz +BGNBOcIQNOGh3CQn8FAwy3brybHnF6iJ/OXlkVD4ZjLtTE5oKlAQ4B+KHZxLM5aQk xjKIPtVfi4HCMYcqWCzPUrkoKbWgkvQ2MI/q2/As= Date: Thu, 13 Apr 2023 17:56:06 +0200 From: Greg KH To: Zheng Hacker Cc: Yongqin Liu , John Stultz , Zheng Wang , Sumit Semwal , arnd@arndb.de, linux-kernel@vger.kernel.org, 1395428693sheep@gmail.com, alex000young@gmail.com, Mauro Carvalho Chehab Subject: Re: [PATCH] misc: hisi_hikey_usb: Fix use after free bug in hisi_hikey_usb_remove due to race condition Message-ID: <2023041308-unvisited-slinky-a56f@gregkh> References: <20230312145305.1908607-1-zyytlz.wz@163.com> <2023041308-nerd-dry-98a6@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 13, 2023 at 11:35:17PM +0800, Zheng Hacker wrote: > Greg KH 于2023年4月13日周四 20:48写道: > > > > On Thu, Apr 13, 2023 at 07:12:07PM +0800, Zheng Hacker wrote: > > > Yongqin Liu 于2023年4月13日周四 18:55写道: > > > > > > > > Hi, Zheng > > > > > > > > On Thu, 13 Apr 2023 at 16:08, Zheng Hacker wrote: > > > > > > > > > > Friendly ping about the bug. > > > > > > > > Sorry, wasn't aware of this message before, > > > > > > > > Could you please help share the instructions to reproduce the problem > > > > this change fixes? > > > > > > > > > > Hi Yongqin, > > > > > > Thanks for your reply. This bug is found by static analysis. There is no PoC. > > > > > > >From my personal experience, triggering race condition bugs stably in > > > the kernel needs some tricks. > > > For example, you can insert some sleep-time code to slow down the > > > thread until the related object is freed. > > > Besides, you can use gdb to control the time window. Also, there are > > > some other tricks as [1] said. > > > > > > As for the reproduction, this attack vector requires that the attacker > > > can physically access the device. > > > When he/she unplugs the usb, the remove function is triggered, and if > > > the set callback is invoked, there might be a race condition. > > > > How does the removal of the USB device trigger a platform device > > removal? > > Sorry I made a mistake. The USB device usually calls disconnect > callback when it's unpluged. Yes, but you are changing the platform device disconnect, not the USB device disconnect. > What I want to express here is When the driver-related device(here > it's USB GPIO Hub) was removed, the remove function is triggered. And is this a patform device on a USB device? If so, that's a bigger problem that we need to fix as that is not allowed. But in looking at the code, it does not seem to be that at all, this is just a "normal" platform device. So how can it ever be removed from the system? (and no, unloading the driver doesn't count, that can never happen on a normal machine.) thanks, greg k-h