| From bippy-5f407fcff5a0 Mon Sep 17 00:00:00 2001 |
| From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| To: <linux-cve-announce@vger.kernel.org> |
| Reply-to: <cve@kernel.org>, <linux-kernel@vger.kernel.org> |
| Subject: CVE-2024-56686: ext4: fix race in buffer_head read fault injection |
| |
| 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() |
| <bh read complete> |
| 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 |
| <report warning> |
| 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 |