Skip to contentSkip to conversation

Out off array access in usb-net

PATCH Applied Gleb Natapov 4 participants 10 messages Nov 9, 2010 – Nov 16, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Out off array access in usb-net

Properly check array bounds before accessing array element.

hw/usb-net.c +1 -1
index 70f9263..84e2d79 100644
@@ -1142,7 +1142,7 @@ static int usb_net_handle_control(USBDevice *dev, int request, int value,
                 break;
 
             default:
-                if (usb_net_stringtable[value & 0xff]) {
+                if (ARRAY_SIZE(usb_net_stringtable) > (value & 0xff)) {
                     ret = set_usb_string(data,
                                     usb_net_stringtable[value & 0xff]);
                     break;

--
Gleb.

Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Gleb Natapov

Properly check array bounds before accessing array element.

hw/usb-net.c +1 -2
index 70f9263..84e2d79 100644
@@ -1142,7 +1142,7 @@ static int usb_net_handle_control(USBDevice *dev, int request, int value,
                  break;
 
              default:
-                if (usb_net_stringtable[value&  0xff]) {
+                if (ARRAY_SIZE(usb_net_stringtable)>  (value&  0xff)) {
                      ret = set_usb_string(data,
                                      usb_net_stringtable[value&  0xff]);
                      break;
--
Quoted 2 lines

Gleb.

Paolo

#2 lore raw
In reply to Gleb Natapov
Quoted 1 line · Gleb Natapov

Properly check array bounds before accessing array element.

Impact?

Apply to stable as well?

Quoted 6 lines
hw/usb-net.c +0 -0
index 70f9263..84e2d79 100644

hw/usb-net.c static int usb_net_handle_control(USBDevice *dev, int request, int value, · line 1148

Quoted 8 lines
hw/usb-net.c +1 -1
@@ -1142,7 +1142,7 @@ static int usb_net_handle_control(USBDevice *dev, int request, int value,
                 break;
 
             default:
-                if (usb_net_stringtable[value & 0xff]) {
+                if (ARRAY_SIZE(usb_net_stringtable) > (value & 0xff)) {
                     ret = set_usb_string(data,
                                     usb_net_stringtable[value & 0xff]);
                     break;

Makes sense.

Nitpick: LIMIT > INDEX looks unusual to me; INDEX < LIMIT is more common.

#3 lore raw
Quoted 6 lines · Markus Armbruster
Quoted 1 line · Gleb Natapov

Properly check array bounds before accessing array element.

Impact?

Gapping security hole for those unfortunate enough to use usb-net?

Quoted 2 lines

Apply to stable as well?

Definitely. Actually for me Windows7 crashed when usb-net is present.

Quoted 17 lines
Quoted 6 lines
hw/usb-net.c +0 -0
index 70f9263..84e2d79 100644

hw/usb-net.c static int usb_net_handle_control(USBDevice *dev, int request, int value, · line 1148

Quoted 8 lines
hw/usb-net.c +1 -1
@@ -1142,7 +1142,7 @@ static int usb_net_handle_control(USBDevice *dev, int request, int value,
                 break;
 
             default:
-                if (usb_net_stringtable[value & 0xff]) {
+                if (ARRAY_SIZE(usb_net_stringtable) > (value & 0xff)) {
                     ret = set_usb_string(data,
                                     usb_net_stringtable[value & 0xff]);
                     break;

Makes sense.

Quoted 2 lines

Nitpick: LIMIT > INDEX looks unusual to me; INDEX < LIMIT is more common.

--
Gleb.

#4 lore raw
Quoted 8 lines · Gleb Natapov
Quoted 6 lines · Markus Armbruster
Quoted 1 line · Gleb Natapov

Properly check array bounds before accessing array element.

Impact?

Gapping security hole for those unfortunate enough to use usb-net?

Doesn't that bit of information belong in the commit message.

Quoted 3 lines
Quoted 2 lines

Apply to stable as well?

Definitely. Actually for me Windows7 crashed when usb-net is present.

And that as well.

Good catch!

#5 lore raw
Quoted 5 lines · Markus Armbruster
Quoted 3 lines · Gleb Natapov
Quoted 2 lines · Markus Armbruster

Gleb Natapov <[email protected]> writes:

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Properly check array bounds before accessing array element.

Impact?

Gapping security hole for those unfortunate enough to use usb-net?

Doesn't that bit of information belong in the commit message.

Some people prefer not to put such information into commit message.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

Apply to stable as well?

Definitely. Actually for me Windows7 crashed when usb-net is present.

And that as well.

Good catch!

--
Gleb.

#6 lore raw
Quoted 8 lines · Gleb Natapov
Quoted 7 lines · Markus Armbruster
Quoted 5 lines · Gleb Natapov
Quoted 4 lines · Markus Armbruster
Quoted 1 line · Gleb Natapov

Properly check array bounds before accessing array element.

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

Impact?

Gapping security hole for those unfortunate enough to use usb-net?

Doesn't that bit of information belong in the commit message.

Some people prefer not to put such information into commit message.

Correct, but does "some people" include the QEMU maintainers? Anthony?

[...]

#7 lore raw
Quoted 18 lines · Markus Armbruster
Quoted 15 lines · Gleb Natapov
Quoted 13 lines · Markus Armbruster
Quoted 10 lines · Gleb Natapov
Quoted 8 lines · Markus Armbruster
Quoted 2 lines · Gleb Natapov

Properly check array bounds before accessing array element.

Impact?

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Gapping security hole for those unfortunate enough to use usb-net?

Doesn't that bit of information belong in the commit message.

Some people prefer not to put such information into commit message.

Correct, but does "some people" include the QEMU maintainers? Anthony?

I don't have a strong opinion either way. If there's a CVE, I'd prefer the CVE number was prominent in the commit log but other than that, I'd leave it to the author's discretion.

Regards,

Anthony Liguori

Quoted 4 lines

[...]

#8 lore raw
Quoted 13 lines · Anthony Liguori
Quoted 12 lines · Markus Armbruster
Quoted 10 lines · Gleb Natapov
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Gleb Natapov
Quoted 5 lines · Markus Armbruster
Quoted 1 line · Gleb Natapov

Properly check array bounds before accessing array element.

Impact?

Gapping security hole for those unfortunate enough to use usb-net?

Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Doesn't that bit of information belong in the commit message.

Some people prefer not to put such information into commit message.

Correct, but does "some people" include the QEMU maintainers? Anthony?

I don't have a strong opinion either way. If there's a CVE, I'd prefer the CVE number was prominent in the commit log but other than that, I'd leave it to the author's discretion.

No CVE. Please apply as is.

--
Gleb.

#9 lore raw
In reply to Gleb Natapov
Quoted 4 lines · Gleb Natapov

Properly check array bounds before accessing array element.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 18 lines
hw/usb-net.c +1 -2
index 70f9263..84e2d79 100644
@@ -1142,7 +1142,7 @@ static int usb_net_handle_control(USBDevice *dev, int request, int value,
                  break;
 
              default:
-                if (usb_net_stringtable[value&  0xff]) {
+                if (ARRAY_SIZE(usb_net_stringtable)>  (value&  0xff)) {
                      ret = set_usb_string(data,
                                      usb_net_stringtable[value&  0xff]);
                      break;
--

Gleb.