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-next>] [day] [month] [year] [list]
Message-Id: <20221128063207.100596-1-duoming@zju.edu.cn>
Date:   Mon, 28 Nov 2022 14:32:07 +0800
From:   Duoming Zhou <duoming@....edu.cn>
To:     linux-kernel@...r.kernel.org
Cc:     chunfeng.yun@...iatek.com, gregkh@...uxfoundation.org,
        matthias.bgg@...il.com, linux-usb@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org,
        Duoming Zhou <duoming@....edu.cn>
Subject: [PATCH] usb: mtu3: fix sleep-in-atomic-context bug caused by usleep_range()

The function zero_autoresume() is a timer handler that runs in
atomic context. It is used to wake up the host connected to the
gadget. when used by usb mtu3, the zero_autoresume() calls
usleep_range() that can sleep. As a result, the sleep-in-atomic-
context bug will happen. The process is shown below.

    (atomic context)
zero_autoresume()
  usb_gadget_wakeup()
    mtu3_gadget_wakeup()
      usleep_range() //sleep

This patch changes usleep_range(10000, 11000) to mdelay(10)
in order to mitigate the bug.

Fixes: df2069acb005 ("usb: Add MediaTek USB3 DRD driver")
Signed-off-by: Duoming Zhou <duoming@....edu.cn>
---
 drivers/usb/mtu3/mtu3_gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
index 80236e7b089..e366c4a97d7 100644
--- a/drivers/usb/mtu3/mtu3_gadget.c
+++ b/drivers/usb/mtu3/mtu3_gadget.c
@@ -468,7 +468,7 @@ static int mtu3_gadget_wakeup(struct usb_gadget *gadget)
 	} else {
 		mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME);
 		spin_unlock_irqrestore(&mtu->lock, flags);
-		usleep_range(10000, 11000);
+		mdelay(10);
 		spin_lock_irqsave(&mtu->lock, flags);
 		mtu3_clrbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME);
 	}
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ