From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53A0B24A055; Tue, 29 Apr 2025 17:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946128; cv=none; b=SfjeYeMZ25ZVMooVwrioE3lLD4aPEu2FKLufFXIMXgup9d+m0DbW7bf02xLKnVTrHssivy+92KXixUy/ywzfWQAQ0nJQxNFnSpf0/aDUCoHd0fsKX4C6ey0q+awBOA2YW/Z5GYeJPqyjbHftyv2B9EDAJ/vpXfaE1r0hOSMeulQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745946128; c=relaxed/simple; bh=Y2Gylub7I5tcqYZ5PneFnbQN1Jqz1ZJe2yUlQLr/FCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H8SKRh53yZ72P3VM6zXdKTRdyzcZTIfiQef+s8r3lyeqLMo2vgTS0a77iC03nwcLAFEutXVf/4Ds0aFDdEyFLydkeSbXWPTZa+pNmncaZEyc54HYTP7a3ffuz7UzN+UAtakjA0wtWFRbqwSCnxQSRelwDxS0IZuVBerZgiyrsk0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AGfQdr+o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AGfQdr+o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA2D6C4CEE3; Tue, 29 Apr 2025 17:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745946128; bh=Y2Gylub7I5tcqYZ5PneFnbQN1Jqz1ZJe2yUlQLr/FCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AGfQdr+oFuebkoTB7YHvckoSYoLCyk8jUQPv4aN0itARPQQ7k61soGCki4FN0IO7k UUEFdcUTjhnNLS/+YtgiThOZGUjDslWPHCxqw9RwQfn+/CH4m/9wwTk6WkOVE5Ngcy gSSGVETvbnEPQf+Js3yJKsz/Lka9pWoQI7pGwaHk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Frode Isaksen , stable , Thinh Nguyen Subject: [PATCH 6.14 165/311] usb: dwc3: gadget: check that event count does not exceed event buffer length Date: Tue, 29 Apr 2025 18:40:02 +0200 Message-ID: <20250429161127.801472160@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161121.011111832@linuxfoundation.org> References: <20250429161121.011111832@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Frode Isaksen commit 63ccd26cd1f6600421795f6ca3e625076be06c9f upstream. 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 Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver") Cc: stable Acked-by: Thinh Nguyen Link: https://lore.kernel.org/r/20250403072907.448524-1-fisaksen@baylibre.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -4564,6 +4564,12 @@ static irqreturn_t dwc3_check_event_buf( if (!count) return IRQ_NONE; + if (count > evt->length) { + dev_err_ratelimited(dwc->dev, "invalid count(%u) > evt->length(%u)\n", + count, evt->length); + return IRQ_NONE; + } + evt->count = count; evt->flags |= DWC3_EVENT_PENDING;