CVE-2022-49414

Severity CVSS v4.0:
Pending analysis
Type:
CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
Publication date:
26/02/2025
Last modified:
01/10/2025

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> ext4: fix race condition between ext4_write and ext4_convert_inline_data<br /> <br /> Hulk Robot reported a BUG_ON:<br /> ==================================================================<br /> EXT4-fs error (device loop3): ext4_mb_generate_buddy:805: group 0,<br /> block bitmap and bg descriptor inconsistent: 25 vs 31513 free clusters<br /> kernel BUG at fs/ext4/ext4_jbd2.c:53!<br /> invalid opcode: 0000 [#1] SMP KASAN PTI<br /> CPU: 0 PID: 25371 Comm: syz-executor.3 Not tainted 5.10.0+ #1<br /> RIP: 0010:ext4_put_nojournal fs/ext4/ext4_jbd2.c:53 [inline]<br /> RIP: 0010:__ext4_journal_stop+0x10e/0x110 fs/ext4/ext4_jbd2.c:116<br /> [...]<br /> Call Trace:<br /> ext4_write_inline_data_end+0x59a/0x730 fs/ext4/inline.c:795<br /> generic_perform_write+0x279/0x3c0 mm/filemap.c:3344<br /> ext4_buffered_write_iter+0x2e3/0x3d0 fs/ext4/file.c:270<br /> ext4_file_write_iter+0x30a/0x11c0 fs/ext4/file.c:520<br /> do_iter_readv_writev+0x339/0x3c0 fs/read_write.c:732<br /> do_iter_write+0x107/0x430 fs/read_write.c:861<br /> vfs_writev fs/read_write.c:934 [inline]<br /> do_pwritev+0x1e5/0x380 fs/read_write.c:1031<br /> [...]<br /> ==================================================================<br /> <br /> Above issue may happen as follows:<br /> cpu1 cpu2<br /> __________________________|__________________________<br /> do_pwritev<br /> vfs_writev<br /> do_iter_write<br /> ext4_file_write_iter<br /> ext4_buffered_write_iter<br /> generic_perform_write<br /> ext4_da_write_begin<br /> vfs_fallocate<br /> ext4_fallocate<br /> ext4_convert_inline_data<br /> ext4_convert_inline_data_nolock<br /> ext4_destroy_inline_data_nolock<br /> clear EXT4_STATE_MAY_INLINE_DATA<br /> ext4_map_blocks<br /> ext4_ext_map_blocks<br /> ext4_mb_new_blocks<br /> ext4_mb_regular_allocator<br /> ext4_mb_good_group_nolock<br /> ext4_mb_init_group<br /> ext4_mb_init_cache<br /> ext4_mb_generate_buddy --&gt; error<br /> ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)<br /> ext4_restore_inline_data<br /> set EXT4_STATE_MAY_INLINE_DATA<br /> ext4_block_write_begin<br /> ext4_da_write_end<br /> ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)<br /> ext4_write_inline_data_end<br /> handle=NULL<br /> ext4_journal_stop(handle)<br /> __ext4_journal_stop<br /> ext4_put_nojournal(handle)<br /> ref_cnt = (unsigned long)handle<br /> BUG_ON(ref_cnt == 0) ---&gt; BUG_ON<br /> <br /> The lock held by ext4_convert_inline_data is xattr_sem, but the lock<br /> held by generic_perform_write is i_rwsem. Therefore, the two locks can<br /> be concurrent.<br /> <br /> To solve above issue, we add inode_lock() for ext4_convert_inline_data().<br /> At the same time, move ext4_convert_inline_data() in front of<br /> ext4_punch_hole(), remove similar handling from ext4_punch_hole().

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 3.8 (including) 5.4.207 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.5 (including) 5.10.132 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.11 (including) 5.15.46 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.16 (including) 5.17.14 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 5.18 (including) 5.18.3 (excluding)