lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 13 Apr 2023 19:12:07 +0800
From:   Zheng Hacker <hackerzheng666@...il.com>
To:     Yongqin Liu <yongqin.liu@...aro.org>
Cc:     John Stultz <jstultz@...gle.com>, Zheng Wang <zyytlz.wz@....com>,
        Sumit Semwal <sumit.semwal@...aro.org>, arnd@...db.de,
        gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
        1395428693sheep@...il.com, alex000young@...il.com,
        Mauro Carvalho Chehab <mchehab@...nel.org>
Subject: Re: [PATCH] misc: hisi_hikey_usb: Fix use after free bug in
 hisi_hikey_usb_remove due to race condition

Yongqin Liu <yongqin.liu@...aro.org> 于2023年4月13日周四 18:55写道:
>
> Hi, Zheng
>
> On Thu, 13 Apr 2023 at 16:08, Zheng Hacker <hackerzheng666@...il.com> 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.

In practice, you can just use rmmod command to simulate the unplug
movement, which will also trigger the hisi_hikey_usb_remove if there
is a real USB device.

If there's some other help I can provide, please feel free to let me know.

Thanks again for your effort.

Best regards,
Zheng

[1] https://www.usenix.org/conference/usenixsecurity21/presentation/lee-yoochan

> Thanks,
> Yongqin Liu
> > Zheng Hacker <hackerzheng666@...il.com> 于2023年3月14日周二 09:01写道:
> > >
> > > John Stultz <jstultz@...gle.com> 于2023年3月14日周二 03:57写道:
> > > >
> > > > On Sun, Mar 12, 2023 at 7:53 AM Zheng Wang <zyytlz.wz@....com> wrote:
> > > > >
> > > > > In hisi_hikey_usb_probe, it called hisi_hikey_usb_of_role_switch
> > > > > and bound &hisi_hikey_usb->work with relay_set_role_switch.
> > > > > When it calls hub_usb_role_switch_set, it will finally call
> > > > > schedule_work to start the work.
> > > > >
> > > > > When we call hisi_hikey_usb_remove to remove the driver, there
> > > > > may be a sequence as follows:
> > > > >
> > > > > Fix it by finishing the work before cleanup in hisi_hikey_usb_remove.
> > > > >
> > > > > CPU0                  CPU1
> > > > >
> > > > >                     |relay_set_role_switch
> > > > > hisi_hikey_usb_remove|
> > > > >   usb_role_switch_put|
> > > > >     usb_role_switch_release  |
> > > > >      kfree(sw)     |
> > > > >                     | usb_role_switch_set_role
> > > > >                     |   //use
> > > > >
> > > > > Fixes: 7a6ff4c4cbc3 ("misc: hisi_hikey_usb: Driver to support onboard USB gpio hub on Hikey960")
> > > > > Signed-off-by: Zheng Wang <zyytlz.wz@....com>
> > > > > ---
> > > > >  drivers/misc/hisi_hikey_usb.c | 1 +
> > > > >  1 file changed, 1 insertion(+)
> > > > >
> > > > > diff --git a/drivers/misc/hisi_hikey_usb.c b/drivers/misc/hisi_hikey_usb.c
> > > > > index 2165ec35a343..26fc895c4418 100644
> > > > > --- a/drivers/misc/hisi_hikey_usb.c
> > > > > +++ b/drivers/misc/hisi_hikey_usb.c
> > > > > @@ -242,6 +242,7 @@ static int hisi_hikey_usb_probe(struct platform_device *pdev)
> > > > >  static int  hisi_hikey_usb_remove(struct platform_device *pdev)
> > > > >  {
> > > > >         struct hisi_hikey_usb *hisi_hikey_usb = platform_get_drvdata(pdev);
> > > > > +       cancel_work_sync(&hisi_hikey_usb->work);
> > > > >
> > > > >         if (hisi_hikey_usb->hub_role_sw) {
> > > > >                 usb_role_switch_unregister(hisi_hikey_usb->hub_role_sw);
> > > >
> > > > Looks sane to me.
> > > > Pulling in Sumit and YongQin as they have hardware and can test with it.
> > > >
> > > Hi John,
> > >
> > > Thanks for your reply. Thank Sumit and YongQin for being willing to
> > > test the solution with their hardware.
> > >
> > > Best regards,
> > > Zheng
>
>
>
> --
> Best Regards,
> Yongqin Liu
> ---------------------------------------------------------------
> #mailing list
> linaro-android@...ts.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-android

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ