All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: rt5759: fix OOB in validate_desc()
@ 2022-11-16  9:29 Yang Yingliang
  2022-11-16 13:14 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-11-16  9:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: broonie, lgirdwood

I got the following OOB report:

 BUG: KASAN: slab-out-of-bounds in validate_desc+0xba/0x109
 Read of size 8 at addr ffff888107db8ff0 by task python3/253
 Call Trace:
  <TASK>
  dump_stack_lvl+0x67/0x83
  print_report+0x178/0x4b0
  kasan_report+0x90/0x190
  validate_desc+0xba/0x109
  gpiod_set_value_cansleep+0x40/0x5a
  regulator_ena_gpio_ctrl+0x93/0xfc
  _regulator_do_enable.cold.61+0x89/0x163
  set_machine_constraints+0x140a/0x159c
  regulator_register.cold.73+0x762/0x10cd
  devm_regulator_register+0x57/0xb0
  rt5759_probe+0x3a0/0x4ac [rt5759_regulator]

The desc used in validate_desc() is passed from 'reg_cfg.ena_gpiod',
which is not initialized. Fix this by initializing 'reg_cfg' to 0.

Fixes: 7b36ddb208bd ("regulator: rt5759: Add support for Richtek RT5759 DCDC converter")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/regulator/rt5759-regulator.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/rt5759-regulator.c b/drivers/regulator/rt5759-regulator.c
index 6b96899eb27e..8488417f4b2c 100644
--- a/drivers/regulator/rt5759-regulator.c
+++ b/drivers/regulator/rt5759-regulator.c
@@ -243,6 +243,7 @@ static int rt5759_regulator_register(struct rt5759_priv *priv)
 	if (priv->chip_type == CHIP_TYPE_RT5759A)
 		reg_desc->uV_step = RT5759A_STEP_UV;
 
+	memset(&reg_cfg, 0, sizeof(reg_cfg));
 	reg_cfg.dev = priv->dev;
 	reg_cfg.of_node = np;
 	reg_cfg.init_data = of_get_regulator_init_data(priv->dev, np, reg_desc);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: rt5759: fix OOB in validate_desc()
  2022-11-16  9:29 [PATCH] regulator: rt5759: fix OOB in validate_desc() Yang Yingliang
@ 2022-11-16 13:14 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2022-11-16 13:14 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel; +Cc: lgirdwood

On Wed, 16 Nov 2022 17:29:43 +0800, Yang Yingliang wrote:
> I got the following OOB report:
> 
>  BUG: KASAN: slab-out-of-bounds in validate_desc+0xba/0x109
>  Read of size 8 at addr ffff888107db8ff0 by task python3/253
>  Call Trace:
>   <TASK>
>   dump_stack_lvl+0x67/0x83
>   print_report+0x178/0x4b0
>   kasan_report+0x90/0x190
>   validate_desc+0xba/0x109
>   gpiod_set_value_cansleep+0x40/0x5a
>   regulator_ena_gpio_ctrl+0x93/0xfc
>   _regulator_do_enable.cold.61+0x89/0x163
>   set_machine_constraints+0x140a/0x159c
>   regulator_register.cold.73+0x762/0x10cd
>   devm_regulator_register+0x57/0xb0
>   rt5759_probe+0x3a0/0x4ac [rt5759_regulator]
> 
> [...]

Applied to

   broonie/regulator.git for-next

Thanks!

[1/1] regulator: rt5759: fix OOB in validate_desc()
      commit: 7920e0fbced429ab18ad4402e3914146a6a0921b

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-16 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16  9:29 [PATCH] regulator: rt5759: fix OOB in validate_desc() Yang Yingliang
2022-11-16 13:14 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.