linux-stable/drivers/spmi
Yu-Che Cheng 9a3881b1f0 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:17:04 +00:00
..
Kconfig
Makefile
hisi-spmi-controller.c spmi: hisi-spmi-controller: Convert to platform remove callback returning void 2023-04-20 14:16:39 +02:00
spmi-mtk-pmif.c spmi: mediatek: Fix UAF on device remove 2024-02-05 20:17:04 +00:00
spmi-pmic-arb.c spmi: fix W=1 kernel-doc warnings 2023-04-20 14:16:39 +02:00
spmi.c spmi: rename spmi device lookup helper 2023-11-01 10:02:18 +00:00