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 A85E11114 for ; Wed, 21 Aug 2024 06:12: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=1724220734; cv=none; b=WEJ17YAs3wgSOuFRwJBnXZqBN0HHUkk4TrZT9Y20JxI/BWBUMhpDVUw7R+PSz5u1vnLvRNc0xtlWfdm/0i5iWco53IDE3RaNmPI8px/6E7SBEmV/8EQPru3khnE7UxLxb80PSd3bLnuqUsp9IucgnQPzeVSp4YQbBext4ACF09I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724220734; c=relaxed/simple; bh=wJhC+qjfeNcjL1elxIa7pvwcPViDTyqpa8VFRt6KapM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GxbFIm8Jr7qUVxIcywPcp3Kc76LTi/Icw3n0ZUPgQDi6QCMAJ7tlmcG/hzhnTgRJyAN/cFjgTknZbhhoMFQyQEABOEvtq8P8OMBml1UwnPDoTukzi//KBxHFlRHJnty5u2Mw72Q+ZJ/diSlAoS9PK882PWX5kv2unkBg6yaLsGU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lGpgETAI; 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="lGpgETAI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3965EC32782; Wed, 21 Aug 2024 06:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1724220734; bh=wJhC+qjfeNcjL1elxIa7pvwcPViDTyqpa8VFRt6KapM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=lGpgETAId86dIBILmTMspbOyN2fice5Ty35TMu4j/FGuvvYSCiYeonVMxEpZBus4u PZ6PL+ToUlhX4yYnoiZHpWjebgWNmWVWbb5Qz53hXGn45geIo8xzibBzXtTbHJmbEp fed9pT9QUmJajFtffHZcJB3BYhvwfeG6g5b5WfxE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-48869: USB: gadgetfs: Fix race between mounting and unmounting Date: Wed, 21 Aug 2024 14:11:03 +0800 Message-ID: <2024082105-CVE-2022-48869-bfe9@gregkh> X-Mailer: git-send-email 2.46.0 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=4249; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=wJhC+qjfeNcjL1elxIa7pvwcPViDTyqpa8VFRt6KapM=; b=kA0DAAIRMUfUDdst+ykByyZiAGbFhPnIZt7XhnHjpIoz6dcU03kwpuumq+IrFNLGKTl8d0PdW ohdBAARAgAdFiEE9LYMxb94wiFKMT3LMUfUDdst+ykFAmbFhPkACgkQMUfUDdst+ykdlACfckf5 RM1fV5n91X+qggg3lTy4a0UAoMWASyhiGVAdiHWwU7qhTGd9I7F6 X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: USB: gadgetfs: Fix race between mounting and unmounting The syzbot fuzzer and Gerald Lee have identified a use-after-free bug in the gadgetfs driver, involving processes concurrently mounting and unmounting the gadgetfs filesystem. In particular, gadgetfs_fill_super() can race with gadgetfs_kill_sb(), causing the latter to deallocate the_device while the former is using it. The output from KASAN says, in part: BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:102 [inline] BUG: KASAN: use-after-free in atomic_fetch_sub_release include/linux/atomic/atomic-instrumented.h:176 [inline] BUG: KASAN: use-after-free in __refcount_sub_and_test include/linux/refcount.h:272 [inline] BUG: KASAN: use-after-free in __refcount_dec_and_test include/linux/refcount.h:315 [inline] BUG: KASAN: use-after-free in refcount_dec_and_test include/linux/refcount.h:333 [inline] BUG: KASAN: use-after-free in put_dev drivers/usb/gadget/legacy/inode.c:159 [inline] BUG: KASAN: use-after-free in gadgetfs_kill_sb+0x33/0x100 drivers/usb/gadget/legacy/inode.c:2086 Write of size 4 at addr ffff8880276d7840 by task syz-executor126/18689 CPU: 0 PID: 18689 Comm: syz-executor126 Not tainted 6.1.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: ... atomic_fetch_sub_release include/linux/atomic/atomic-instrumented.h:176 [inline] __refcount_sub_and_test include/linux/refcount.h:272 [inline] __refcount_dec_and_test include/linux/refcount.h:315 [inline] refcount_dec_and_test include/linux/refcount.h:333 [inline] put_dev drivers/usb/gadget/legacy/inode.c:159 [inline] gadgetfs_kill_sb+0x33/0x100 drivers/usb/gadget/legacy/inode.c:2086 deactivate_locked_super+0xa7/0xf0 fs/super.c:332 vfs_get_super fs/super.c:1190 [inline] get_tree_single+0xd0/0x160 fs/super.c:1207 vfs_get_tree+0x88/0x270 fs/super.c:1531 vfs_fsconfig_locked fs/fsopen.c:232 [inline] The simplest solution is to ensure that gadgetfs_fill_super() and gadgetfs_kill_sb() are serialized by making them both acquire a new mutex. The Linux kernel CVE team has assigned CVE-2022-48869 to this issue. Affected and fixed versions =========================== Issue introduced in 5.3 with commit e5d82a7360d1 and fixed in 5.4.230 with commit 9a39f4626b36 Issue introduced in 5.3 with commit e5d82a7360d1 and fixed in 5.10.165 with commit 856e4b5e53f2 Issue introduced in 5.3 with commit e5d82a7360d1 and fixed in 5.15.90 with commit a2e075f40122 Issue introduced in 5.3 with commit e5d82a7360d1 and fixed in 6.1.8 with commit 616fd34d0170 Issue introduced in 5.3 with commit e5d82a7360d1 and fixed in 6.2 with commit d18dcfe9860e 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-48869 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/legacy/inode.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/9a39f4626b361ee7aa10fd990401c37ec3b466ae https://git.kernel.org/stable/c/856e4b5e53f21edbd15d275dde62228dd94fb2b4 https://git.kernel.org/stable/c/a2e075f40122d8daf587db126c562a67abd69cf9 https://git.kernel.org/stable/c/616fd34d017000ecf9097368b13d8a266f4920b3 https://git.kernel.org/stable/c/d18dcfe9860e842f394e37ba01ca9440ab2178f4