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

Jagannathan Raman posted 1 patch 4 years, 9 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/be476bcdb99e820fec0fa09fe8f04c9dd3e62473.1613128220.git.jag.raman@oracle.com
Maintainers: "Daniel P. Berrangé" <berrange@redhat.com>
io/channel.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault
Posted by Jagannathan Raman 4 years, 9 months ago
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

Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
---
 io/channel.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/io/channel.c b/io/channel.c
index 4555021..e8b019d 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -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) {
-- 
1.8.3.1


Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault
Posted by Daniel P. Berrangé 4 years, 9 months ago
On Fri, Feb 12, 2021 at 06:16:07AM -0500, Jagannathan Raman wrote:
> 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
> 
> Reported-by: Max Reitz <mreitz@redhat.com>
> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
> ---
>  io/channel.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/io/channel.c b/io/channel.c
> index 4555021..e8b019d 100644
> --- a/io/channel.c
> +++ b/io/channel.c
> @@ -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) {

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: 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 :|


Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault
Posted by Jag Raman 4 years, 9 months ago

> On Feb 12, 2021, at 6:16 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
> 
> On Fri, Feb 12, 2021 at 06:16:07AM -0500, Jagannathan Raman wrote:
>> 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
>> 
>> Reported-by: Max Reitz <mreitz@redhat.com>
>> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
>> ---
>> io/channel.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/io/channel.c b/io/channel.c
>> index 4555021..e8b019d 100644
>> --- a/io/channel.c
>> +++ b/io/channel.c
>> @@ -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) {
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

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

> 
> 
> Regards,
> Daniel
> -- 
> |: 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 :|

Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault
Posted by Eric Blake 4 years, 9 months ago
On 2/12/21 5:41 AM, Jag Raman wrote:
> 
> 
>> On Feb 12, 2021, at 6:16 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>
>> On Fri, Feb 12, 2021 at 06:16:07AM -0500, Jagannathan Raman wrote:
>>> 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
>>>
>>> Reported-by: Max Reitz <mreitz@redhat.com>
>>> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
>>> ---
>>> io/channel.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)

>>
>> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> 
> 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.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Re: [PATCH] io: error_prepend() in qio_channel_readv_full_all() causes segfault
Posted by Jag Raman 4 years, 9 months ago

> On Feb 12, 2021, at 8:08 AM, Eric Blake <eblake@redhat.com> wrote:
> 
> On 2/12/21 5:41 AM, Jag Raman wrote:
>> 
>> 
>>> On Feb 12, 2021, at 6:16 AM, Daniel P. Berrangé <berrange@redhat.com> wrote:
>>> 
>>> On Fri, Feb 12, 2021 at 06:16:07AM -0500, Jagannathan Raman wrote:
>>>> 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
>>>> 
>>>> Reported-by: Max Reitz <mreitz@redhat.com>
>>>> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
>>>> ---
>>>> io/channel.c | 3 +--
>>>> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
>>> 
>>> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>> 
>> 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! :)

> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3226
> Virtualization:  qemu.org | libvirt.org