Skip to contentSkip to conversation

qapi: Fix potential NULL pointer segfault

PATCH Applied Stefan Weil 3 participants 5 messages Sep 1, 2012 – Sep 3, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qapi: Fix potential NULL pointer segfault

Report from smatch:

qapi-visit.c:1640 visit_type_BlockdevAction(8) error:
we previously assumed 'obj' could be null (see line 1639)
qapi-visit.c:2432 visit_type_NetClientOptions(8) error:
we previously assumed 'obj' could be null (see line 2431)

---
 scripts/qapi-visit.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qapi-visit.py +1 -1
index 2afc5c0..1a669f3 100644
@@ -157,7 +157,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
     if (!error_is_set(errp)) {
         visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
         if (!err) {
-            if (!obj || *obj) {
+            if (obj && *obj) {
                 visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err);
                 if (!err) {
                     switch ((*obj)->kind) {
Signature · 1 line
1.7.10
Reviewed-by on v1 1/1
#1 lore raw

Il 01/09/2012 09:30, Stefan Weil ha scritto:

Quoted 18 lines

Report from smatch:

qapi-visit.c:1640 visit_type_BlockdevAction(8) error:
we previously assumed 'obj' could be null (see line 1639)
qapi-visit.c:2432 visit_type_NetClientOptions(8) error:
we previously assumed 'obj' could be null (see line 2431)

---
 scripts/qapi-visit.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qapi-visit.py +0 -0
index 2afc5c0..1a669f3 100644

scripts/qapi-visit.py void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** · line 163

Quoted 8 lines
scripts/qapi-visit.py +1 -1
@@ -157,7 +157,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
     if (!error_is_set(errp)) {
         visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
         if (!err) {
-            if (!obj || *obj) {
+            if (obj && *obj) {
                 visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err);
                 if (!err) {
                     switch ((*obj)->kind) {

Paolo

#2 lore raw
Quoted 13 lines · On Mon, 03 Sep 2012 08:57:36 +0200 Paolo Bonzini <[email protected]> wrote:

Il 01/09/2012 09:30, Stefan Weil ha scritto:

Quoted 12 lines

Report from smatch:

qapi-visit.c:1640 visit_type_BlockdevAction(8) error:
we previously assumed 'obj' could be null (see line 1639)
qapi-visit.c:2432 visit_type_NetClientOptions(8) error:
we previously assumed 'obj' could be null (see line 2431)

---
 scripts/qapi-visit.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
scripts/qapi-visit.py +0 -0
index 2afc5c0..1a669f3 100644

scripts/qapi-visit.py void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** · line 163

Quoted 8 lines
scripts/qapi-visit.py +1 -1
@@ -157,7 +157,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
     if (!error_is_set(errp)) {
         visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
         if (!err) {
-            if (!obj || *obj) {
+            if (obj && *obj) {
                 visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err);
                 if (!err) {
                     switch ((*obj)->kind) {

Is this for 1.2?

Although the fix is pretty obvious, it doesn't seem possible to trigger the segfault today and I believe we're only accepting true bug fixes at this point (ie. two days from the release).

#3 lore raw

Am 03.09.2012 18:34, schrieb Luiz Capitulino:

Quoted 33 lines
Quoted 13 lines · On Mon, 03 Sep 2012 08:57:36 +0200 Paolo Bonzini <[email protected]> wrote:

Il 01/09/2012 09:30, Stefan Weil ha scritto:

Quoted 12 lines

Report from smatch:

qapi-visit.c:1640 visit_type_BlockdevAction(8) error:
we previously assumed 'obj' could be null (see line 1639)
qapi-visit.c:2432 visit_type_NetClientOptions(8) error:
we previously assumed 'obj' could be null (see line 2431)

---
  scripts/qapi-visit.py |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
scripts/qapi-visit.py +0 -0
index 2afc5c0..1a669f3 100644

scripts/qapi-visit.py void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** · line 163

Quoted 8 lines
scripts/qapi-visit.py +1 -1
@@ -157,7 +157,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
      if (!error_is_set(errp)) {
          visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
          if (!err) {
-            if (!obj || *obj) {
+            if (obj && *obj) {
                  visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err);
                  if (!err) {
                      switch ((*obj)->kind) {
Quoted 5 lines

Is this for 1.2?

Although the fix is pretty obvious, it doesn't seem possible to trigger the segfault today and I believe we're only accepting true bug fixes at this point (ie. two days from the release).

As long as nobody has a scenario which triggers the bug, there is no need to apply that patch before 1.2 is released.

That's why I did not add "for 1.2" to the subject line.

- sw

#4 lore raw
Quoted 36 lines · On Mon, 03 Sep 2012 18:49:54 +0200 Stefan Weil <[email protected]> wrote:

Am 03.09.2012 18:34, schrieb Luiz Capitulino:

Quoted 35 lines
Quoted 13 lines · On Mon, 03 Sep 2012 08:57:36 +0200 Paolo Bonzini <[email protected]> wrote:

Il 01/09/2012 09:30, Stefan Weil ha scritto:

Quoted 12 lines

Report from smatch:

qapi-visit.c:1640 visit_type_BlockdevAction(8) error:
we previously assumed 'obj' could be null (see line 1639)
qapi-visit.c:2432 visit_type_NetClientOptions(8) error:
we previously assumed 'obj' could be null (see line 2431)

---
  scripts/qapi-visit.py |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
scripts/qapi-visit.py +0 -0
index 2afc5c0..1a669f3 100644

scripts/qapi-visit.py void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** · line 163

Quoted 8 lines
scripts/qapi-visit.py +1 -1
@@ -157,7 +157,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
      if (!error_is_set(errp)) {
          visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err);
          if (!err) {
-            if (!obj || *obj) {
+            if (obj && *obj) {
                  visit_type_%(name)sKind(m, &(*obj)->kind, "type", &err);
                  if (!err) {
                      switch ((*obj)->kind) {

Is this for 1.2?

Quoted 8 lines
Quoted 3 lines

Although the fix is pretty obvious, it doesn't seem possible to trigger the segfault today and I believe we're only accepting true bug fixes at this point (ie. two days from the release).

As long as nobody has a scenario which triggers the bug, there is no need to apply that patch before 1.2 is released.

That's why I did not add "for 1.2" to the subject line.

Applied to qmp-next, thanks.