Re: [PATCH 1/3] platform/x86: dell-laptop: Reject keyboard backlight timeouts that overflow
From: Pali Rohár
Date: Fri Nov 20 2026 - 08:20:27 EST
On Friday 13 November 2026 22:29:25 Rosen Penev wrote:
> kbd_led_timeout_store() converts a timeout that is too large for its
> unit to seconds with plain int multiplication. A large enough value
> wraps, and if the wrapped number happens to be a valid timeout it is
> accepted. On a Precision M4800, writing "4424214d" (over 12000 years)
> to stop_timeout sets the timeout to 4 minutes, and "18989323d" sets it
> to 2 minutes.
>
> Convert with check_mul_overflow() and return -EINVAL on overflow.
>
> Fixes: 02b2aaaa57ab ("platform: x86: dell-laptop: Add support for keyboard backlight")
> Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> ---
> drivers/platform/x86/dell/dell-laptop.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
> index 89e85c7f7132..bee347e1d60c 100644
> --- a/drivers/platform/x86/dell/dell-laptop.c
> +++ b/drivers/platform/x86/dell/dell-laptop.c
> @@ -25,6 +25,7 @@
> #include <linux/sysfs.h>
> #include <linux/acpi.h>
> #include <linux/mm.h>
> +#include <linux/overflow.h>
> #include <linux/i8042.h>
> #include <linux/debugfs.h>
> #include <linux/seq_file.h>
> @@ -1554,6 +1555,7 @@ static ssize_t kbd_led_timeout_store(struct device *dev,
> struct kbd_state state;
> bool convert;
> int value;
> + int mult;
> int ret;
> char ch;
> u8 unit;
> @@ -1602,16 +1604,23 @@ static ssize_t kbd_led_timeout_store(struct device *dev,
> /* Convert value from current units to seconds */
> switch (unit) {
> case KBD_TIMEOUT_DAYS:
> - value *= 24;
> - fallthrough;
> + mult = 24 * 60 * 60;
> + break;
> case KBD_TIMEOUT_HOURS:
> - value *= 60;
> - fallthrough;
> + mult = 60 * 60;
> + break;
> case KBD_TIMEOUT_MINUTES:
> - value *= 60;
> - unit = KBD_TIMEOUT_SECONDS;
> + mult = 60;
> + break;
> + default:
> + mult = 1;
> + break;
> }
>
> + if (check_mul_overflow(value, mult, &value))
> + return -EINVAL;
> + unit = KBD_TIMEOUT_SECONDS;
> +
> if (quirks && quirks->needs_kbd_timeouts) {
> for (i = 0; quirks->kbd_timeouts[i] != -1; i++) {
> if (value <= quirks->kbd_timeouts[i]) {
> --
> 2.56.0
>
This change does not work correctly. The code below the quoted change is
then dividing the value by (60 * 60 * 24) again (after being multiplied
above). So the newly adding check_mul_overflow() will reject valid
inputs, just because they do not fit into the "value" variable.