* [PATCH 0/8] regulator: Fix locking, OOB read, lifetime, and global state bugs (batch 2)
@ 2026-11-27 18:35 Lee Jones
2026-11-27 18:35 ` [PATCH 4/8] regulator: tps65910: Fix OOB read and bit shift in external sleep config Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Lee Jones @ 2026-11-27 18:35 UTC (permalink / raw)
To: lee
Cc: linux-kernel, André Draszik, Aaro Koskinen, Alexey Charkov,
Andreas Kemnade, Corentin Labbe, Douglas Anderson,
Eduardo Candelaria, Esteban Blanc, Graeme Gregory, Gyungoh Yoo,
Jerome Neanne, Jin Park, Kevin Hilman, Laxman Dewangan,
Liam Girdwood, linux-omap, Mal Nadar, Mark Brown,
Markus Schneider-Pargmann, Oleksij Rempel, Rajendra Nayak,
Roger Quadros, Samuel Ortiz, Stephen Warren, Tony Lindgren,
Uday Khare
These issues were reported by Sashiko.
This is batch 2 of Regulator bug fixes, based on regulator/for-next.
It addresses supply teardown and locking bugs in regulator core, slab
and global out-of-bounds reads in tps6594 and tps65910, devres lifetime
mismatches in tps6594, a NULL device_node dereference in of_regulator,
and shared global table mutations in max8907 and aat2870.
Cc: "André Draszik" <andre.draszik@linaro.org>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Alexey Charkov <alchark@flipper.net>
Cc: Andreas Kemnade <andreas@kemnade.info>
Cc: Corentin Labbe <clabbe@baylibre.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Eduardo Candelaria <jedu@slimlogic.co.uk>
Cc: Esteban Blanc <eblanc@baylibre.com>
Cc: Graeme Gregory <gg@slimlogic.co.uk>
Cc: Gyungoh Yoo <jack.yoo@maxim-ic.com>
Cc: Jerome Neanne <jneanne@baylibre.com>
Cc: Jin Park <jinyoungp@nvidia.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-omap@vger.kernel.org
Cc: Mal Nadar <m.nirmaladevi@ltts.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Markus Schneider-Pargmann <msp@baylibre.com>
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Rajendra Nayak <rnayak@ti.com>
Cc: Roger Quadros <rogerq@kernel.org>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Uday Khare <udaykhare77@gmail.com>
Lee Jones (8):
regulator: core: Defer supply cleanup and unregister event forwarding
on error
regulator: max8907: Duplicate of_regulator_match table per device
regulator: tps6594-regulator: Use dedicated handler for external
regulator IRQs
regulator: tps65910: Fix OOB read and bit shift in external sleep
config
regulator: tps6594-regulator: Bind IRQ resources to child platform
device
regulator: core: Respect is_locked when disabling supply on enable
failure
regulator: of: Guard against NULL device_node in
of_regulator_bulk_get_all()
regulator: aat2870: Duplicate regulator data per device
drivers/regulator/aat2870-regulator.c | 30 +++++++++-----
drivers/regulator/core.c | 18 ++++----
drivers/regulator/max8907-regulator.c | 57 +++++++++++---------------
drivers/regulator/of_regulator.c | 3 ++
drivers/regulator/tps65910-regulator.c | 20 +++++++--
drivers/regulator/tps6594-regulator.c | 27 +++++++++---
6 files changed, 95 insertions(+), 60 deletions(-)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 4/8] regulator: tps65910: Fix OOB read and bit shift in external sleep config
2026-11-27 18:35 [PATCH 0/8] regulator: Fix locking, OOB read, lifetime, and global state bugs (batch 2) Lee Jones
@ 2026-11-27 18:35 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-11-27 18:35 UTC (permalink / raw)
To: lee, Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Liam Girdwood, Mark Brown, Graeme Gregory,
Eduardo Candelaria, Markus Schneider-Pargmann, linux-omap,
linux-kernel
Cc: stable
tps65910_regs contains 14 regulators including VBB at index 13, whereas
tps65910_ext_sleep_control has only 13 elements. Both tps65910_probe()
and tps65910_shutdown() iterate up to pmic->num_regulators and index
pmic->ext_sleep_control[id] out of bounds for VBB.
In addition, unsupported rails such as VRTC use 0, which collides with
VMMC and LDO6 (offset 0, bit 0), and computing
(1 << pmic->ext_sleep_control[id] & 0xFF) shifts by more than 31 bits
whenever regs_offs is non-zero because << binds tighter than &.
Introduce EXT_CONTROL_REG_NONE as a distinct sentinel for rails without
external sleep control (VRTC and VBB), add BUILD_BUG_ON() array-size
checks, return early in tps65910_set_ext_sleep_config() for unsupported
rails, and use BIT(pmic->ext_sleep_control[id] & 0xFF) for bit_pos.
Fixes: 03746dcbde75 ("regulator: tps65910: Add backup battery regulator")
Closes: https://sashiko.dev/#/bug/linux-ed3bcc60-149e-497b-93aa-50138953c49a
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/regulator/tps65910-regulator.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index b99923773701..d42ffc237bf4 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -271,9 +271,10 @@ static struct tps_info tps65911_regs[] = {
},
};
+#define EXT_CONTROL_REG_NONE (~0U)
#define EXT_CONTROL_REG_BITS(id, regs_offs, bits) (((regs_offs) << 8) | (bits))
static unsigned int tps65910_ext_sleep_control[] = {
- 0,
+ EXT_CONTROL_REG_NONE,
EXT_CONTROL_REG_BITS(VIO, 1, 0),
EXT_CONTROL_REG_BITS(VDD1, 1, 1),
EXT_CONTROL_REG_BITS(VDD2, 1, 2),
@@ -286,10 +287,11 @@ static unsigned int tps65910_ext_sleep_control[] = {
EXT_CONTROL_REG_BITS(VAUX2, 0, 4),
EXT_CONTROL_REG_BITS(VAUX33, 0, 5),
EXT_CONTROL_REG_BITS(VMMC, 0, 0),
+ EXT_CONTROL_REG_NONE,
};
static unsigned int tps65911_ext_sleep_control[] = {
- 0,
+ EXT_CONTROL_REG_NONE,
EXT_CONTROL_REG_BITS(VIO, 1, 0),
EXT_CONTROL_REG_BITS(VDD1, 1, 1),
EXT_CONTROL_REG_BITS(VDD2, 1, 2),
@@ -822,10 +824,16 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
int id, int ext_sleep_config)
{
struct tps65910 *mfd = pmic->mfd;
- u8 regoffs = (pmic->ext_sleep_control[id] >> 8) & 0xFF;
- u8 bit_pos = (1 << pmic->ext_sleep_control[id] & 0xFF);
+ u8 regoffs;
+ u8 bit_pos;
int ret;
+ if (pmic->ext_sleep_control[id] == EXT_CONTROL_REG_NONE)
+ return 0;
+
+ regoffs = (pmic->ext_sleep_control[id] >> 8) & 0xFF;
+ bit_pos = BIT(pmic->ext_sleep_control[id] & 0xFF);
+
/*
* Regulator can not be control from multiple external input EN1, EN2
* and EN3 together.
@@ -1104,6 +1112,8 @@ static int tps65910_probe(struct platform_device *pdev)
switch (tps65910_chip_id(tps65910)) {
case TPS65910:
BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65910_regs));
+ BUILD_BUG_ON(ARRAY_SIZE(tps65910_regs) !=
+ ARRAY_SIZE(tps65910_ext_sleep_control));
pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
pmic->num_regulators = ARRAY_SIZE(tps65910_regs);
pmic->ext_sleep_control = tps65910_ext_sleep_control;
@@ -1117,6 +1127,8 @@ static int tps65910_probe(struct platform_device *pdev)
break;
case TPS65911:
BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65911_regs));
+ BUILD_BUG_ON(ARRAY_SIZE(tps65911_regs) !=
+ ARRAY_SIZE(tps65911_ext_sleep_control));
pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
pmic->num_regulators = ARRAY_SIZE(tps65911_regs);
pmic->ext_sleep_control = tps65911_ext_sleep_control;
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 18:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 18:35 [PATCH 0/8] regulator: Fix locking, OOB read, lifetime, and global state bugs (batch 2) Lee Jones
2026-11-27 18:35 ` [PATCH 4/8] regulator: tps65910: Fix OOB read and bit shift in external sleep config Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox