* [PATCH 0/2] leds: lp50xx: Fix component index and count validation
@ 2026-11-27 13:43 Tobias Johansson
2026-11-27 13:43 ` [PATCH 1/2] leds: lp50xx: Use an unsigned component index Tobias Johansson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tobias Johansson @ 2026-11-27 13:43 UTC (permalink / raw)
To: Lee Jones, Pavel Machek, Jacek Anaszewski, Johan Adolfsson,
Dan Murphy
Cc: linux-leds, linux-kernel, Pavel Machek, kernel, Tobias Johansson,
Sashiko
This series fixes two pre-existing bounds-check issues identified during
review of the default-intensity patch:
https://lore.kernel.org/r/20261109-b4-leds-lp50xx-default-intensity-v1-1-0a04a3533df6@axis.com
The first patch makes the component index unsigned so that firmware reg
values with the high bit set cannot bypass the upper-bound check.
The second patch rejects more than three component child nodes, preventing
num_colors from exceeding the allocation used by the brightness and
multicolor sysfs paths even when component reg values are repeated.
Both issues require malformed firmware descriptions. The fixes are kept
separate from the default-intensity feature and do not depend on it.
Each patch includes a Fixes tag for independent backporting.
---
Tobias Johansson (2):
leds: lp50xx: Use an unsigned component index
leds: lp50xx: Reject excessive component counts
drivers/leds/leds-lp50xx.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
base-commit: 05b4738b0078f7d6f154f68068a11c8a0635e9df
change-id: 20261119-leds-lp50xx-bounds-fixes-b40666d382f6
Best regards,
--
Tobias Johansson <tobias.johansson@axis.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] leds: lp50xx: Use an unsigned component index
2026-11-27 13:43 [PATCH 0/2] leds: lp50xx: Fix component index and count validation Tobias Johansson
@ 2026-11-27 13:43 ` Tobias Johansson
2026-11-27 13:43 ` [PATCH 2/2] leds: lp50xx: Reject excessive component counts Tobias Johansson
2026-11-27 13:51 ` [PATCH 0/2] leds: lp50xx: Fix component index and count validation sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: Tobias Johansson @ 2026-11-27 13:43 UTC (permalink / raw)
To: Lee Jones, Pavel Machek, Jacek Anaszewski, Johan Adolfsson,
Dan Murphy
Cc: linux-leds, linux-kernel, Pavel Machek, kernel, Tobias Johansson
The component reg property is read from a firmware node as a u32, but
multi_index is an int. A malformed firmware description with the high
bit set is interpreted as negative and passes the upper-bound check
against LP50XX_LEDS_PER_MODULE. Using such an index then writes out of
bounds at a negative offset from mc_led_info during probe.
Declare multi_index as u32 to match the property reader and ensure that
the existing bounds check rejects all values outside the allocation.
Update the diagnostic format specifier accordingly.
Reported-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/all/179442102947.44545.9103121805533352120@kernel.org/
Fixes: 2e84a5e53742 ("leds: leds-lp50xx: Handle reg to get correct multi_index")
Signed-off-by: Tobias Johansson <tobias.johansson@axis.com>
---
drivers/leds/leds-lp50xx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
index 20bfb315bda1..4d4ad0db96af 100644
--- a/drivers/leds/leds-lp50xx.c
+++ b/drivers/leds/leds-lp50xx.c
@@ -506,7 +506,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
return -ENOMEM;
fwnode_for_each_child_node(child, led_node) {
- int multi_index;
+ u32 multi_index;
ret = fwnode_property_read_u32(led_node, "color",
&color_id);
if (ret) {
@@ -519,7 +519,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
dev_err(priv->dev, "reg must be set\n");
return -EINVAL;
} else if (multi_index >= LP50XX_LEDS_PER_MODULE) {
- dev_err(priv->dev, "reg %i out of range\n", multi_index);
+ dev_err(priv->dev, "reg %u out of range\n", multi_index);
return -EINVAL;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] leds: lp50xx: Reject excessive component counts
2026-11-27 13:43 [PATCH 0/2] leds: lp50xx: Fix component index and count validation Tobias Johansson
2026-11-27 13:43 ` [PATCH 1/2] leds: lp50xx: Use an unsigned component index Tobias Johansson
@ 2026-11-27 13:43 ` Tobias Johansson
2026-11-27 13:51 ` [PATCH 0/2] leds: lp50xx: Fix component index and count validation sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: Tobias Johansson @ 2026-11-27 13:43 UTC (permalink / raw)
To: Lee Jones, Pavel Machek, Jacek Anaszewski, Johan Adolfsson,
Dan Murphy
Cc: linux-leds, linux-kernel, Pavel Machek, kernel, Sashiko,
Tobias Johansson
Each multicolor LED has storage for LP50XX_LEDS_PER_MODULE components,
but num_colors is incremented for every component child node. More than
three children with repeated valid reg values therefore produce a count
larger than the subled_info allocation.
The brightness and multicolor sysfs paths trust this count, resulting in
out-of-bounds reads and writes.
Reject firmware nodes containing more components than the allocation can
hold before parsing them. This bounds num_colors without changing the
handling of configurations with up to three components.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/all/sashiko-outbox-204991@kernel.org/
Fixes: 242b81170fb8 ("leds: lp50xx: Add the LP50XX family of the RGB LED driver")
Signed-off-by: Tobias Johansson <tobias.johansson@axis.com>
---
drivers/leds/leds-lp50xx.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
index 4d4ad0db96af..4da78e6ad0aa 100644
--- a/drivers/leds/leds-lp50xx.c
+++ b/drivers/leds/leds-lp50xx.c
@@ -496,6 +496,11 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
init_data.fwnode = child;
num_colors = 0;
+ if (fwnode_get_child_node_count(child) > LP50XX_LEDS_PER_MODULE) {
+ dev_err(priv->dev, "Too many sub-LEDs\n");
+ return -EINVAL;
+ }
+
/*
* There are only 3 LEDs per module otherwise they should be
* banked which also is presented as 3 LEDs.
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] leds: lp50xx: Fix component index and count validation
2026-11-27 13:43 [PATCH 0/2] leds: lp50xx: Fix component index and count validation Tobias Johansson
2026-11-27 13:43 ` [PATCH 1/2] leds: lp50xx: Use an unsigned component index Tobias Johansson
2026-11-27 13:43 ` [PATCH 2/2] leds: lp50xx: Reject excessive component counts Tobias Johansson
@ 2026-11-27 13:51 ` sashiko-bot
2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-27 13:51 UTC (permalink / raw)
To: Tobias Johansson; +Cc: linux-leds, lee
Sashiko has reviewed this 2-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-leds-lp50xx-bounds-fixes-v1-0-b9f0399d747e@axis.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-27 13:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 13:43 [PATCH 0/2] leds: lp50xx: Fix component index and count validation Tobias Johansson
2026-11-27 13:43 ` [PATCH 1/2] leds: lp50xx: Use an unsigned component index Tobias Johansson
2026-11-27 13:43 ` [PATCH 2/2] leds: lp50xx: Reject excessive component counts Tobias Johansson
2026-11-27 13:51 ` [PATCH 0/2] leds: lp50xx: Fix component index and count validation sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox