Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4306746rwe; Mon, 17 Apr 2023 10:38:12 -0700 (PDT) X-Google-Smtp-Source: AKy350bzfHkyHg4jMrzeac4j5zQgoVrxVgjV8HjJ2VL1dYyzUVB+VYL14hbYAFI1WAYpQkYGRo+m X-Received: by 2002:a05:6a20:8e19:b0:d9:6660:8746 with SMTP id y25-20020a056a208e1900b000d966608746mr21228543pzj.18.1681753091952; Mon, 17 Apr 2023 10:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681753091; cv=none; d=google.com; s=arc-20160816; b=Rb5OKUfKWCr6ZMfBBO3erVUIRCsfaJJQOMU41as8hR3j4s9ezSmQ0RR9ew7GwPlGpu nmtoEGVUwx0Q6aZnKlnjfFvEq2FXRLBdqxfKi4TMq+wD7pfNguPgUqpRBS+8TSXmvmqa Zibw+ZOYQeKYHjDQFX03fQyrW7q//0XOOYUCgkzDNREHtQ3BOasXkahX4wQxvrDKw4FW w9tD0OsvR7iJ+GNmOqpa+ELCvVACXEg5kUlfuD1R76+iLty/gN+bjJRW9cBmNOAf6Nxn jms9ORi40DcqFKwxyJ4iRMM0xZ4s5XcPKcadqzYDxYAlQYsI4jRIu4Hk+RRVsPHrdTqx NeiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8AmmSDrsQHdnhufQ9cCGYdxSLK6ckhPta0CA+BQUdMg=; b=hgcxYZAiCCUjlROV7oHPUCgEt9mXGW8gz4diIR9bv6fANmoqwG8iKyvhbt+JketF5w Hff8Uj+QVuzp6v9spcOII2wyLsaIfsmDR+STnraclBA/4AEr/3QGJjk64pyKu8Qt9wv4 fWgRrmDO3XBheuU7IWJt9VDiT7d/xn6FhAAz4en+lpLGNxyAlE4X7ye11hTJwjTKc/Lf aQnHCEKb3FbyIjXNWV4T4keC4wD37KcWakCrtIXxx6cDXsMT16xt/UpWsh0tNxeuh3+o uwZLCib5yxq0MKZpEp1kIf1jGfCG9xuO8F6UIq/YbVa9cVQmLKgCZvsktRNAKFpdB+uk mmJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vgq2uPR7; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc22-20020a656d96000000b00513965a1e60si11223126pgb.902.2023.04.17.10.38.00; Mon, 17 Apr 2023 10:38:11 -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=@linaro.org header.s=google header.b=Vgq2uPR7; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbjDQRbl (ORCPT + 99 others); Mon, 17 Apr 2023 13:31:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230254AbjDQRbj (ORCPT ); Mon, 17 Apr 2023 13:31:39 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC237902E for ; Mon, 17 Apr 2023 10:31:34 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-552fb3c2bb7so17536587b3.10 for ; Mon, 17 Apr 2023 10:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681752694; x=1684344694; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8AmmSDrsQHdnhufQ9cCGYdxSLK6ckhPta0CA+BQUdMg=; b=Vgq2uPR7sumT6O4mlILxLag5gF6XWWQWaawnnlkxvXW7T7iHpuwqV4Di5iVALdndHz J1r91xq2rJkKfhEHoxqKFApZpP/wH2CKbp+CgnRELeYurJrr/4xogi96drJePWgREzWZ 8E6a5a2Inkj2x0uRY0L5t0/lMuW7jiJtFypGCpwamd0wBz1lKHIIOMTxWT6gL6OjhOkn aD3S1It9V4xem0z0DME1ADMpd0sQLQlvyA8QQ2C5KCz8M5oSl18x9BmNeQLH7nzBzGNZ E+9RSXy6CFt989wGmJPrSl028qvmU8SzidvFxbxIPV1BZCl5yw89H+dsNvh3WuUQwqRN gE7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681752694; x=1684344694; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8AmmSDrsQHdnhufQ9cCGYdxSLK6ckhPta0CA+BQUdMg=; b=GwRRMCLnAYHVRDVSxw1zTgauptAdk8K4OfF/s33UUoVu1+RvHvlqQmQZRtOcfmQvdu kGT29TNh1lcHr6SQrX5m4fAcxRZ6xY6SSp6TBQ0ummeemYmZ2Q2wQQO7EBW6KmEhRa7j odBAvLPS2jktJNUirBheeiQcwY/4iI0UFCI4mNv3er2XQ+0fzHs/7JUKMZHFnlbF0h0T o8AnhrXuDf5WzvpZz4iAvM42RhqXaDp5BBRcIrRpGQ+BtTEq71mOwmfQFZoEmbwB2Vdq XfnScD0c8vQZ3vfPmV6IoHKOrL5uKv0azxZJD2T3xn8G11M9cgi3lCzloSDKlugBN6G+ Y59Q== X-Gm-Message-State: AAQBX9fh5+86jD+bDbDpytfSCS1qrS61U1875vQT/ljR9Q8XdszPQdZm Ufq7BhK5+9WRA18sWY8VPWT9ZXKbzd94hHCCN1BSIg== X-Received: by 2002:a81:b621:0:b0:54c:bf7:1853 with SMTP id u33-20020a81b621000000b0054c0bf71853mr10417013ywh.6.1681752694033; Mon, 17 Apr 2023 10:31:34 -0700 (PDT) MIME-Version: 1.0 References: <20230312145305.1908607-1-zyytlz.wz@163.com> <2023041308-nerd-dry-98a6@gregkh> <2023041308-unvisited-slinky-a56f@gregkh> In-Reply-To: From: Yongqin Liu Date: Tue, 18 Apr 2023 01:31:20 +0800 Message-ID: Subject: Re: [PATCH] misc: hisi_hikey_usb: Fix use after free bug in hisi_hikey_usb_remove due to race condition To: Zheng Hacker Cc: Greg KH , John Stultz , Zheng Wang , Sumit Semwal , arnd@arndb.de, linux-kernel@vger.kernel.org, 1395428693sheep@gmail.com, alex000young@gmail.com, Mauro Carvalho Chehab Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi, Zheng Sorry for the late reply. I tested this change with Android build based on the ACK android-mainline branch. The hisi_hikey_usb module could not be removed with error like this: console:/ # rmmod -f hisi_hikey_usb rmmod: failed to unload hisi_hikey_usb: Try again 1|console:/ # Sorry I am not able to reproduce any problem without this commit, but I do not see any problem with this change applied either. If there is any specific things you want to check, please feel free let me = know Thanks, Yongqin Liu On Fri, 14 Apr 2023 at 00:46, Zheng Hacker wrote= : > > Greg KH =E4=BA=8E2023=E5=B9=B44=E6=9C=8813= =E6=97=A5=E5=91=A8=E5=9B=9B 23:56=E5=86=99=E9=81=93=EF=BC=9A > > > > On Thu, Apr 13, 2023 at 11:35:17PM +0800, Zheng Hacker wrote: > > > Greg KH =E4=BA=8E2023=E5=B9=B44=E6=9C=88= 13=E6=97=A5=E5=91=A8=E5=9B=9B 20:48=E5=86=99=E9=81=93=EF=BC=9A > > > > > > > > On Thu, Apr 13, 2023 at 07:12:07PM +0800, Zheng Hacker wrote: > > > > > Yongqin Liu =E4=BA=8E2023=E5=B9=B44=E6= =9C=8813=E6=97=A5=E5=91=A8=E5=9B=9B 18:55=E5=86=99=E9=81=93=EF=BC=9A > > > > > > > > > > > > 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 p= roblem > > > > > > this change fixes? > > > > > > > > > > > > > > > > Hi Yongqin, > > > > > > > > > > Thanks for your reply. This bug is found by static analysis. Ther= e is no PoC. > > > > > > > > > > >From my personal experience, triggering race condition bugs stab= ly 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 att= acker > > > > > can physically access the device. > > > > > When he/she unplugs the usb, the remove function is triggered, an= d 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. > > No this is not a platform device on a USB device. > > > > > 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 th= e > > system? (and no, unloading the driver doesn't count, that can never > > happen on a normal machine.) > > > > Yes, I finally figured out your meaning. I know it's hard to unplug > the platform device > directly. All I want to express is that it's a theoretical method > except rmmod. I think it's better to fix the bug. But if the > developers think it's practically impossible, I think there's no need > to take further action. > > Sorry for wasting your time and thanks for your explanation. > > Best regards, > Zheng > > > thanks, > > > > greg k-h -- Best Regards, Yongqin Liu --------------------------------------------------------------- #mailing list linaro-android@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-android