linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
@ 2018-01-10  9:39 Dan Carpenter
  2018-01-15 20:21 ` Silvan Jegen
  2018-01-23 14:47 ` Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-01-10  9:39 UTC (permalink / raw)
  To: Stefan Achatz
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, kernel-janitors

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 <dan.carpenter@oracle.com>

diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c
index 43617fb28b87..317c9c2c0a7c 100644
--- a/drivers/hid/hid-roccat-kovaplus.c
+++ b/drivers/hid/hid-roccat-kovaplus.c
@@ -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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
  2018-01-10  9:39 [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Dan Carpenter
@ 2018-01-15 20:21 ` Silvan Jegen
  2018-01-23 14:47 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Silvan Jegen @ 2018-01-15 20:21 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Stefan Achatz, Jiri Kosina, Benjamin Tissoires, linux-input,
	kernel-janitors

Hi

On Wed, Jan 10, 2018 at 12:39:03PM +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>

Looks good to me.

Acked-by: Silvan Jegen <s.jegen@gmail.com>


> diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c
> index 43617fb28b87..317c9c2c0a7c 100644
> --- a/drivers/hid/hid-roccat-kovaplus.c
> +++ b/drivers/hid/hid-roccat-kovaplus.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
  2018-01-10  9:39 [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Dan Carpenter
  2018-01-15 20:21 ` Silvan Jegen
@ 2018-01-23 14:47 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2018-01-23 14:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Stefan Achatz, Benjamin Tissoires, linux-input, kernel-janitors

On Wed, 10 Jan 2018, Dan Carpenter wrote:

> 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 <dan.carpenter@oracle.com>

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-23 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-10  9:39 [PATCH] HID: roccat: prevent an out of bounds read in kovaplus_profile_activated() Dan Carpenter
2018-01-15 20:21 ` Silvan Jegen
2018-01-23 14:47 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).