[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dd329b51-f11a-2af6-9549-c8a014fd5a71@samsung.com>
Date: Tue, 13 Dec 2022 12:32:58 +0100
From: Marek Szyprowski <m.szyprowski@...sung.com>
To: cy_huang <u0084500@...il.com>, broonie@...nel.org
Cc: djrscally@...il.com, hdegoede@...hat.com, markgross@...nel.org,
lgirdwood@...il.com, mcoquelin.stm32@...il.com,
alexandre.torgue@...s.st.com, yangyingliang@...wei.com,
gene_chen@...htek.com, chiaen_wu@...htek.com,
platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
ChiYuan Huang <cy_huang@...htek.com>
Subject: Re: [PATCH v2] regulator: core: Use different devices for resource
allocation and DT lookup
Dear All,
On 06.12.2022 08:22, cy_huang wrote:
> From: ChiYuan Huang <cy_huang@...htek.com>
>
> Following by the below discussion, there's the potential UAF issue
> between regulator and mfd.
> https://lore.kernel.org/all/20221128143601.1698148-1-yangyingliang@huawei.com/
>
> >From the analysis of Yingliang
>
> CPU A |CPU B
> mt6370_probe() |
> devm_mfd_add_devices() |
> |mt6370_regulator_probe()
> | regulator_register()
> | //allocate init_data and add it to devres
> | regulator_of_get_init_data()
> i2c_unregister_device() |
> device_del() |
> devres_release_all() |
> // init_data is freed |
> release_nodes() |
> | // using init_data causes UAF
> | regulator_register()
>
> It's common to use mfd core to create child device for the regulator.
> In order to do the DT lookup for init data, the child that registered
> the regulator would pass its parent as the parameter. And this causes
> init data resource allocated to its parent, not itself. The issue happen
> when parent device is going to release and regulator core is still doing
> some operation of init data constraint for the regulator of child device.
>
> To fix it, this patch expand 'regulator_register' API to use the
> different devices for init data allocation and DT lookup.
>
> Reported-by: Yang Yingliang <yangyingliang@...wei.com>
> Signed-off-by: ChiYuan Huang <cy_huang@...htek.com>
This patch landed in linux-next 202212 as commit 8f3cbcd6b440
("regulator: core: Use different devices for resource allocation and DT
lookup"). Unfortunately it causes serious regression on my test systems.
It looks that some supplies are not resolved correctly and then turned
off as 'unused', even if they provide power to other core regulators in
the system. I've observed this issue on Samsung Chromebook Peach-Pit and
Peach-Pi (ARM 32bit Exynos based). The symptoms are somehow similar to
the issue reported here some time ago:
https://lore.kernel.org/all/58b92e75-f373-dae7-7031-8abd465bb874@samsung.com/
I've post more information once I analyze this issue further.
> ---
> loop Yang Yingliang in cc list.
>
> Since v2
> - Fix typo 'int3742' to 'int3472' for kernel build test
>
> ---
> drivers/platform/x86/intel/int3472/clk_and_regulator.c | 3 ++-
> drivers/regulator/core.c | 8 ++++----
> drivers/regulator/devres.c | 2 +-
> drivers/regulator/of_regulator.c | 2 +-
> drivers/regulator/stm32-vrefbuf.c | 2 +-
> include/linux/regulator/driver.h | 3 ++-
> 6 files changed, 11 insertions(+), 9 deletions(-)
>
> ...
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
Powered by blists - more mailing lists