syzbot
WARNING in vfree
Status:
upstream: reported C repro on 2026/11/26 09:25
Subsystems:
dm
Labels:
prio:normal
[Documentation on labels]
Reported-by: syzbot+1eda626824b6334f5ad3@syzkaller.appspotmail.com
First crash: 4d01h, last: 1d08h
✨ AI-generated root cause summary:
In drivers/md/dm-snap-persistent.c, alloc_area() allocates three vmalloc buffers (ps->area, ps->zero_area, and ps->header_area) for struct pstore. When allocating ps->zero_area or ps->header_area fails (such as under memory pressure), the error path calls vfree() on the already-allocated buffer(s) and returns -ENOMEM without resetting ps->area (or ps->zero_area) to NULL. On failure of persistent_read_metadata(), snapshot_ctr() tears down the exception store via dm_exception_store_destroy() -> persistent_dtr() -> free_area(), which invokes vfree() on the dangling ps->area (and ps->zero_area) pointer a second time.
▶
▼
✨ Full AI root cause analysis
Root Cause
The bug is a double-free (vfree()) on error handling in alloc_area() in drivers/md/dm-snap-persistent.c.
Mechanism
- During snapshot target construction,
snapshot_ctr() (drivers/md/dm-snap.c:1389) invokes s->store->type->read_metadata(), which for persistent snapshots is persistent_read_metadata() (drivers/md/dm-snap-persistent.c:612).
persistent_read_metadata() calls read_header() (drivers/md/dm-snap-persistent.c:306), which calls alloc_area(ps) (drivers/md/dm-snap-persistent.c:170, called at lines 334 and 378) to allocate three vmalloc() buffers on struct pstore *ps:
ps->area = vmalloc(len); (line 181)
ps->zero_area = vzalloc(len); (line 185)
ps->header_area = vmalloc(len); (line 189)
- If
ps->area succeeds (e.g., at 0xffffc9000e259000) and either ps->zero_area or ps->header_area fails allocation (such as under memory pressure, as indicated by the preceding Mem-Info: dump), alloc_area() jumps to err_zero_area or err_header_area (drivers/md/dm-snap-persistent.c:195-202):
err_header_area calls vfree(ps->zero_area) and falls through to err_zero_area.
err_zero_area calls vfree(ps->area) and returns -ENOMEM.
- Neither error label clears
ps->area or ps->zero_area to NULL (nor does alloc_area() call free_area(ps)), leaving dangling vmalloc pointers stored in struct pstore.
read_header() and persistent_read_metadata() propagate -ENOMEM back to snapshot_ctr(), which jumps to bad_read_metadata and cleans up via dm_exception_store_destroy(s->store) (drivers/md/dm-snap.c:1421).
dm_exception_store_destroy() (drivers/md/dm-exception-store.c:257) calls persistent_dtr() (drivers/md/dm-snap-persistent.c:595), which calls free_area(ps) (drivers/md/dm-snap-persistent.c:205):
vfree(ps->area);
ps->area = NULL;
vfree(ps->zero_area);
ps->zero_area = NULL;
vfree(ps->header_area);
ps->header_area = NULL;
Because ps->area (and ps->zero_area, if header_area failed) was not reset to NULL in alloc_area(), free_area() calls vfree() a second time on the already-freed vmalloc address, triggering the Trying to vfree() nonexistent vm area warning at mm/vmalloc.c:3539.
Violated Invariant
struct pstore expects ps->area, ps->zero_area, and ps->header_area to be NULL whenever they do not own an active vmalloc allocation (as initialized in persistent_ctr() and maintained by free_area()), so that persistent_dtr() can unconditionally call free_area(ps). alloc_area() violates this invariant on partial allocation failure by freeing the pointers without nullifying them.
▶
▼
Last patch testing requests (1)
Sample crash report:
------------[ cut here ]------------
Trying to vfree() nonexistent vm area (ffffc90024410000)
WARNING: mm/vmalloc.c:3540 at vfree+0x463/0x490 mm/vmalloc.c:3539, CPU#0: syz-executor415/5665
Modules linked in:
CPU: 0 UID: 0 PID: 5665 Comm: syz-executor415 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:vfree+0x466/0x490 mm/vmalloc.c:3539
Code: e8 1f d6 98 ff 4c 89 f7 48 83 c4 10 5b 41 5c 41 5d 41 5e 41 5f 5d e9 19 f9 ff ff e8 04 d6 98 ff 48 8d 3d 4d e3 92 0f 4c 89 f6 <67> 48 0f b9 3a e9 42 fd ff ff e8 eb d5 98 ff 4c 89 e7 e8 23 00 00
RSP: 0018:ffffc9000364f868 EFLAGS: 00010293
RAX: ffffffff82307c2c RBX: 0000000000000000 RCX: ffff88803d920000
RDX: 0000000000000000 RSI: ffffc90024410000 RDI: ffffffff91c35f80
RBP: ffffc9000364fa38 R08: ffffffff9bf28a83 R09: 1ffffffff37e5150
R10: dffffc0000000000 R11: fffffbfff37e5151 R12: 1ffff1100277eb03
R13: ffff88800c1c1898 R14: ffffc90024410000 R15: 00000000ff00ff00
FS: 000055558a755400(0000) GS:ffff88808a9e9000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f23c5db2bd0 CR3: 000000003f9e6000 CR4: 0000000000352ef0
Call Trace:
<TASK>
free_area drivers/md/dm-snap-persistent.c:207 [inline]
persistent_dtr+0xb2/0x170 drivers/md/dm-snap-persistent.c:604
dm_exception_store_destroy+0x5c/0xc0 drivers/md/dm-exception-store.c:257
snapshot_ctr+0x10a0/0x1380 drivers/md/dm-snap.c:1421
dm_table_add_target+0x58d/0xc70 drivers/md/dm-table.c:765
populate_table drivers/md/dm-ioctl.c:1602 [inline]
table_load+0x325/0x8a0 drivers/md/dm-ioctl.c:1645
ctl_ioctl drivers/md/dm-ioctl.c:2221 [inline]
dm_ctl_ioctl+0x9ec/0xe10 drivers/md/dm-ioctl.c:2243
vfs_ioctl fs/ioctl.c:52 [inline]
__do_sys_ioctl fs/ioctl.c:598 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:584
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7ffb7fb0744b
Code: Unable to access opcode bytes at 0x7ffb7fb07421.
RSP: 002b:00007ffe9db1e5a0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007ffb7fb0744b
RDX: 00007ffe9db1e600 RSI: 00000000c138fd09 RDI: 0000000000000003
RBP: 0000000000000008 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffe9db1e760
R13: 00007ffe9db1f640 R14: 00007ffe9db1f660 R15: 00007ffe9db1f6b0
</TASK>
----------------
Code disassembly (best guess):
0: e8 1f d6 98 ff call 0xff98d624
5: 4c 89 f7 mov %r14,%rdi
8: 48 83 c4 10 add $0x10,%rsp
c: 5b pop %rbx
d: 41 5c pop %r12
f: 41 5d pop %r13
11: 41 5e pop %r14
13: 41 5f pop %r15
15: 5d pop %rbp
16: e9 19 f9 ff ff jmp 0xfffff934
1b: e8 04 d6 98 ff call 0xff98d624
20: 48 8d 3d 4d e3 92 0f lea 0xf92e34d(%rip),%rdi # 0xf92e374
27: 4c 89 f6 mov %r14,%rsi
* 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction
2f: e9 42 fd ff ff jmp 0xfffffd76
34: e8 eb d5 98 ff call 0xff98d624
39: 4c 89 e7 mov %r12,%rdi
3c: e8 .byte 0xe8
3d: 23 00 and (%rax),%eax
* Struck through repros no longer work on HEAD.