public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: "Günther Noack" <gnoack@google.com>
Cc: "Filipe Laíns" <lains@riseup.net>,
	"Bastien Nocera" <hadess@hadess.net>,
	"Jiri Kosina" <jikos@kernel.org>,
	"Benjamin Tissoires" <bentiss@kernel.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] HID: logitech-hidpp: Check bounds when deleting force-feedback effects
Date: Tue, 31 Mar 2026 08:58:13 +0100	[thread overview]
Message-ID: <20260331075813.GB3241346@google.com> (raw)
In-Reply-To: <20260331074052.194064-1-gnoack@google.com>

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 [李琼斯]

      reply	other threads:[~2026-03-31  7:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260331075813.GB3241346@google.com \
    --to=lee@kernel.org \
    --cc=bentiss@kernel.org \
    --cc=gnoack@google.com \
    --cc=hadess@hadess.net \
    --cc=jikos@kernel.org \
    --cc=lains@riseup.net \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox