Skip to contentSkip to conversation

x86/hvm/ioreq: fix out of bounds access in error path

PATCH In review Wei Liu 3 participants 3 messages Apr 4, 2018

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 x86/hvm/ioreq: fix out of bounds access in error path

It is possible to call the error path with i pointing beyond the end of the array.

There is another bug that if there is already a default ioreq server, the code will actually sets the element to NULL, hence leaking memory.

Move setting NULL to where it is needed.

Coverity-ID: 1433777

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/hvm/ioreq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/ioreq.c +3 -2
index 9435291e87..2275278305 100644
@@ -811,7 +811,10 @@ int hvm_create_ioreq_server(struct domain *d, bool is_default,
 
     rc = hvm_ioreq_server_init(s, d, bufioreq_handling, i);
     if ( rc )
+    {
+        set_ioreq_server(d, i, NULL);
         goto fail;
+    }
 
     if ( i == DEFAULT_IOSERVID )
         hvm_ioreq_server_enable(s);
@@ -825,8 +828,6 @@ int hvm_create_ioreq_server(struct domain *d, bool is_default,
     return 0;
 
  fail:
-    set_ioreq_server(d, i, NULL);
-
     spin_unlock_recursive(&d->arch.hvm_domain.ioreq_server.lock);
     domain_unpause(d);
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines

-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 04 April 2018 12:03
To: Xen-devel <[email protected]>
Cc: Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH] x86/hvm/ioreq: fix out of bounds access in error path

It is possible to call the error path with i pointing beyond the end of the array.

Quoted 7 lines

There is another bug that if there is already a default ioreq server, the code will actually sets the element to NULL, hence leaking memory.

Move setting NULL to where it is needed.

Coverity-ID: 1433777

Quoted 35 lines

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/arch/x86/hvm/ioreq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/ioreq.c +3 -0
index 9435291e87..2275278305 100644
@@ -811,7 +811,10 @@ int hvm_create_ioreq_server(struct domain *d, bool
 is_default,
 
     rc = hvm_ioreq_server_init(s, d, bufioreq_handling, i);
     if ( rc )
+    {
+        set_ioreq_server(d, i, NULL);
         goto fail;
+    }
 
     if ( i == DEFAULT_IOSERVID )
         hvm_ioreq_server_enable(s);
xen/arch/x86/hvm/ioreq.c +0 -3
@@ -825,8 +828,6 @@ int hvm_create_ioreq_server(struct domain *d, bool
 is_default,
     return 0;
 
  fail:
-    set_ioreq_server(d, i, NULL);
-
     spin_unlock_recursive(&d->arch.hvm_domain.ioreq_server.lock);
     domain_unpause(d);
 
--
Quoted 1 line

2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by
#2 lore raw
Quoted 12 lines · Paul Durrant
Quoted 12 lines

-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 04 April 2018 12:03
To: Xen-devel <[email protected]>
Cc: Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH] x86/hvm/ioreq: fix out of bounds access in error path

It is possible to call the error path with i pointing beyond the end of the array.

Quoted 8 lines
Quoted 7 lines

There is another bug that if there is already a default ioreq server, the code will actually sets the element to NULL, hence leaking memory.

Move setting NULL to where it is needed.

Coverity-ID: 1433777

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel