Skip to contentSkip to conversation

VMCI: Resource wildcard match fixed

PATCH In review Jorgen Hansen 2 participants 6 messages Sep 21, 2018 – Oct 9, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 VMCI: Resource wildcard match fixed

When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller.

Fixes bc63dedb7d46 ("VMCI: resource object implementation")
---
 drivers/misc/vmw_vmci/vmci_driver.c   | 2 +-
 drivers/misc/vmw_vmci/vmci_resource.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_driver.c +1 -1
index d7eaf1eb11e7..003bfba40758 100644
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
-MODULE_VERSION("1.1.5.0-k");
+MODULE_VERSION("1.1.6.0-k");
 MODULE_LICENSE("GPL v2");
drivers/misc/vmw_vmci/vmci_resource.c +2 -1
index 1ab6e8737a5f..da1ee2e1ba99 100644
@@ -57,7 +57,8 @@ static struct vmci_resource *vmci_resource_lookup(struct vmci_handle handle,
 
 		if (r->type == type &&
 		    rid == handle.resource &&
-		    (cid == handle.context || cid == VMCI_INVALID_ID)) {
+		    (cid == handle.context || cid == VMCI_INVALID_ID ||
+		     handle.context == VMCI_INVALID_ID)) {
 			resource = r;
 			break;
 		}
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 25 lines · Jorgen Hansen

When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller.

Fixes bc63dedb7d46 ("VMCI: resource object implementation")
---
 drivers/misc/vmw_vmci/vmci_driver.c   | 2 +-
 drivers/misc/vmw_vmci/vmci_resource.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_driver.c +0 -0
index d7eaf1eb11e7..003bfba40758 100644

drivers/misc/vmw_vmci/vmci_driver.c module_exit(vmci_drv_exit); · line 117

Quoted 6 lines
drivers/misc/vmw_vmci/vmci_driver.c +1 -1
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
-MODULE_VERSION("1.1.5.0-k");
+MODULE_VERSION("1.1.6.0-k");
 MODULE_LICENSE("GPL v2");

You do know MODULE_VERSION means nothing, right? Please just remove it.

thanks,

greg k-h

maintainer
#2 lore raw
In reply to Jorgen Hansen
Quoted 25 lines · Jorgen Hansen

When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller.

Fixes bc63dedb7d46 ("VMCI: resource object implementation")
---
 drivers/misc/vmw_vmci/vmci_driver.c   | 2 +-
 drivers/misc/vmw_vmci/vmci_resource.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_driver.c +0 -0
index d7eaf1eb11e7..003bfba40758 100644

drivers/misc/vmw_vmci/vmci_driver.c module_exit(vmci_drv_exit); · line 117

Quoted 6 lines
drivers/misc/vmw_vmci/vmci_driver.c +1 -1
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
-MODULE_VERSION("1.1.5.0-k");
+MODULE_VERSION("1.1.6.0-k");
 MODULE_LICENSE("GPL v2");

You do know MODULE_VERSION means nothing, right? Please just remove it.

thanks,

greg k-h

author Reviewed-by Adit Ranadive Reviewed-by Vishnu Dasa
#3 lore raw

On 3 Oct 2018, at 00:35, Greg KH <[email protected]<mailto:[email protected]>> wrote:

On Fri, Sep 21, 2018 at 12:31:05AM -0700, Jorgen Hansen wrote:
When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller.

---
drivers/misc/vmw_vmci/vmci_driver.c | 2 +-
drivers/misc/vmw_vmci/vmci_resource.c | 3 ++-

2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_driver.c +0 -0
index d7eaf1eb11e7..003bfba40758 100644
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
 

MODULE_AUTHOR("VMware, Inc.");
MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface."); -MODULE_VERSION("1.1.5.0-k");
+MODULE_VERSION("1.1.6.0-k");
MODULE_LICENSE("GPL v2");

You do know MODULE_VERSION means nothing, right? Please just remove it.

Sure. Do you want a new version of this patch with it removed ? (The reason for asking is that I already got a couple of notifications about the patch being added to char-misc and char-misc-next).

Thanks,
Jorgen

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

maintainer
#4 lore raw
Quoted 37 lines · Jorgen S. Hansen

On 3 Oct 2018, at 00:35, Greg KH <[email protected]<mailto:[email protected]>> wrote:

On Fri, Sep 21, 2018 at 12:31:05AM -0700, Jorgen Hansen wrote:
When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller.

---
drivers/misc/vmw_vmci/vmci_driver.c | 2 +-
drivers/misc/vmw_vmci/vmci_resource.c | 3 ++-

2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_driver.c +1 -1
index d7eaf1eb11e7..003bfba40758 100644
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
-MODULE_VERSION("1.1.5.0-k");
+MODULE_VERSION("1.1.6.0-k");
 MODULE_LICENSE("GPL v2");
Quoted 3 lines

You do know MODULE_VERSION means nothing, right? Please just remove it.

Sure. Do you want a new version of this patch with it removed ? (The reason for asking is that I already got a couple of notifications about the patch being added to char-misc and char-misc-next).

Just send a follow-on patch that removes it please.

thanks,

greg k-h

maintainer
#5 lore raw
In reply to Jorgen S. Hansen
Quoted 37 lines · Jorgen S. Hansen

On 3 Oct 2018, at 00:35, Greg KH <[email protected]<mailto:[email protected]>> wrote:

On Fri, Sep 21, 2018 at 12:31:05AM -0700, Jorgen Hansen wrote:
When adding a VMCI resource, the check for an existing entry would ignore that the new entry could be a wildcard. This could result in multiple resource entries that would match a given handle. One disastrous outcome of this is that the refcounting used to ensure that delayed callbacks for VMCI datagrams have run before the datagram is destroyed can be wrong, since the refcount could be increased on the duplicate entry. This in turn leads to a use after free bug. This issue was discovered by Hangbin Liu using KASAN and syzkaller.

---
drivers/misc/vmw_vmci/vmci_driver.c | 2 +-
drivers/misc/vmw_vmci/vmci_resource.c | 3 ++-

2 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/vmw_vmci/vmci_driver.c +1 -1
index d7eaf1eb11e7..003bfba40758 100644
@@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
 
 MODULE_AUTHOR("VMware, Inc.");
 MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
-MODULE_VERSION("1.1.5.0-k");
+MODULE_VERSION("1.1.6.0-k");
 MODULE_LICENSE("GPL v2");
Quoted 3 lines

You do know MODULE_VERSION means nothing, right? Please just remove it.

Sure. Do you want a new version of this patch with it removed ? (The reason for asking is that I already got a couple of notifications about the patch being added to char-misc and char-misc-next).

Just send a follow-on patch that removes it please.

thanks,

greg k-h