aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorJorgen Hansen <jhansen@vmware.com>2015-01-14 14:10:19 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-25 12:18:00 -0500
commita1d88436d53a75e950db15834b3d2f8c0c358fdc (patch)
treea1c852aa45acec5f487e0d61706b7dbe57eaea90 /drivers/misc
parent3f46d81ae1cf8f20f25c39ae1ab3f1b064698361 (diff)
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 <acking@vmware.com> Acked-by: Darius Davis <darius@vmware.com> Signed-off-by: Jorgen Hansen <jhansen@vmware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/vmw_vmci/vmci_driver.c2
-rw-r--r--drivers/misc/vmw_vmci/vmci_host.c13
2 files changed, 8 insertions, 7 deletions
diff --git a/drivers/misc/vmw_vmci/vmci_driver.c b/drivers/misc/vmw_vmci/vmci_driver.c
index 3dee7ae123e7..032d35cf93ca 100644
--- a/drivers/misc/vmw_vmci/vmci_driver.c
+++ b/drivers/misc/vmw_vmci/vmci_driver.c
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
113 113
114MODULE_AUTHOR("VMware, Inc."); 114MODULE_AUTHOR("VMware, Inc.");
115MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface."); 115MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
116MODULE_VERSION("1.1.0.0-k"); 116MODULE_VERSION("1.1.1.0-k");
117MODULE_LICENSE("GPL v2"); 117MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/vmw_vmci/vmci_host.c b/drivers/misc/vmw_vmci/vmci_host.c
index 1723a6e4f2e8..66fc9921fc85 100644
--- a/drivers/misc/vmw_vmci/vmci_host.c
+++ b/drivers/misc/vmw_vmci/vmci_host.c
@@ -218,13 +218,12 @@ static int drv_cp_harray_to_user(void __user *user_buf_uva,
218} 218}
219 219
220/* 220/*
221 * Sets up a given context for notify to work. Calls drv_map_bool_ptr() 221 * Sets up a given context for notify to work. Maps the notify
222 * which maps the notify boolean in user VA in kernel space. 222 * boolean in user VA into kernel space.
223 */ 223 */
224static int vmci_host_setup_notify(struct vmci_ctx *context, 224static int vmci_host_setup_notify(struct vmci_ctx *context,
225 unsigned long uva) 225 unsigned long uva)
226{ 226{
227 struct page *page;
228 int retval; 227 int retval;
229 228
230 if (context->notify_page) { 229 if (context->notify_page) {
@@ -243,14 +242,16 @@ static int vmci_host_setup_notify(struct vmci_ctx *context,
243 /* 242 /*
244 * Lock physical page backing a given user VA. 243 * Lock physical page backing a given user VA.
245 */ 244 */
246 retval = get_user_pages_fast(PAGE_ALIGN(uva), 1, 1, &page); 245 retval = get_user_pages_fast(uva, 1, 1, &context->notify_page);
247 if (retval != 1) 246 if (retval != 1) {
247 context->notify_page = NULL;
248 return VMCI_ERROR_GENERIC; 248 return VMCI_ERROR_GENERIC;
249 }
249 250
250 /* 251 /*
251 * Map the locked page and set up notify pointer. 252 * Map the locked page and set up notify pointer.
252 */ 253 */
253 context->notify = kmap(page) + (uva & (PAGE_SIZE - 1)); 254 context->notify = kmap(context->notify_page) + (uva & (PAGE_SIZE - 1));
254 vmci_ctx_check_signal_notify(context); 255 vmci_ctx_check_signal_notify(context);
255 256
256 return VMCI_SUCCESS; 257 return VMCI_SUCCESS;