Skip to contentSkip to conversation

Fix segfault during NBD iotest 083

PATCH New Jagannathan Raman 3 participants 6 messages Feb 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix segfault during NBD iotest 083

Hi,

The patch fixes a segfault issue. error_prepend() in qio_channel_readv_full_all() sets a NULL *errp when ret is 0.

We ran the following tests with this patch and they all passed:
- cd tests/qemu-iotests && ./check -nbd 083
- make check
- make check-iotests
- CI using Travis. We also kicked off gitlab CI, but didn't hear anything back from the server

Jagannathan Raman (1):
io: error_prepend() in qio_channel_readv_full_all() causes segfault

 io/channel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault

In reply to Jagannathan Raman
Quoted 17 lines · Jagannathan Raman

Using error_prepend() in qio_channel_readv_full_all() causes a segfault as errp is not set when ret is 0. This results in the failure of iotest
83. Replacing with error_setg() fixes the problem.

Additionally, removes a full stop at the end of error message

---
 io/channel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
io/channel.c +0 -0
index 4555021..e8b019d 100644

io/channel.c int qio_channel_readv_full_all(QIOChannel *ioc, · line 208

Quoted 9 lines
io/channel.c +1 -2
@@ -202,8 +202,7 @@ int qio_channel_readv_full_all(QIOChannel *ioc,
     int ret = qio_channel_readv_full_all_eof(ioc, iov, niov, fds, nfds, errp);
 
     if (ret == 0) {
-        error_prepend(errp,
-                      "Unexpected end-of-file before all data were read.");
+        error_setg(errp, "Unexpected end-of-file before all data were read");
         return -1;
     }
     if (ret == 1) {

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#1 lore raw

PATCH 1/1 io: error_prepend() in qio_channel_readv_full_all() causes segfault

In reply to Jagannathan Raman

Using error_prepend() in qio_channel_readv_full_all() causes a segfault as errp is not set when ret is 0. This results in the failure of iotest
83. Replacing with error_setg() fixes the problem.

Additionally, removes a full stop at the end of error message

---
 io/channel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
io/channel.c +1 -2
index 4555021..e8b019d 100644
@@ -202,8 +202,7 @@ int qio_channel_readv_full_all(QIOChannel *ioc,
     int ret = qio_channel_readv_full_all_eof(ioc, iov, niov, fds, nfds, errp);
 
     if (ret == 0) {
-        error_prepend(errp,
-                      "Unexpected end-of-file before all data were read.");
+        error_setg(errp, "Unexpected end-of-file before all data were read");
         return -1;
     }
     if (ret == 1) {
Signature · 1 line
1.8.3.1
author
#3 lore raw

Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault

In reply to Daniel P. Berrangé
Quoted 24 lines · Daniel P. Berrangé
Quoted 19 lines · Jagannathan Raman

Using error_prepend() in qio_channel_readv_full_all() causes a segfault as errp is not set when ret is 0. This results in the failure of iotest
83. Replacing with error_setg() fixes the problem.

Additionally, removes a full stop at the end of error message

---
io/channel.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
io/channel.c +0 -0
index 4555021..e8b019d 100644
@@ -202,8 +202,7 @@ int qio_channel_readv_full_all(QIOChannel *ioc,
    int ret = qio_channel_readv_full_all_eof(ioc, iov, niov, fds, nfds, errp);
 
Quoted 9 lines

io/channel.c int qio_channel_readv_full_all(QIOChannel *ioc, · line 208

Quoted 7 lines
io/channel.c +1 -2
    if (ret == 0) {
-        error_prepend(errp,
-                      "Unexpected end-of-file before all data were read.");
+        error_setg(errp, "Unexpected end-of-file before all data were read");
        return -1;
    }
    if (ret == 1) {

Thank you for reviewing, Daniel! I recall that you warned about error_prepend() during the review, somehow slipped through.

Hi Peter,

Could we send a PULL request for this patch?

Thank you!
--
Jag

Quoted 8 lines

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault

Quoted 18 lines · Jag Raman
Quoted 18 lines · Daniel P. Berrangé
Quoted 11 lines · Jagannathan Raman

Using error_prepend() in qio_channel_readv_full_all() causes a segfault as errp is not set when ret is 0. This results in the failure of iotest
83. Replacing with error_setg() fixes the problem.

Additionally, removes a full stop at the end of error message

---
io/channel.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 8 lines
Quoted 1 line

Thank you for reviewing, Daniel! I recall that you warned about error_prepend() during the review, somehow slipped through.

Hi Peter,

Could we send a PULL request for this patch?

I'm bundling up a pull request for my NBD tree, and will include this one.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
author
#5 lore raw

Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault

Quoted 25 lines · Eric Blake
Quoted 20 lines · Jag Raman
Quoted 19 lines · Daniel P. Berrangé
Quoted 11 lines · Jagannathan Raman

Using error_prepend() in qio_channel_readv_full_all() causes a segfault as errp is not set when ret is 0. This results in the failure of iotest
83. Replacing with error_setg() fixes the problem.

Additionally, removes a full stop at the end of error message

---
io/channel.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 8 lines
Quoted 6 lines

Thank you for reviewing, Daniel! I recall that you warned about error_prepend() during the review, somehow slipped through.

Hi Peter,

Could we send a PULL request for this patch?

I'm bundling up a pull request for my NBD tree, and will include this one.

Thank you very much, Eric! :)

Quoted 5 lines
Signature · 4 lines
-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org