Skip to contentSkip to conversation

nbd/client: fix drop_sync [CVE-2017-2630]

PATCH Superseded Eric Blake 3 participants 4 messages Mar 6, 2017 – Mar 7, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 nbd/client: fix drop_sync [CVE-2017-2630]

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Comparison symbol is misused. It may lead to memory corruption. Introduced in commit 7d3123e.

Message-Id: <[email protected]>

[eblake: add CVE details]

---

This one still hasn't been merged in; sending separately since the rest of my NBD series is now 2.10 material:
https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg04528.html

 nbd/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nbd/client.c +1 -1
index 5c9dee3..165b33e 100644
@@ -94,7 +94,7 @@ static ssize_t drop_sync(QIOChannel *ioc, size_t size)
     char small[1024];
     char *buffer;
 
-    buffer = sizeof(small) < size ? small : g_malloc(MIN(65536, size));
+    buffer = sizeof(small) > size ? small : g_malloc(MIN(65536, size));
     while (size > 0) {
         ssize_t count = read_sync(ioc, buffer, MIN(65536, size));
 
Signature · 1 line
2.9.3
#1 lore raw

Hi Vladimir,

Quoted 24 lines · Eric Blake

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Comparison symbol is misused. It may lead to memory corruption. Introduced in commit 7d3123e.

Message-Id: <[email protected]>

[eblake: add CVE details]

---

This one still hasn't been merged in; sending separately since the rest of my NBD series is now 2.10 material:
https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg04528.html

 nbd/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nbd/client.c +0 -0
index 5c9dee3..165b33e 100644

nbd/client.c static ssize_t drop_sync(QIOChannel *ioc, size_t size) · line 97

Quoted 5 lines
nbd/client.c +1 -1
@@ -94,7 +94,7 @@ static ssize_t drop_sync(QIOChannel *ioc, size_t size)
     char small[1024];
     char *buffer;
 
-    buffer = sizeof(small) < size ? small : g_malloc(MIN(65536, size));
+    buffer = sizeof(small) > size ? small : g_malloc(MIN(65536, size));

here ">=" seems correct/safe.
(if size is 1024, use small stack buffer too).

Quoted 3 lines
nbd/client.c +0 -0
     while (size > 0) {
         ssize_t count = read_sync(ioc, buffer, MIN(65536, size));
 
#2 lore raw
Quoted 30 lines · Philippe Mathieu-Daudé

Hi Vladimir,

Quoted 27 lines · Eric Blake

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Comparison symbol is misused. It may lead to memory corruption. Introduced in commit 7d3123e.

Message-Id: <[email protected]>

[eblake: add CVE details]

---

This one still hasn't been merged in; sending separately since the rest of my NBD series is now 2.10 material:
https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg04528.html

 nbd/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nbd/client.c +0 -0
index 5c9dee3..165b33e 100644
@@ -94,7 +94,7 @@ static ssize_t drop_sync(QIOChannel *ioc, size_t size)
     char small[1024];
     char *buffer;
 
Quoted 5 lines

nbd/client.c static ssize_t drop_sync(QIOChannel *ioc, size_t size) · line 97

Quoted 2 lines
nbd/client.c +1 -1
-    buffer = sizeof(small) < size ? small : g_malloc(MIN(65536, size));
+    buffer = sizeof(small) > size ? small : g_malloc(MIN(65536, size));

here ">=" seems correct/safe.
(if size is 1024, use small stack buffer too).

Agree.

Quoted 4 lines
Quoted 4 lines
nbd/client.c +0 -0
     while (size > 0) {
         ssize_t count = read_sync(ioc, buffer, MIN(65536, size));
 
Signature · 2 lines
Best regards,
Vladimir
author
#3 lore raw
In reply to Eric Blake
Quoted 10 lines · Eric Blake

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Comparison symbol is misused. It may lead to memory corruption. Introduced in commit 7d3123e.

Message-Id: <[email protected]>

[eblake: add CVE details]

Blergh. This R-b isn't correct.

Sending v2 with fixed attributions, and with >= instead of >.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org