mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Fang Xieyan <fangxy@xiaopeng.com>
Cc: "hminas@synopsys.com" <hminas@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	Guanglei Zhu <zhugl3@xiaopeng.com>
Subject: Re: [PATCH] usb: dwc2: gadget: fix off-by-one in ep_from_windex bounds check
Date: Thu, 5 Nov 2026 01:25:11 +0000	[thread overview]
Message-ID: <auvOD5lXoSPL-1Va@vbox> (raw)
In-Reply-To: <20261026031138.35911-1-fangxy@xiaopeng.com>

On Mon, Oct 26, 2026, Fang Xieyan wrote:
> ep_from_windex() uses idx > hsotg->num_of_eps to validate the
> endpoint index. Since valid indices are below num_of_eps, an index
> equal to num_of_eps passes the check and is used to access
> eps_in[] or eps_out[] out of bounds. This can cause an unintended
> endpoint pointer to be used by subsequent request handling.

Not quite. The OOB access only happens when num_of_eps ==
MAX_EPS_CHANNELS, Otherwise, eps_in/out[] are zero-initialized, so
index_to_ep() returns NULL and the request is already rejected.

> 
> Reject indices greater than or equal to num_of_eps to prevent the
> out-of-bounds access.
> 
> Fixes: b3f489b2b658 ("usb:hsotg:samsung: Determine number of EPs from HW configuration register")

This points to the wrong commit. num_of_eps didn't include EP0 there. It
should be:

Fixes: c6f5c050e2a7 ("usb: dwc2: gadget: add bi-directional endpoint support")

And please Cc stable.

Thanks,
Thinh

      parent reply	other threads:[~2026-11-05  1:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26  3:11 Fang Xieyan
2026-10-26  7:26 ` Fang Xieyan
2026-11-05  1:25 ` Thinh Nguyen [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=auvOD5lXoSPL-1Va@vbox \
    --to=thinh.nguyen@synopsys.com \
    --cc=fangxy@xiaopeng.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hminas@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zhugl3@xiaopeng.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

all inboxes | Powered by JetHome®