HID: logitech-hidpp: Check bounds when deleting force-feedback effects
Subsystems (3)
PATCH 1/1 HID: logitech-hidpp: Check bounds when deleting force-feedback effects
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.
--- drivers/hid/hid-logitech-hidpp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/hid/hid-logitech-hidpp.c +9 -6
@@ -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 ];
Signature · 1 line
2.53.0.1018.g2bb0e51243-goog
Quoted 24 lines · Günther Noack
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 <[email protected]>Signed-off-by Günther Noack <[email protected]>--- drivers/hid/hid-logitech-hidpp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)drivers/hid/hid-logitech-hidpp.c +0
-5@@ -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 */
drivers/hid/hid-logitech-hidpp.c static void hidpp_ff_work_handler(struct work_struct *w) · line 2513
Quoted 10 lines
drivers/hid/hid-logitech-hidpp.c +9
-1- 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.
Signature · 1 line
Lee Jones [李琼斯]
Quoted 7 lines · Günther Noack
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 <[email protected]>Signed-off-by G=C3=BCnther Noack <[email protected]>
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs