Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Originally I was checking dr->dr_dbuf->db_level == 0 in dbuf_dirty_is_direct_write(). Howver, this can lead to a NULL ponter dereference if the dr_dbuf is no longer set. I updated dbuf_dirty_is_direct_write() to now also take a dmu_buf_impl_t to check if db->db_level == 0. This failure was caught on the Fedora 37 CI running in test enospc_rm. Below is the stack trace. [ 9851.511608] BUG: kernel NULL pointer dereference, address: 0000000000000068 [ 9851.515922] #PF: supervisor read access in kernel mode [ 9851.519462] #PF: error_code(0x0000) - not-present page [ 9851.522992] PGD 0 P4D 0 [ 9851.525684] Oops: 0000 [openzfs#1] PREEMPT SMP PTI [ 9851.528878] CPU: 0 PID: 1272993 Comm: fio Tainted: P OE 6.5.12-100.fc37.x86_64 openzfs#1 [ 9851.535266] Hardware name: Amazon EC2 m5d.large/, BIOS 1.0 10/16/2017 [ 9851.539226] RIP: 0010:dbuf_dirty_is_direct_write+0xb/0x40 [zfs] [ 9851.543379] Code: 10 74 02 31 c0 5b c3 cc cc cc cc 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 31 c0 48 85 ff 74 31 48 8b 57 20 <80> 7a 68 00 75 27 8b 87 64 01 00 00 85 c0 75 1b 83 bf 58 01 00 00 [ 9851.554719] RSP: 0018:ffff9b5b8305f8e8 EFLAGS: 00010286 [ 9851.558276] RAX: 0000000000000000 RBX: ffff9b5b8569b0b8 RCX: 0000000000000000 [ 9851.562481] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8f2e97de9e00 [ 9851.566672] RBP: 0000000000020000 R08: 0000000000000000 R09: ffff8f2f70e94000 [ 9851.570851] R10: 0000000000000001 R11: 0000000000000110 R12: ffff8f2f774ae4c0 [ 9851.575032] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 [ 9851.579209] FS: 00007f57c5542240(0000) GS:ffff8f2faa800000(0000) knlGS:0000000000000000 [ 9851.585357] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 9851.589064] CR2: 0000000000000068 CR3: 00000001f9a38001 CR4: 00000000007706f0 [ 9851.593256] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 9851.597440] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 9851.601618] PKRU: 55555554 [ 9851.604341] Call Trace: [ 9851.606981] <TASK> [ 9851.609515] ? __die+0x23/0x70 [ 9851.612388] ? page_fault_oops+0x171/0x4e0 [ 9851.615571] ? exc_page_fault+0x77/0x170 [ 9851.618704] ? asm_exc_page_fault+0x26/0x30 [ 9851.621900] ? dbuf_dirty_is_direct_write+0xb/0x40 [zfs] [ 9851.625828] zfs_get_data+0x407/0x820 [zfs] [ 9851.629400] zil_lwb_commit+0x18d/0x3f0 [zfs] [ 9851.633026] zil_lwb_write_issue+0x92/0xbb0 [zfs] [ 9851.636758] zil_commit_waiter_timeout+0x1f3/0x580 [zfs] [ 9851.640696] zil_commit_waiter+0x1ff/0x3a0 [zfs] [ 9851.644402] zil_commit_impl+0x71/0xd0 [zfs] [ 9851.647998] zfs_write+0xb51/0xdc0 [zfs] [ 9851.651467] zpl_iter_write_buffered+0xc9/0x140 [zfs] [ 9851.655337] zpl_iter_write+0xc0/0x110 [zfs] [ 9851.658920] vfs_write+0x23e/0x420 [ 9851.661871] __x64_sys_pwrite64+0x98/0xd0 [ 9851.665013] do_syscall_64+0x5f/0x90 [ 9851.668027] ? ksys_fadvise64_64+0x57/0xa0 [ 9851.671212] ? syscall_exit_to_user_mode+0x2b/0x40 [ 9851.674594] ? do_syscall_64+0x6b/0x90 [ 9851.677655] ? syscall_exit_to_user_mode+0x2b/0x40 [ 9851.681051] ? do_syscall_64+0x6b/0x90 [ 9851.684128] ? exc_page_fault+0x77/0x170 [ 9851.687256] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 9851.690759] RIP: 0033:0x7f57c563c377 Signed-off-by: Brian Atkinson <[email protected]>
- Loading branch information