HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
Subsystems (3)
PATCH 1/1 HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
We get the "new_profile_index" value from the mouse device when we're handling raw events. Smatch taints it as untrusted data and complains that we need a bounds check. This seems like a reasonable warning otherwise there is a small read beyond the end of the array.
drivers/hid/hid-roccat-kovaplus.c +2 -0
@@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(uint value)static void kovaplus_profile_activated (struct kovaplus_device *kovaplus,uint new_profile_index) { +if (new_profile_index >=ARRAY_SIZE (kovaplus->profile_settings)) +return ; kovaplus->actual_profile = new_profile_index; kovaplus->actual_cpi = kovaplus->profile_settings[new_profile_index].cpi_startup_level; kovaplus->actual_x_sensitivity = kovaplus->profile_settings[new_profile_index].sensitivity_x;
Hi
Quoted 7 lines · Dan Carpenter
We get the "
new_profile_index" value from the mouse device when we're handling raw events. Smatch taints it as untrusted data and complains that we need a bounds check. This seems like a reasonable warning otherwise there is a small read beyond the end of the array.Fixes 0e70f97f257e ("HID: roccat: Add support for Kova[+] mouse")Signed-off-by Dan Carpenter <[email protected]>
Looks good to me.
Quoted 17 lines
drivers/hid/hid-roccat-kovaplus.c +2
-1@@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(uint value)static void kovaplus_profile_activated (struct kovaplus_device *kovaplus,uint new_profile_index) { +if (new_profile_index >=ARRAY_SIZE (kovaplus->profile_settings)) +return ; kovaplus->actual_profile = new_profile_index; kovaplus->actual_cpi = kovaplus->profile_settings[new_profile_index].cpi_startup_level; kovaplus->actual_x_sensitivity = kovaplus->profile_settings[new_profile_index].sensitivity_x; --To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Dan Carpenter
We get the "
new_profile_index" value from the mouse device when we're handling raw events. Smatch taints it as untrusted data and complains that we need a bounds check. This seems like a reasonable warning otherwise there is a small read beyond the end of the array.Fixes 0e70f97f257e ("HID: roccat: Add support for Kova[+] mouse")Signed-off-by Dan Carpenter <[email protected]>
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs