alloc_area() frees ps->area and ps->zero_area when a later allocation
fails, but leaves the pointers set. persistent_read_metadata() then
returns -ENOMEM, snapshot_ctr() aborts and dm_exception_store_destroy()
calls persistent_dtr() -> free_area(), which vfree()s the same areas
again:
Trying to vfree() nonexistent vm area (ffffc90024410000)
WARNING: mm/vmalloc.c:3539 at vfree+0x463/0x490
Clear each pointer after freeing it so free_area() is safe on the
partial-allocation error path.
Fixes: 7c9e6c17325f ("dm exception store: refactor zero_area")
Reported-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?extid=1eda626824b6334f5ad3
Cc: [email protected]
Signed-off-by: Ruiqiang Hao <[email protected]>
---
drivers/md/dm-snap-persistent.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index b587ee733056..9f5ade4f51ce 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -194,9 +194,11 @@ static int alloc_area(struct pstore *ps)
err_header_area:
vfree(ps->zero_area);
+ ps->zero_area = NULL;
err_zero_area:
vfree(ps->area);
+ ps->area = NULL;
err_area:
return r;
--
2.43.0