Skip to content

Commit 6922db2

Browse files
Stanislav Kinsburskiiliuw
authored andcommitted
mshv: Fix use-after-free in mshv_map_user_memory error path
In the error path of mshv_map_user_memory(), calling vfree() directly on the region leaves the MMU notifier registered. When userspace later unmaps the memory, the notifier fires and accesses the freed region, causing a use-after-free and potential kernel panic. Replace vfree() with mshv_partition_put() to properly unregister the MMU notifier before freeing the region. Fixes: b9a66cd ("mshv: Add support for movable memory regions") Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 0fc773b commit 6922db2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/hv/mshv_root_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
13471347
return 0;
13481348

13491349
errout:
1350-
vfree(region);
1350+
mshv_region_put(region);
13511351
return ret;
13521352
}
13531353

0 commit comments

Comments
 (0)