Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Frode Isaksen <fisaksen@baylibre.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"krishna.kurapati@oss.qualcomm.com"
	<krishna.kurapati@oss.qualcomm.com>,
	Frode Isaksen <frode@meta.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] usb: dwc3: gadget: check that event count does not exceed event buffer length
Date: Tue, 1 Apr 2025 23:43:15 +0000	[thread overview]
Message-ID: <20250401234311.nf5f4nomu6w5wwts@synopsys.com> (raw)
In-Reply-To: <20250401125350.221910-1-fisaksen@baylibre.com>

On Tue, Apr 01, 2025, Frode Isaksen wrote:
> From: Frode Isaksen <frode@meta.com>
> 
> The event count is read from register DWC3_GEVNTCOUNT.
> There is a check for the count being zero, but not for exceeding the
> event buffer length.
> Check that event count does not exceed event buffer length,
> avoiding an out-of-bounds access when memcpy'ing the event.
> Crash log:
> Unable to handle kernel paging request at virtual address ffffffc0129be000
> pc : __memcpy+0x114/0x180
> lr : dwc3_check_event_buf+0xec/0x348
> x3 : 0000000000000030 x2 : 000000000000dfc4
> x1 : ffffffc0129be000 x0 : ffffff87aad60080
> Call trace:
> __memcpy+0x114/0x180
> dwc3_interrupt+0x24/0x34
> 
> Signed-off-by: Frode Isaksen <frode@meta.com>
> Fixes: ebbb2d59398f ("usb: dwc3: gadget: use evt->cache for processing events")

The fix should go before this and since the beginning:

72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")

> Cc: stable@vger.kernel.org
> ---
> v1->v2: added error log

Isn't this supposed to be V3?

> 
>  drivers/usb/dwc3/gadget.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 89a4dc8ebf94..923737776d82 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -4564,6 +4564,12 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
>  	if (!count)
>  		return IRQ_NONE;
>  
> +	if (count > evt->length) {
> +		dev_err(dwc->dev, "invalid count(%u) > evt->length(%u)\n",
> +			count, evt->length);
> +		return IRQ_NONE;
> +	}
> +
>  	evt->count = count;
>  	evt->flags |= DWC3_EVENT_PENDING;
>  
> -- 
> 2.49.0
> 


  parent reply	other threads:[~2025-04-01 23:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 12:53 [PATCH v2] usb: dwc3: gadget: check that event count does not exceed event buffer length Frode Isaksen
2025-04-01 13:49 ` Greg KH
2025-04-01 23:43 ` Thinh Nguyen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-28 10:44 Frode Isaksen
2025-04-01  5:43 ` Krishna Kurapati
2025-04-01 12:08   ` Frode Isaksen
2025-04-01 12:26     ` Krishna Kurapati
2025-04-01 23:36       ` Thinh Nguyen
2025-04-02  4:42         ` Krishna Kurapati
2025-04-02  7:50           ` Frode Isaksen
2025-04-02 22:22             ` Thinh Nguyen

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=20250401234311.nf5f4nomu6w5wwts@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=fisaksen@baylibre.com \
    --cc=frode@meta.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=krishna.kurapati@oss.qualcomm.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@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