Commit 960899af authored by Zijun Hu's avatar Zijun Hu Committed by Pu Lehui
Browse files

usb: musb: sunxi: Fix accessing an released usb phy

stable inclusion
from stable-v5.10.230
commit 6e2848d1c8c0139161e69ac0a94133e90e9988e8
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IB5AVU
CVE: CVE-2024-50269

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6e2848d1c8c0



--------------------------------

commit 498dbd9aea205db9da674994b74c7bf8e18448bd upstream.

Commit 6ed05c68 ("usb: musb: sunxi: Explicitly release USB PHY on
exit") will cause that usb phy @glue->xceiv is accessed after released.

1) register platform driver @sunxi_musb_driver
// get the usb phy @glue->xceiv
sunxi_musb_probe() -> devm_usb_get_phy().

2) register and unregister platform driver @musb_driver
musb_probe() -> sunxi_musb_init()
use the phy here
//the phy is released here
musb_remove() -> sunxi_musb_exit() -> devm_usb_put_phy()

3) register @musb_driver again
musb_probe() -> sunxi_musb_init()
use the phy here but the phy has been released at 2).
...

Fixed by reverting the commit, namely, removing devm_usb_put_phy()
from sunxi_musb_exit().

Fixes: 6ed05c68 ("usb: musb: sunxi: Explicitly release USB PHY on exit")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarZijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20241029-sunxi_fix-v1-1-9431ed2ab826@quicinc.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
parent d26629f1
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -286,8 +286,6 @@ static int sunxi_musb_exit(struct musb *musb)
	if (test_bit(SUNXI_MUSB_FL_HAS_SRAM, &glue->flags))
		sunxi_sram_release(musb->controller->parent);

	devm_usb_put_phy(glue->dev, glue->xceiv);

	return 0;
}