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 1768918CBE1 for ; Mon, 8 Dec 2025 00:48:14 +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=1765154895; cv=none; b=Xg9s7Pdtfkm7flECIZjCffuSZOpNIMaOZsxgE4D5qhi2U0TEjttpDRclO1kiZ8u7oZWm0G1ETZP4PpGuRgj0iRDcSISTKACRR+ZLxQG+NFyMZeG+02n3GG2MaFV15fPF+TN7mjqlJb8VamDsj/eAE4Q/a/bVWqpxLBF9UjGqGzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765154895; c=relaxed/simple; bh=9+zoa1T113aXD32pwdVg25MINY8Gq58HH9/7juUhXj4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KUjdklBqajSSsuyS1OhOalZ75m6oTHozLQvYwq3+D039MVDYpQ0k/IjSAZJ2jrzFVEALTlbHOW4bKoxGkS/c3utjpWbBa4D4a6jOIbOutqwVF8DXGUGk9Mzg3HUNwmh0/Nur8FPVascKDrnWgFTWmA2OhY2mNiDXs/U/iNN+F4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JF1Z6uFp; 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="JF1Z6uFp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BE63C4CEFB; Mon, 8 Dec 2025 00:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765154894; bh=9+zoa1T113aXD32pwdVg25MINY8Gq58HH9/7juUhXj4=; h=From:To:Cc:Subject:Date:Reply-To:From; b=JF1Z6uFpsh0eTYViHJOjKKH5jCtUUN8bo45CoKtWK+MSSUPQom5S3YafDdU6th3iV +5XO7jOSlUNy3JlYOkmyv6wxckiZXtcndehQX+5JK216C/l5m7zZcFzd3wSgo5tBlM 08fkqQJS7f/fm6rLLvUrzxhXRWtunu1lAYWAPoig= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40314: usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget Date: Mon, 8 Dec 2025 09:47:38 +0900 Message-ID: <2025120822-CVE-2025-40314-1dcb@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2907; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=DeW4GgYJqQUw3SwSb6rbaHX3VNGtBT7plHn+GulxJDA=; b=owGbwMvMwCRo6H6F97bub03G02pJDJlmClLn5xlcuG2vfExQTWOP+tpJMdp3Lrd2q976NCOB6 2Vb/GzljlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjI0XsMc2X0NDXsald+/d+d 8VIgTODL91OCNxjm2Ug1Cvruj1WQ3Hz84vQekZINFs/PAwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: usb: cdns3: gadget: Use-after-free during failed initialization and exit of cdnsp gadget In the __cdnsp_gadget_init() and cdnsp_gadget_exit() functions, the gadget structure (pdev->gadget) was freed before its endpoints. The endpoints are linked via the ep_list in the gadget structure. Freeing the gadget first leaves dangling pointers in the endpoint list. When the endpoints are subsequently freed, this results in a use-after-free. Fix: By separating the usb_del_gadget_udc() operation into distinct "del" and "put" steps, cdnsp_gadget_free_endpoints() can be executed prior to the final release of the gadget structure with usb_put_gadget(). A patch similar to bb9c74a5bd14("usb: dwc3: gadget: Free gadget structure only after freeing endpoints"). The Linux kernel CVE team has assigned CVE-2025-40314 to this issue. Affected and fixed versions =========================== Fixed in 5.15.197 with commit 0cf9a50af91fbdac3849f8d950e883a3eaa3ecea Fixed in 6.1.159 with commit 37158ce6ba964b62d1e3eebd11f03c6900a52dd1 Fixed in 6.6.117 with commit ea37884097a0931abb8e11e40eacfb25e9fdb5e9 Fixed in 6.12.58 with commit 9c52f01429c377a2d32cafc977465f37b5384f77 Fixed in 6.17.8 with commit fdf573c517627a96f5040f988e9b21267806be5c Fixed in 6.18 with commit 87c5ff5615dc0a37167e8faf3adeeddc6f1344a3 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-40314 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/usb/cdns3/cdnsp-gadget.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/0cf9a50af91fbdac3849f8d950e883a3eaa3ecea https://git.kernel.org/stable/c/37158ce6ba964b62d1e3eebd11f03c6900a52dd1 https://git.kernel.org/stable/c/ea37884097a0931abb8e11e40eacfb25e9fdb5e9 https://git.kernel.org/stable/c/9c52f01429c377a2d32cafc977465f37b5384f77 https://git.kernel.org/stable/c/fdf573c517627a96f5040f988e9b21267806be5c https://git.kernel.org/stable/c/87c5ff5615dc0a37167e8faf3adeeddc6f1344a3