Skip to content

Commit a1d8843

Browse files
Jorgen Hansengregkh
authored andcommitted
VMCI: Fix two UVA mapping bugs
(this is a resend of this patch. Originally sent last year, but post appears to have been lost) This change fixes two bugs in the VMCI host driver related to mapping the notify boolean from user space into kernel space: - the actual UVA was rounded up to the next page boundary - resulting in memory corruption in the calling process whenever notifications would be signalled. This has been fixed by just removing the PAGE_ALIGN part, since get_user_pages_fast can figure this out on its own - the mapped page wasn't stored anywhere, so it wasn't unmapped and put back when a VMCI context was destroyed. Fixed this by remembering the page. Acked-by: Andy King <[email protected]> Acked-by: Darius Davis <[email protected]> Signed-off-by: Jorgen Hansen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3f46d81 commit a1d8843

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

drivers/misc/vmw_vmci/vmci_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
113113

114114
MODULE_AUTHOR("VMware, Inc.");
115115
MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
116-
MODULE_VERSION("1.1.0.0-k");
116+
MODULE_VERSION("1.1.1.0-k");
117117
MODULE_LICENSE("GPL v2");

drivers/misc/vmw_vmci/vmci_host.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,12 @@ static int drv_cp_harray_to_user(void __user *user_buf_uva,
218218
}
219219

220220
/*
221-
* Sets up a given context for notify to work. Calls drv_map_bool_ptr()
222-
* which maps the notify boolean in user VA in kernel space.
221+
* Sets up a given context for notify to work. Maps the notify
222+
* boolean in user VA into kernel space.
223223
*/
224224
static int vmci_host_setup_notify(struct vmci_ctx *context,
225225
unsigned long uva)
226226
{
227-
struct page *page;
228227
int retval;
229228

230229
if (context->notify_page) {
@@ -243,14 +242,16 @@ static int vmci_host_setup_notify(struct vmci_ctx *context,
243242
/*
244243
* Lock physical page backing a given user VA.
245244
*/
246-
retval = get_user_pages_fast(PAGE_ALIGN(uva), 1, 1, &page);
247-
if (retval != 1)
245+
retval = get_user_pages_fast(uva, 1, 1, &context->notify_page);
246+
if (retval != 1) {
247+
context->notify_page = NULL;
248248
return VMCI_ERROR_GENERIC;
249+
}
249250

250251
/*
251252
* Map the locked page and set up notify pointer.
252253
*/
253-
context->notify = kmap(page) + (uva & (PAGE_SIZE - 1));
254+
context->notify = kmap(context->notify_page) + (uva & (PAGE_SIZE - 1));
254255
vmci_ctx_check_signal_notify(context);
255256

256257
return VMCI_SUCCESS;

0 commit comments

Comments
 (0)