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 3AD502F49FC for ; Wed, 22 Oct 2025 13:24:34 +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=1761139475; cv=none; b=YuWMMX0x1Jc7aS4UKO3bcqOAVz6Rv6qwoGs5tsifhxC8uRzvA+Pg9mTTRwa77ny1oFOiilAoBs9FTKnm64hV+dMwSH4TPPWr8HK6+gEh8Gr54UrSHNcJYvdNLSgh0fC1PJGYRNst0I7pm8ScZhwdv4hIvh2BtvzZO40IBxaqUFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761139475; c=relaxed/simple; bh=FbSSHgFfKrPKilyCOMxyWC3DMtp0RKb9Rt9dmcrCgUM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=izjsNs3Vo0DoSJtpBACD327uo+biMyJbnpm3Msz7U/XPsiCO3ipL4KzdzelZ8WMnz1SFcgCKW/hFzQTzC2vnPf8IhjaO1hpwIXlgs7AoVIqPI8ZvJ/bpOr5pFfY3KJetGRBi/OGtk2IYlj6lBdpZI8Axe7Gy9vN83dQMIEVs/zY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Am2fslxY; 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="Am2fslxY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F98BC4CEFF; Wed, 22 Oct 2025 13:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761139474; bh=FbSSHgFfKrPKilyCOMxyWC3DMtp0RKb9Rt9dmcrCgUM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Am2fslxYXCp8V+bVorP7kakW6piF/qB9XTueQyapOlpvvcVIONIla4pEQqg8xz7l1 Um69SZ1dlakLQpQMf0rBe/3JynAgusMAMi+HQ/cRNno2nPuHuRhodNz29gAUTh4Vs7 EPtJ5gAkFZsFx/pu7JELwGqrEOut0QtAVqS8NNoo= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50568: usb: gadget: f_hid: fix f_hidg lifetime vs cdev Date: Wed, 22 Oct 2025 15:24:16 +0200 Message-ID: <2025102207-CVE-2022-50568-f109@gregkh> X-Mailer: git-send-email 2.51.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3558; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=znSiGxzwMUTwWLCuc8xSJHFvp7E5uT3xwktDIDnmC/Q=; b=owGbwMvMwCRo6H6F97bub03G02pJDBk/bn3vdmYxPauzL3HZnIsulzZolvxlYfSbueaK2h2T0 JdccxZ96YhlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJXNFlWDD/veXy/BrxY65c fGzcmzx3cjC6nmFYcODe1YWVD6Ik7ee+738WYPY5McwuCwA= 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: gadget: f_hid: fix f_hidg lifetime vs cdev The embedded struct cdev does not have its lifetime correctly tied to the enclosing struct f_hidg, so there is a use-after-free if /dev/hidgN is held open while the gadget is deleted. This can readily be replicated with libusbgx's example programs (for conciseness - operating directly via configfs is equivalent): gadget-hid exec 3<> /dev/hidg0 gadget-vid-pid-remove exec 3<&- Pull the existing device up in to struct f_hidg and make use of the cdev_device_{add,del}() helpers. This changes the lifetime of the device object to match struct f_hidg, but note that it is still added and deleted at the same time. The Linux kernel CVE team has assigned CVE-2022-50568 to this issue. Affected and fixed versions =========================== Issue introduced in 2.6.35 with commit 71adf118946957839a13aa4d1094183e05c6c094 and fixed in 4.19.270 with commit 1cd7f156f6389918f760687fbbf133c86da93162 Issue introduced in 2.6.35 with commit 71adf118946957839a13aa4d1094183e05c6c094 and fixed in 5.4.229 with commit c78c87c4e389b62f8892af7f59857447aa6d9797 Issue introduced in 2.6.35 with commit 71adf118946957839a13aa4d1094183e05c6c094 and fixed in 5.10.163 with commit 1b6a53e447ec3d81623610c8c7ec5082b47dfdce Issue introduced in 2.6.35 with commit 71adf118946957839a13aa4d1094183e05c6c094 and fixed in 5.15.86 with commit d3136b79705c2e3bba9c76adc5628af0215d798e Issue introduced in 2.6.35 with commit 71adf118946957839a13aa4d1094183e05c6c094 and fixed in 6.0.16 with commit 9e4b85d815b14bd4db2deea2a54264a23de8b896 Issue introduced in 2.6.35 with commit 71adf118946957839a13aa4d1094183e05c6c094 and fixed in 6.1.2 with commit 9e08b7f5fa00e9d550851352bd0d1ba74ccffef2 Issue introduced in 2.6.35 with commit 71adf118946957839a13aa4d1094183e05c6c094 and fixed in 6.2 with commit 89ff3dfac604614287ad5aad9370c3f984ea3f4b 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-2022-50568 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/gadget/function/f_hid.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/1cd7f156f6389918f760687fbbf133c86da93162 https://git.kernel.org/stable/c/c78c87c4e389b62f8892af7f59857447aa6d9797 https://git.kernel.org/stable/c/1b6a53e447ec3d81623610c8c7ec5082b47dfdce https://git.kernel.org/stable/c/d3136b79705c2e3bba9c76adc5628af0215d798e https://git.kernel.org/stable/c/9e4b85d815b14bd4db2deea2a54264a23de8b896 https://git.kernel.org/stable/c/9e08b7f5fa00e9d550851352bd0d1ba74ccffef2 https://git.kernel.org/stable/c/89ff3dfac604614287ad5aad9370c3f984ea3f4b