CVE-2024-50225

Severity CVSS v4.0:
Pending analysis
Type:
CWE-476 NULL Pointer Dereference
Publication date:
09/11/2024
Last modified:
01/10/2025

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> btrfs: fix error propagation of split bios<br /> <br /> The purpose of btrfs_bbio_propagate_error() shall be propagating an error<br /> of split bio to its original btrfs_bio, and tell the error to the upper<br /> layer. However, it&amp;#39;s not working well on some cases.<br /> <br /> * Case 1. Immediate (or quick) end_bio with an error<br /> <br /> When btrfs sends btrfs_bio to mirrored devices, btrfs calls<br /> btrfs_bio_end_io() when all the mirroring bios are completed. If that<br /> btrfs_bio was split, it is from btrfs_clone_bioset and its end_io function<br /> is btrfs_orig_write_end_io. For this case, btrfs_bbio_propagate_error()<br /> accesses the orig_bbio&amp;#39;s bio context to increase the error count.<br /> <br /> That works well in most cases. However, if the end_io is called enough<br /> fast, orig_bbio&amp;#39;s (remaining part after split) bio context may not be<br /> properly set at that time. Since the bio context is set when the orig_bbio<br /> (the last btrfs_bio) is sent to devices, that might be too late for earlier<br /> split btrfs_bio&amp;#39;s completion. That will result in NULL pointer<br /> dereference.<br /> <br /> That bug is easily reproducible by running btrfs/146 on zoned devices [1]<br /> and it shows the following trace.<br /> <br /> [1] You need raid-stripe-tree feature as it create "-d raid0 -m raid1" FS.<br /> <br /> BUG: kernel NULL pointer dereference, address: 0000000000000020<br /> #PF: supervisor read access in kernel mode<br /> #PF: error_code(0x0000) - not-present page<br /> PGD 0 P4D 0<br /> Oops: Oops: 0000 [#1] PREEMPT SMP PTI<br /> CPU: 1 UID: 0 PID: 13 Comm: kworker/u32:1 Not tainted 6.11.0-rc7-BTRFS-ZNS+ #474<br /> Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011<br /> Workqueue: writeback wb_workfn (flush-btrfs-5)<br /> RIP: 0010:btrfs_bio_end_io+0xae/0xc0 [btrfs]<br /> BTRFS error (device dm-0): bdev /dev/mapper/error-test errs: wr 2, rd 0, flush 0, corrupt 0, gen 0<br /> RSP: 0018:ffffc9000006f248 EFLAGS: 00010246<br /> RAX: 0000000000000000 RBX: ffff888005a7f080 RCX: ffffc9000006f1dc<br /> RDX: 0000000000000000 RSI: 000000000000000a RDI: ffff888005a7f080<br /> RBP: ffff888011dfc540 R08: 0000000000000000 R09: 0000000000000001<br /> R10: ffffffff82e508e0 R11: 0000000000000005 R12: ffff88800ddfbe58<br /> R13: ffff888005a7f080 R14: ffff888005a7f158 R15: ffff888005a7f158<br /> FS: 0000000000000000(0000) GS:ffff88803ea80000(0000) knlGS:0000000000000000<br /> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033<br /> CR2: 0000000000000020 CR3: 0000000002e22006 CR4: 0000000000370ef0<br /> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000<br /> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400<br /> Call Trace:<br /> <br /> ? __die_body.cold+0x19/0x26<br /> ? page_fault_oops+0x13e/0x2b0<br /> ? _printk+0x58/0x73<br /> ? do_user_addr_fault+0x5f/0x750<br /> ? exc_page_fault+0x76/0x240<br /> ? asm_exc_page_fault+0x22/0x30<br /> ? btrfs_bio_end_io+0xae/0xc0 [btrfs]<br /> ? btrfs_log_dev_io_error+0x7f/0x90 [btrfs]<br /> btrfs_orig_write_end_io+0x51/0x90 [btrfs]<br /> dm_submit_bio+0x5c2/0xa50 [dm_mod]<br /> ? find_held_lock+0x2b/0x80<br /> ? blk_try_enter_queue+0x90/0x1e0<br /> __submit_bio+0xe0/0x130<br /> ? ktime_get+0x10a/0x160<br /> ? lockdep_hardirqs_on+0x74/0x100<br /> submit_bio_noacct_nocheck+0x199/0x410<br /> btrfs_submit_bio+0x7d/0x150 [btrfs]<br /> btrfs_submit_chunk+0x1a1/0x6d0 [btrfs]<br /> ? lockdep_hardirqs_on+0x74/0x100<br /> ? __folio_start_writeback+0x10/0x2c0<br /> btrfs_submit_bbio+0x1c/0x40 [btrfs]<br /> submit_one_bio+0x44/0x60 [btrfs]<br /> submit_extent_folio+0x13f/0x330 [btrfs]<br /> ? btrfs_set_range_writeback+0xa3/0xd0 [btrfs]<br /> extent_writepage_io+0x18b/0x360 [btrfs]<br /> extent_write_locked_range+0x17c/0x340 [btrfs]<br /> ? __pfx_end_bbio_data_write+0x10/0x10 [btrfs]<br /> run_delalloc_cow+0x71/0xd0 [btrfs]<br /> btrfs_run_delalloc_range+0x176/0x500 [btrfs]<br /> ? find_lock_delalloc_range+0x119/0x260 [btrfs]<br /> writepage_delalloc+0x2ab/0x480 [btrfs]<br /> extent_write_cache_pages+0x236/0x7d0 [btrfs]<br /> btrfs_writepages+0x72/0x130 [btrfs]<br /> do_writepages+0xd4/0x240<br /> ? find_held_lock+0x2b/0x80<br /> ? wbc_attach_and_unlock_inode+0x12c/0x290<br /> ? wbc_attach_and_unlock_inode+0x12c/0x29<br /> ---truncated---

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.3 (including) 6.11.7 (excluding)
cpe:2.3:o:linux:linux_kernel:6.12:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc4:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.12:rc5:*:*:*:*:*:*