regulator: core: Fix slab-out-of-bounds in regulator_unlock_recursive()
authorDmitry Osipenko <digetx@gmail.com>
Mon, 31 Aug 2020 20:43:35 +0000 (23:43 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Sep 2020 11:47:52 +0000 (13:47 +0200)
commita467624aef02df2a8d7d6dc7b0b3625c8133b6b0
tree88ba81e4665c7726558ca1fa27737a7877c30f12
parentdfbb9cea5a4b07f6a5445d2f821041aae50b7632
regulator: core: Fix slab-out-of-bounds in regulator_unlock_recursive()

commit 0a7416f94707c60b9f66b01c0a505b7e41375f3a upstream.

The recent commit 7d8196641ee1 ("regulator: Remove pointer table
overallocation") changed the size of coupled_rdevs and now KASAN is able
to detect slab-out-of-bounds problem in regulator_unlock_recursive(),
which is a legit problem caused by a typo in the code. The recursive
unlock function uses n_coupled value of a parent regulator for unlocking
supply regulator, while supply's n_coupled should be used. In practice
problem may only affect platforms that use coupled regulators.

Cc: stable@vger.kernel.org # 5.0+
Fixes: f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking")
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20200831204335.19489-1-digetx@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/regulator/core.c