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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 18 Jun 2024 22:42:16 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Michael Nazzareno Trimarchi <michael@...rulasolutions.com>
CC: Thinh Nguyen <Thinh.Nguyen@...opsys.com>, Meng Li <Meng.Li@...driver.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "quic_uaggarwa@...cinc.com" <quic_uaggarwa@...cinc.com>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "xu.yang_2@....com" <xu.yang_2@....com>
Subject: Re: [v2 PATCH] usb: dwc3: core: remove lock of otg mode during gadget
 suspend/resume to avoid deadlock

Hi,

On Wed, Jun 19, 2024, Michael Nazzareno Trimarchi wrote:
> Hi
> 
> On Tue, Jun 18, 2024 at 11:55 PM Thinh Nguyen <Thinh.Nguyen@...opsys.com> wrote:
> >
> > On Tue, Jun 18, 2024, Meng Li wrote:
> > > When config CONFIG_USB_DWC3_DUAL_ROLE is selected, and trigger system
> > > to enter suspend status with below command:
> > > echo mem > /sys/power/state
> > > There will be a deadlock issue occurring. Detailed invoking path as
> > > below:
> > > dwc3_suspend_common()
> > >     spin_lock_irqsave(&dwc->lock, flags);              <-- 1st
> > >     dwc3_gadget_suspend(dwc);
> > >         dwc3_gadget_soft_disconnect(dwc);
> > >             spin_lock_irqsave(&dwc->lock, flags);      <-- 2nd
> 
> 
> In resume path the spinlock was taken too and I see that there is a call
> dwc3_gadget_soft_connect that call the dwc3_core_soft_reset that can poll
> using msleep for time.  I don't know if this is a valid fix but seems
> does not fix
> only commit c7ebd8149ee5
> 

Meng did take the resume path into account. Can you clarify what you
meant with "does not fix only commit c7ebd8149ee5"?

Thanks,
Thinh

> 
> > > This issue is exposed by commit c7ebd8149ee5 ("usb: dwc3: gadget: Fix
> > > NULL pointer dereference in dwc3_gadget_suspend") that removes the code
> > > of checking whether dwc->gadget_driver is NULL or not. It causes the
> > > following code is executed and deadlock occurs when trying to get the
> > > spinlock. In fact, the root cause is the commit 5265397f9442("usb: dwc3:
> > > Remove DWC3 locking during gadget suspend/resume") that forgot to remove
> > > the lock of otg mode. So, remove the redundant lock of otg mode during
> > > gadget suspend/resume.
> > >
> > > Fixes: 5265397f9442 ("usb: dwc3: Remove DWC3 locking during gadget suspend/resume")
> > > Cc: Xu Yang <xu.yang_2@....com>
> > > Cc: stable@...r.kernel.org
> > > Signed-off-by: Meng Li <Meng.Li@...driver.com>
> > >
> > > ---
> > > v1->v2:
> > >  - improve commit log, correct the Fixes commit id.
> > >
> > > ---
> > >  drivers/usb/dwc3/core.c | 6 ------
> > >  1 file changed, 6 deletions(-)
> > >
> > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> > > index 7ee61a89520b..9d47c3aa5777 100644
> > > --- a/drivers/usb/dwc3/core.c
> > > +++ b/drivers/usb/dwc3/core.c
> > > @@ -2250,7 +2250,6 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc)
> > >
> > >  static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
> > >  {
> > > -     unsigned long   flags;
> > >       u32 reg;
> > >       int i;
> > >
> > > @@ -2293,9 +2292,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
> > >                       break;
> > >
> > >               if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) {
> > > -                     spin_lock_irqsave(&dwc->lock, flags);
> > >                       dwc3_gadget_suspend(dwc);
> > > -                     spin_unlock_irqrestore(&dwc->lock, flags);
> > >                       synchronize_irq(dwc->irq_gadget);
> > >               }
> > >
> > > @@ -2312,7 +2309,6 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
> > >
> > >  static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
> > >  {
> > > -     unsigned long   flags;
> > >       int             ret;
> > >       u32             reg;
> > >       int             i;
> > > @@ -2366,9 +2362,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
> > >               if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST) {
> > >                       dwc3_otg_host_init(dwc);
> > >               } else if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) {
> > > -                     spin_lock_irqsave(&dwc->lock, flags);
> > >                       dwc3_gadget_resume(dwc);
> > > -                     spin_unlock_irqrestore(&dwc->lock, flags);
> > >               }
> > >
> > >               break;
> > > --
> > > 2.34.1
> > >
> >
> > Did you use "git format-patch -v"? The $subject version prefix order is
> > different. In any case,
> >
> > Acked-by: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
> >
> > Thanks,
> > Thinh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ