linux/drivers/spmi
Yu-Che Cheng f8dcafcb54 spmi: mediatek: Fix UAF on device remove
[ Upstream commit e821d50ab5 ]

The pmif driver data that contains the clocks is allocated along with
spmi_controller.
On device remove, spmi_controller will be freed first, and then devres
, including the clocks, will be cleanup.
This leads to UAF because putting the clocks will access the clocks in
the pmif driver data, which is already freed along with spmi_controller.

This can be reproduced by enabling DEBUG_TEST_DRIVER_REMOVE and
building the kernel with KASAN.

Fix the UAF issue by using unmanaged clk_bulk_get() and putting the
clocks before freeing spmi_controller.

Reported-by: Fei Shao <fshao@chromium.org>
Signed-off-by: Yu-Che Cheng <giver@chromium.org>
Link: https://lore.kernel.org/r/20230717173934.1.If004a6e055a189c7f2d0724fa814422c26789839@changeid
Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20231206231733.4031901-3-sboyd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:32 +00:00
..
hisi-spmi-controller.c spmi: hisi-spmi-controller: Convert to platform remove callback returning void 2023-04-20 14:16:39 +02:00
Kconfig spmi: mediatek: Add support for MT6873/8192 2021-12-17 17:18:18 +01:00
Makefile spmi: mediatek: Add support for MT6873/8192 2021-12-17 17:18:18 +01:00
spmi-mtk-pmif.c spmi: mediatek: Fix UAF on device remove 2024-02-05 20:14:32 +00:00
spmi-pmic-arb.c spmi: fix W=1 kernel-doc warnings 2023-04-20 14:16:39 +02:00
spmi.c spmi: Add a check for remove callback when removing a SPMI driver 2023-04-20 14:16:39 +02:00