anolis-cloud-kernel/drivers/power
Zheng Wang a2c23773c1 power: supply: da9150: Fix use after free bug in da9150_charger_remove due to race condition
ANBZ: #4782

commit 06615d11cc upstream.

In da9150_charger_probe, &charger->otg_work is bound with
da9150_charger_otg_work. da9150_charger_otg_ncb may be
called to start the work.

If we remove the module which will call da9150_charger_remove
to make cleanup, there may be a unfinished work. The possible
sequence is as follows:

Fix it by canceling the work before cleanup in the da9150_charger_remove

CPU0                  CPUc1

                    |da9150_charger_otg_work
da9150_charger_remove      |
power_supply_unregister  |
device_unregister   |
power_supply_dev_release|
kfree(psy)          |
                    |
                    | 	power_supply_changed(charger->usb);
                    |   //use

Fixes: c1a281e34d ("power: Add support for DA9150 Charger")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

Fixes: CVE-2023-30772
Signed-off-by: Xiao Long <xiaolong@openanolis.org>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/1576
2023-07-04 03:18:42 +00:00
..
avs PM / AVS: SmartReflex: NULL check before some freeing functions is not needed 2019-12-05 09:20:02 +01:00
reset power: reset: at91-poweroff: do not procede if at91_shdwc is allocated 2019-11-20 18:46:46 +01:00
supply power: supply: da9150: Fix use after free bug in da9150_charger_remove due to race condition 2023-07-04 03:18:42 +00:00
Kconfig power: move power supply drivers to power/supply 2016-08-11 01:11:03 +02:00
Makefile power: move power supply drivers to power/supply 2016-08-11 01:11:03 +02:00