anolis-cloud-kernel/drivers/power
Zheng Wang 1ae191bb45 power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition
ANBZ: #5366

commit 47c29d6921 upstream.

[ Upstream commit 47c29d6921 ]

In bq24190_probe, &bdi->input_current_limit_work is bound
with bq24190_input_current_limit_work. When external power
changed, it will call bq24190_charger_external_power_changed
 to start the work.

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

CPU0                  CPUc1

                    |bq24190_input_current_limit_work
bq24190_remove      |
power_supply_unregister  |
device_unregister   |
power_supply_dev_release|
kfree(psy)          |
                    |
                    | power_supply_get_property_from_supplier
                    |   //use

Fix it by finishing the work before cleanup in the bq24190_remove

Fixes: 9777467257 ("power_supply: Initialize changed_work before calling device_add")
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 conflicts]
Fixes: CVE-2023-33288
Signed-off-by: Qiao Ma <mqaio@linux.alibaba.com>
Signed-off-by: Xiao Long <xiaolong@openanolis.org>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/1789
2023-06-27 06:47:07 +00:00
..
reset power/reset: arm-versatile: Fix refcount leak in versatile_reboot_probe 2022-07-29 17:19:10 +02:00
supply power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition 2023-06-27 06:47:07 +00:00
Kconfig PM: AVS: Drop the avs directory and the corresponding Kconfig 2020-10-22 18:39:32 +02:00
Makefile PM: AVS: Drop the avs directory and the corresponding Kconfig 2020-10-22 18:39:32 +02:00