All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block/amend: Check whether the node exists
@ 2020-07-10  9:50 Max Reitz
  2020-07-12 11:47 ` Maxim Levitsky
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Max Reitz @ 2020-07-10  9:50 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Maxim Levitsky, qemu-devel, Max Reitz

We should check whether the user-specified node-name actually refers to
a node.  The simplest way to do that is to use bdrv_lookup_bs() instead
of bdrv_find_node() (the former wraps the latter, and produces an error
message if necessary).

Reported-by: Coverity (CID 1430268)
Fixes: ced914d0ab9fb2c900f873f6349a0b8eecd1fdbe
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/amend.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/amend.c b/block/amend.c
index f4612dcf08..392df9ef83 100644
--- a/block/amend.c
+++ b/block/amend.c
@@ -69,8 +69,12 @@ void qmp_x_blockdev_amend(const char *job_id,
     BlockdevAmendJob *s;
     const char *fmt = BlockdevDriver_str(options->driver);
     BlockDriver *drv = bdrv_find_format(fmt);
-    BlockDriverState *bs = bdrv_find_node(node_name);
+    BlockDriverState *bs;
 
+    bs = bdrv_lookup_bs(NULL, node_name, errp);
+    if (!bs) {
+        return;
+    }
 
     if (!drv) {
         error_setg(errp, "Block driver '%s' not found or not supported", fmt);
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/amend: Check whether the node exists
  2020-07-10  9:50 [PATCH] block/amend: Check whether the node exists Max Reitz
@ 2020-07-12 11:47 ` Maxim Levitsky
  2020-07-23 17:56 ` Peter Maydell
  2020-07-24  7:08 ` Max Reitz
  2 siblings, 0 replies; 5+ messages in thread
From: Maxim Levitsky @ 2020-07-12 11:47 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, qemu-devel

On Fri, 2020-07-10 at 11:50 +0200, Max Reitz wrote:
> We should check whether the user-specified node-name actually refers to
> a node.  The simplest way to do that is to use bdrv_lookup_bs() instead
> of bdrv_find_node() (the former wraps the latter, and produces an error
> message if necessary).
> 
> Reported-by: Coverity (CID 1430268)
> Fixes: ced914d0ab9fb2c900f873f6349a0b8eecd1fdbe
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/amend.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/block/amend.c b/block/amend.c
> index f4612dcf08..392df9ef83 100644
> --- a/block/amend.c
> +++ b/block/amend.c
> @@ -69,8 +69,12 @@ void qmp_x_blockdev_amend(const char *job_id,
>      BlockdevAmendJob *s;
>      const char *fmt = BlockdevDriver_str(options->driver);
>      BlockDriver *drv = bdrv_find_format(fmt);
> -    BlockDriverState *bs = bdrv_find_node(node_name);
> +    BlockDriverState *bs;
>  
> +    bs = bdrv_lookup_bs(NULL, node_name, errp);
> +    if (!bs) {
> +        return;
> +    }
>  
>      if (!drv) {
>          error_setg(errp, "Block driver '%s' not found or not supported", fmt);

Yep, this looks like a real bug, sorry about that.

Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/amend: Check whether the node exists
  2020-07-10  9:50 [PATCH] block/amend: Check whether the node exists Max Reitz
  2020-07-12 11:47 ` Maxim Levitsky
@ 2020-07-23 17:56 ` Peter Maydell
  2020-07-24  7:01   ` Max Reitz
  2020-07-24  7:08 ` Max Reitz
  2 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2020-07-23 17:56 UTC (permalink / raw)
  To: Max Reitz; +Cc: Kevin Wolf, QEMU Developers, Qemu-block, Maxim Levitsky

On Fri, 10 Jul 2020 at 10:51, Max Reitz <mreitz@redhat.com> wrote:
>
> We should check whether the user-specified node-name actually refers to
> a node.  The simplest way to do that is to use bdrv_lookup_bs() instead
> of bdrv_find_node() (the former wraps the latter, and produces an error
> message if necessary).
>
> Reported-by: Coverity (CID 1430268)
> Fixes: ced914d0ab9fb2c900f873f6349a0b8eecd1fdbe
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Hi; has this patch got lost? (I'm just running through the Coverity
issues marked as fix-submitted to check the patches made it into
master, and it looks like this one hasn't yet.)

thanks
-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/amend: Check whether the node exists
  2020-07-23 17:56 ` Peter Maydell
@ 2020-07-24  7:01   ` Max Reitz
  0 siblings, 0 replies; 5+ messages in thread
From: Max Reitz @ 2020-07-24  7:01 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Kevin Wolf, QEMU Developers, Qemu-block, Maxim Levitsky


[-- Attachment #1.1: Type: text/plain, Size: 816 bytes --]

On 23.07.20 19:56, Peter Maydell wrote:
> On Fri, 10 Jul 2020 at 10:51, Max Reitz <mreitz@redhat.com> wrote:
>>
>> We should check whether the user-specified node-name actually refers to
>> a node.  The simplest way to do that is to use bdrv_lookup_bs() instead
>> of bdrv_find_node() (the former wraps the latter, and produces an error
>> message if necessary).
>>
>> Reported-by: Coverity (CID 1430268)
>> Fixes: ced914d0ab9fb2c900f873f6349a0b8eecd1fdbe
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
> 
> Hi; has this patch got lost? (I'm just running through the Coverity
> issues marked as fix-submitted to check the patches made it into
> master, and it looks like this one hasn't yet.)

Well, not strictly speaking lost, but I did forget to merge it, yes.
Thanks for the reminder!

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] block/amend: Check whether the node exists
  2020-07-10  9:50 [PATCH] block/amend: Check whether the node exists Max Reitz
  2020-07-12 11:47 ` Maxim Levitsky
  2020-07-23 17:56 ` Peter Maydell
@ 2020-07-24  7:08 ` Max Reitz
  2 siblings, 0 replies; 5+ messages in thread
From: Max Reitz @ 2020-07-24  7:08 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, qemu-devel, Maxim Levitsky


[-- Attachment #1.1: Type: text/plain, Size: 550 bytes --]

On 10.07.20 11:50, Max Reitz wrote:
> We should check whether the user-specified node-name actually refers to
> a node.  The simplest way to do that is to use bdrv_lookup_bs() instead
> of bdrv_find_node() (the former wraps the latter, and produces an error
> message if necessary).
> 
> Reported-by: Coverity (CID 1430268)
> Fixes: ced914d0ab9fb2c900f873f6349a0b8eecd1fdbe
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/amend.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Applied to my block branch.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-24  7:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10  9:50 [PATCH] block/amend: Check whether the node exists Max Reitz
2020-07-12 11:47 ` Maxim Levitsky
2020-07-23 17:56 ` Peter Maydell
2020-07-24  7:01   ` Max Reitz
2020-07-24  7:08 ` Max Reitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.