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 D53E54594D for ; Sat, 28 Dec 2024 09:46:45 +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=1735379206; cv=none; b=XPSKiQZ0eY/2AfytJ35fQxUzfHR7OQRTIZ36e1hgmocuBsl0Wz/4FZqs7/Az3XZ5VfWvbqkAgzytl4LwzJUc1+F72RNAcaGjU8s+4F0ct+0Nt338wEzp5aowmRgillc+8CSEVRrKeVo/WJMjYPc7jr58X9TNDOLMpWRJWBRQEKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735379206; c=relaxed/simple; bh=pwql488f/sB9SRXHb8f94QpYkRuv/dr6hb/B0BmCVSg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PHPv7SriBbQzTT2CCTH6cm5DzMQAprQs6yfv0rm3rmUSHicM5T8R40FKf1GwN3P+5bIxkjrCqwzdh3+EzYgZ06zpwCakDSaDH8d2brl3Y9Bm+Y9IL/9ZaHd+JEHIgMY+lu4qtR4c1ZyaS2XrA58PBKjnglxktszcQ7IP3goCaeE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cXyQbBLG; 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="cXyQbBLG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 048D1C4CECD; Sat, 28 Dec 2024 09:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735379205; bh=pwql488f/sB9SRXHb8f94QpYkRuv/dr6hb/B0BmCVSg=; h=From:To:Cc:Subject:Date:Reply-to:From; b=cXyQbBLG7FDeQPoYTKr44FthLotIwONMGE3VzMfs01lrFPcp5ILvbNMLiOt0STflh HSV8xSgY4KN8HpgYNqAQNtu0DZHALRHGf7+/OHy84e+4/JweuHVk9c8UM6z7jpX/uJ WyxMl9yhwKL/Cf6W1Hf1wTB6/pT1KmUb0LPgeHzU= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-56686: ext4: fix race in buffer_head read fault injection Date: Sat, 28 Dec 2024 10:45:38 +0100 Message-ID: <2024122833-CVE-2024-56686-b432@gregkh> X-Mailer: git-send-email 2.47.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=4188; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=pwql488f/sB9SRXHb8f94QpYkRuv/dr6hb/B0BmCVSg=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn5J/b17ezR2Mz40O/xqr1caV5vrwX6/hO55uW4S6O54 hdnpO+3jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjINRWGeXozb6V7bo+2brvd O7ewfsoj32/cnxhms376wMrtd3/q7crwbTmbuuP2mKxZDgA= 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: ext4: fix race in buffer_head read fault injection When I enabled ext4 debug for fault injection testing, I encountered the following warning: EXT4-fs error (device sda): ext4_read_inode_bitmap:201: comm fsstress: Cannot read inode bitmap - block_group = 8, inode_bitmap = 1051 WARNING: CPU: 0 PID: 511 at fs/buffer.c:1181 mark_buffer_dirty+0x1b3/0x1d0 The root cause of the issue lies in the improper implementation of ext4's buffer_head read fault injection. The actual completion of buffer_head read and the buffer_head fault injection are not atomic, which can lead to the uptodate flag being cleared on normally used buffer_heads in race conditions. [CPU0] [CPU1] [CPU2] ext4_read_inode_bitmap ext4_read_bh() ext4_read_inode_bitmap if (buffer_uptodate(bh)) return bh jbd2_journal_commit_transaction __jbd2_journal_refile_buffer __jbd2_journal_unfile_buffer __jbd2_journal_temp_unlink_buffer ext4_simulate_fail_bh() clear_buffer_uptodate mark_buffer_dirty WARN_ON_ONCE(!buffer_uptodate(bh)) The best approach would be to perform fault injection in the IO completion callback function, rather than after IO completion. However, the IO completion callback function cannot get the fault injection code in sb. Fix it by passing the result of fault injection into the bh read function, we simulate faults within the bh read function itself. This requires adding an extra parameter to the bh read functions that need fault injection. The Linux kernel CVE team has assigned CVE-2024-56686 to this issue. Affected and fixed versions =========================== Issue introduced in 5.6 with commit 46f870d690fecc792a66730dcbbf0aa109f5f9ab and fixed in 6.6.64 with commit 77035e4d27e15f87ea55929c8bb8fb1970129e2f Issue introduced in 5.6 with commit 46f870d690fecc792a66730dcbbf0aa109f5f9ab and fixed in 6.11.11 with commit 25a5acf88fed59e060405bbb48098f4a3a2c2adc Issue introduced in 5.6 with commit 46f870d690fecc792a66730dcbbf0aa109f5f9ab and fixed in 6.12.2 with commit 61832ee7fa2fbd569d129379e795038abfb0d128 Issue introduced in 5.6 with commit 46f870d690fecc792a66730dcbbf0aa109f5f9ab and fixed in 6.13-rc1 with commit 2f3d93e210b9c2866c8b3662adae427d5bf511ec 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-2024-56686 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/ext4/balloc.c fs/ext4/ext4.h fs/ext4/extents.c fs/ext4/ialloc.c fs/ext4/indirect.c fs/ext4/inode.c fs/ext4/mmp.c fs/ext4/move_extent.c fs/ext4/resize.c fs/ext4/super.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/77035e4d27e15f87ea55929c8bb8fb1970129e2f https://git.kernel.org/stable/c/25a5acf88fed59e060405bbb48098f4a3a2c2adc https://git.kernel.org/stable/c/61832ee7fa2fbd569d129379e795038abfb0d128 https://git.kernel.org/stable/c/2f3d93e210b9c2866c8b3662adae427d5bf511ec