Skip to content

Commit 34861bd

Browse files
Stanislav Kinsburskiigregkh
authored andcommitted
mshv: Fix use-after-free in mshv_map_user_memory error path
[ Upstream commit 6922db2 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ac3e12b commit 34861bd

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
@@ -1334,7 +1334,7 @@ mshv_map_user_memory(struct mshv_partition *partition,
13341334
return 0;
13351335

13361336
errout:
1337-
vfree(region);
1337+
mshv_region_put(region);
13381338
return ret;
13391339
}
13401340

0 commit comments

Comments
 (0)