public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Kery Qi <qikeyu2017@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB: gadget: max3420: validate endpoint index in set_clear_feature
Date: Fri, 16 Jan 2026 16:27:30 +0100	[thread overview]
Message-ID: <2026011622-finalist-gleaming-d275@gregkh> (raw)
In-Reply-To: <20260105081402.1287-2-qikeyu2017@gmail.com>

On Mon, Jan 05, 2026 at 04:14:02PM +0800, Kery Qi wrote:
> Assure that the host may not manipulate the index to point past the
> endpoint array.
> 
> In max3420_set_clear_feature(), the driver derives the endpoint
> index from the wIndex field of the setup packet. However, there is
> no check to ensure this index is within the valid bounds of the
> udc->ep[] array.
> 
> A malicious host could send a USB_REQ_SET_FEATURE or
> USB_REQ_CLEAR_FEATURE request with a large endpoint index, leading
> to an out-of-bounds memory access when accessing udc->ep[id].
> 
> This patch adds a validation check against MAX3420_MAX_EPS. If the
> endpoint index is invalid, we simply break the switch statement
> to invoke the existing error handling path.
> 
> Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
> ---
>  drivers/usb/gadget/udc/max3420_udc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c
> index ac11ddf3fcbc..f4f549d88d6d 100644
> --- a/drivers/usb/gadget/udc/max3420_udc.c
> +++ b/drivers/usb/gadget/udc/max3420_udc.c
> @@ -600,6 +600,8 @@ static void max3420_set_clear_feature(struct max3420_udc *udc)
>  			break;
>  
>  		id = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK;
> +		if (id >= MAX3420_MAX_EPS)
> +			break;
>  		ep = &udc->ep[id];
>  
>  		spin_lock_irqsave(&ep->lock, flags);
> -- 
> 2.34.1
> 

Same problems here as your other patch :(

      reply	other threads:[~2026-01-16 15:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05  8:14 [PATCH] USB: gadget: max3420: validate endpoint index in set_clear_feature Kery Qi
2026-01-16 15:27 ` Greg KH [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=2026011622-finalist-gleaming-d275@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qikeyu2017@gmail.com \
    /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