* [PATCH] HID: logitech-hidpp: Check bounds when deleting force-feedback effects
@ 2026-03-31 7:40 Günther Noack
2026-03-31 7:58 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Günther Noack @ 2026-03-31 7:40 UTC (permalink / raw)
To: Filipe Laíns, Bastien Nocera, Jiri Kosina,
Benjamin Tissoires
Cc: Günther Noack, Lee Jones, linux-input, linux-kernel
Without this bounds check, this might otherwise overwrite index -1.
Triggering this condition requires action both from the USB device and from
userspace, which reduces the scenarios in which it can be exploited.
Cc: Lee Jones <lee@kernel.org>
Signed-off-by: Günther Noack <gnoack@google.com>
---
drivers/hid/hid-logitech-hidpp.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index d1dea7297712..5f63f1d2303a 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -2502,12 +2502,15 @@ static void hidpp_ff_work_handler(struct work_struct *w)
}
break;
case HIDPP_FF_DESTROY_EFFECT:
- if (wd->effect_id >= 0)
- /* regular effect destroyed */
- data->effect_ids[wd->params[0]-1] = -1;
- else if (wd->effect_id >= HIDPP_FF_EFFECTID_AUTOCENTER)
- /* autocenter spring destroyed */
- data->slot_autocenter = 0;
+ slot = wd->params[0];
+ if (slot > 0 && slot <= data->num_effects) {
+ if (wd->effect_id >= 0)
+ /* regular effect destroyed */
+ data->effect_ids[slot-1] = -1;
+ else if (wd->effect_id >= HIDPP_FF_EFFECTID_AUTOCENTER)
+ /* autocenter spring destroyed */
+ data->slot_autocenter = 0;
+ }
break;
case HIDPP_FF_SET_GLOBAL_GAINS:
data->gain = (wd->params[0] << 8) + wd->params[1];
--
2.53.0.1018.g2bb0e51243-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] HID: logitech-hidpp: Check bounds when deleting force-feedback effects
2026-03-31 7:40 [PATCH] HID: logitech-hidpp: Check bounds when deleting force-feedback effects Günther Noack
@ 2026-03-31 7:58 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-03-31 7:58 UTC (permalink / raw)
To: Günther Noack
Cc: Filipe Laíns, Bastien Nocera, Jiri Kosina,
Benjamin Tissoires, linux-input, linux-kernel
On Tue, 31 Mar 2026, Günther Noack wrote:
> Without this bounds check, this might otherwise overwrite index -1.
>
> Triggering this condition requires action both from the USB device and from
> userspace, which reduces the scenarios in which it can be exploited.
>
> Cc: Lee Jones <lee@kernel.org>
> Signed-off-by: Günther Noack <gnoack@google.com>
> ---
> drivers/hid/hid-logitech-hidpp.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index d1dea7297712..5f63f1d2303a 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -2502,12 +2502,15 @@ static void hidpp_ff_work_handler(struct work_struct *w)
> }
> break;
> case HIDPP_FF_DESTROY_EFFECT:
> - if (wd->effect_id >= 0)
> - /* regular effect destroyed */
> - data->effect_ids[wd->params[0]-1] = -1;
> - else if (wd->effect_id >= HIDPP_FF_EFFECTID_AUTOCENTER)
> - /* autocenter spring destroyed */
> - data->slot_autocenter = 0;
> + slot = wd->params[0];
> + if (slot > 0 && slot <= data->num_effects) {
> + if (wd->effect_id >= 0)
> + /* regular effect destroyed */
> + data->effect_ids[slot-1] = -1;
> + else if (wd->effect_id >= HIDPP_FF_EFFECTID_AUTOCENTER)
> + /* autocenter spring destroyed */
> + data->slot_autocenter = 0;
> + }
LGTM.
Reviewed-by: Lee Jones <lee@kernel.org>
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-31 7:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 7:40 [PATCH] HID: logitech-hidpp: Check bounds when deleting force-feedback effects Günther Noack
2026-03-31 7:58 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox