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 4EE021494C9 for ; Wed, 26 Feb 2025 01:57:23 +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=1740535044; cv=none; b=OQye7RSKzqFpqvE1R4jllyToE1sz1HKIroxe5F0ERb8+IAfkFGJwP68BxwGeokRJNxf7a893RzWjKqaHq4rFsHXkW8ltZSV1c+JNWKpk/EjJ5kvHDQCjM+NpMVtiN3t/LroNJdPk2+K7VGwLlrEbvK+QhA85ATbnpZE/E55IT6A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535044; c=relaxed/simple; bh=7FC7PXmBCXgp5hOHaxn4kW/IpfFOhdLWEcrUVaJE4vI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Qdmw4JxiHcDguTRqVz5yK9bb5wtbJks9EaM506jNRN1qUw6tBAF5z3WmCZe5vpRI+H/l3r1nKz9zrCgZu+UrdLLeIUFI6a8jO3BtsqRCDMy3kUM2GcVjwzANMkO37LA+ormzxpCelJwJt6VdTvODkf27u++kKvs5/uy+35nrZ2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0eWXLBNs; 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="0eWXLBNs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6F30C4CEE6; Wed, 26 Feb 2025 01:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535043; bh=7FC7PXmBCXgp5hOHaxn4kW/IpfFOhdLWEcrUVaJE4vI=; h=From:To:Cc:Subject:Date:Reply-to:From; b=0eWXLBNs9Ij8HXIu9+acEA6XIOigqRyALMuGbd8V3OCFTbE7BaQoUXet14cfN3GQ3 WAIiIFCQq00r6/cCEhY1Wx6a0QXiomWEtBlpd4hI8x4KhOSO6lumQWAWnNOQVKqEmP mzSGuW1tSzJHT8m4vGEMPVqKNQc8nj+eHvkAIEno= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47637: ubifs: Fix deadlock in concurrent rename whiteout and inode writeback Date: Wed, 26 Feb 2025 02:53:48 +0100 Message-ID: <2025022646-CVE-2021-47637-c754@gregkh> X-Mailer: git-send-email 2.48.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=4833; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=7FC7PXmBCXgp5hOHaxn4kW/IpfFOhdLWEcrUVaJE4vI=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SrTkZz/zCOw8ny+bWDiFIyQ/Zpejw7qGDcJhWu7Vd Rq/ld92xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwESsNjIsWNi70uDUrYBcaVGe zieS82+V1WY3MMxmW3ua64P20/r7anpROgrf5x0Me/YXAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: ubifs: Fix deadlock in concurrent rename whiteout and inode writeback Following hung tasks: [ 77.028764] task:kworker/u8:4 state:D stack: 0 pid: 132 [ 77.028820] Call Trace: [ 77.029027] schedule+0x8c/0x1b0 [ 77.029067] mutex_lock+0x50/0x60 [ 77.029074] ubifs_write_inode+0x68/0x1f0 [ubifs] [ 77.029117] __writeback_single_inode+0x43c/0x570 [ 77.029128] writeback_sb_inodes+0x259/0x740 [ 77.029148] wb_writeback+0x107/0x4d0 [ 77.029163] wb_workfn+0x162/0x7b0 [ 92.390442] task:aa state:D stack: 0 pid: 1506 [ 92.390448] Call Trace: [ 92.390458] schedule+0x8c/0x1b0 [ 92.390461] wb_wait_for_completion+0x82/0xd0 [ 92.390469] __writeback_inodes_sb_nr+0xb2/0x110 [ 92.390472] writeback_inodes_sb_nr+0x14/0x20 [ 92.390476] ubifs_budget_space+0x705/0xdd0 [ubifs] [ 92.390503] do_rename.cold+0x7f/0x187 [ubifs] [ 92.390549] ubifs_rename+0x8b/0x180 [ubifs] [ 92.390571] vfs_rename+0xdb2/0x1170 [ 92.390580] do_renameat2+0x554/0x770 , are caused by concurrent rename whiteout and inode writeback processes: rename_whiteout(Thread 1) wb_workfn(Thread2) ubifs_rename do_rename lock_4_inodes (Hold ui_mutex) ubifs_budget_space make_free_space shrink_liability __writeback_inodes_sb_nr bdi_split_work_to_wbs (Queue new wb work) wb_do_writeback(wb work) __writeback_single_inode ubifs_write_inode LOCK(ui_mutex) ↑ wb_wait_for_completion (Wait wb work) <-- deadlock! Reproducer (Detail program in [Link]): 1. SYS_renameat2("/mp/dir/file", "/mp/dir/whiteout", RENAME_WHITEOUT) 2. Consume out of space before kernel(mdelay) doing budget for whiteout Fix it by doing whiteout space budget before locking ubifs inodes. BTW, it also fixes wrong goto tag 'out_release' in whiteout budget error handling path(It should at least recover dir i_size and unlock 4 ubifs inodes). The Linux kernel CVE team has assigned CVE-2021-47637 to this issue. Affected and fixed versions =========================== Issue introduced in 4.9 with commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 and fixed in 4.19.238 with commit 9dddc8211430fb851ddf0b168e3a00c6f66cc185 Issue introduced in 4.9 with commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 and fixed in 5.4.189 with commit 37bdf1ad592555ecda1d55b89f6e393e4c0589d1 Issue introduced in 4.9 with commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 and fixed in 5.10.110 with commit 83e42a78428fc354f5e2049935b84c8d8d29b787 Issue introduced in 4.9 with commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 and fixed in 5.15.33 with commit c58af8564a7b08757173009030b74baf4b2b762b Issue introduced in 4.9 with commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 and fixed in 5.16.19 with commit 70e9090acc32348cedc5def0cd6d5c126efc97b9 Issue introduced in 4.9 with commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 and fixed in 5.17.2 with commit 8b278c8dcfb565cb65eceb62a38cbf7a7c326db5 Issue introduced in 4.9 with commit 9e0a1fff8db56eaaebb74b4a3ef65f86811c4798 and fixed in 5.18 with commit afd427048047e8efdedab30e8888044e2be5aa9c 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-2021-47637 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: fs/ubifs/dir.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/9dddc8211430fb851ddf0b168e3a00c6f66cc185 https://git.kernel.org/stable/c/37bdf1ad592555ecda1d55b89f6e393e4c0589d1 https://git.kernel.org/stable/c/83e42a78428fc354f5e2049935b84c8d8d29b787 https://git.kernel.org/stable/c/c58af8564a7b08757173009030b74baf4b2b762b https://git.kernel.org/stable/c/70e9090acc32348cedc5def0cd6d5c126efc97b9 https://git.kernel.org/stable/c/8b278c8dcfb565cb65eceb62a38cbf7a7c326db5 https://git.kernel.org/stable/c/afd427048047e8efdedab30e8888044e2be5aa9c