nbd/client: fix drop_sync [CVE-2017-2630]
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]>
---
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
@@ -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
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.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>Message-Id: <[email protected]>
[eblake: add CVE details]Signed-off-by Eric Blake <[email protected]>Reviewed-by Marc-André Lureau <address@hidden>---
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.htmlnbd/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)nbd/client.c +0
-0
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
-0while (size >0 ) {ssize_t count =read_sync (ioc, buffer,MIN (65536 , size));
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.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>Message-Id: <[email protected]>
[eblake: add CVE details]Signed-off-by Eric Blake <[email protected]>Reviewed-by Marc-André Lureau <address@hidden>---
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.htmlnbd/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)nbd/client.c +0
-0@@ -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
-0while (size >0 ) {ssize_t count =read_sync (ioc, buffer,MIN (65536 , size));
Signature · 2 lines
Best regards, Vladimir
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.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>Message-Id: <[email protected]>
[eblake: add CVE details]Signed-off-by Eric Blake <[email protected]>Reviewed-by Marc-André Lureau <address@hidden>
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