All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHv2] filter-mirror: segfault when specifying non existent device
@ 2017-09-29 12:03 Eduardo Otubo
  2017-09-29 12:56 ` Zhang Chen
  2017-10-16 20:16 ` Michael Tokarev
  0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Otubo @ 2017-09-29 12:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Zhang Chen, Michael Tokarev, lizhijian

v2:
    Removed "err:" label from the end of the function and replaced by
    two separate error messages. One when outdev is not specified and
    one when outdev does not exist.

    Fixed the error message that was referencing nf->netdev_id and not
    s->outdev.

When using filter-mirror like the example below where the interface
'ndev0' does not exist on the host, QEMU crashes into segmentation
fault.

 $ qemu-system-x86_64 -S -machine pc -netdev user,id=ndev0 -object filter-mirror,id=test-object,netdev=ndev0

This happens because the function filter_mirror_setup() does not checks
if the device actually exists and still keep on processing calling
qemu_chr_find(). This patch fixes this issue.

Signed-off-by: Eduardo Otubo <otubo@redhat.com>
---
 net/filter-mirror.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/filter-mirror.c b/net/filter-mirror.c
index 90e2c92337..ce0dc23c2a 100644
--- a/net/filter-mirror.c
+++ b/net/filter-mirror.c
@@ -213,6 +213,12 @@ static void filter_mirror_setup(NetFilterState *nf, Error **errp)
     MirrorState *s = FILTER_MIRROR(nf);
     Chardev *chr;
 
+    if (s->outdev == NULL) {
+        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "filter-mirror parameter"\
+                  " 'outdev' cannot be empty");
+        return;
+    }
+
     chr = qemu_chr_find(s->outdev);
     if (chr == NULL) {
         error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
-- 
2.13.5

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

* Re: [Qemu-devel] [PATCHv2] filter-mirror: segfault when specifying non existent device
  2017-09-29 12:03 [Qemu-devel] [PATCHv2] filter-mirror: segfault when specifying non existent device Eduardo Otubo
@ 2017-09-29 12:56 ` Zhang Chen
  2017-10-16 20:16 ` Michael Tokarev
  1 sibling, 0 replies; 3+ messages in thread
From: Zhang Chen @ 2017-09-29 12:56 UTC (permalink / raw)
  To: Eduardo Otubo
  Cc: qemu-devel, qemu-trivial, Michael Tokarev, lizhijian, Zhang Chen

2017-09-29 12:03 GMT+00:00 Eduardo Otubo <otubo@redhat.com>:

> v2:
>     Removed "err:" label from the end of the function and replaced by
>     two separate error messages. One when outdev is not specified and
>     one when outdev does not exist.
>
>     Fixed the error message that was referencing nf->netdev_id and not
>     s->outdev.
>
> When using filter-mirror like the example below where the interface
> 'ndev0' does not exist on the host, QEMU crashes into segmentation
> fault.
>
>  $ qemu-system-x86_64 -S -machine pc -netdev user,id=ndev0 -object
> filter-mirror,id=test-object,netdev=ndev0
>
> This happens because the function filter_mirror_setup() does not checks
> if the device actually exists and still keep on processing calling
> qemu_chr_find(). This patch fixes this issue.
>
> Signed-off-by: Eduardo Otubo <otubo@redhat.com>
>


 Reviewed-by: Zhang Chen <zhangckid@gmail.com>

 Thanks
 Zhang Chen


> ---
>  net/filter-mirror.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/net/filter-mirror.c b/net/filter-mirror.c
> index 90e2c92337..ce0dc23c2a 100644
> --- a/net/filter-mirror.c
> +++ b/net/filter-mirror.c
> @@ -213,6 +213,12 @@ static void filter_mirror_setup(NetFilterState *nf,
> Error **errp)
>      MirrorState *s = FILTER_MIRROR(nf);
>      Chardev *chr;
>
> +    if (s->outdev == NULL) {
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "filter-mirror
> parameter"\
> +                  " 'outdev' cannot be empty");
> +        return;
> +    }
> +
>      chr = qemu_chr_find(s->outdev);
>      if (chr == NULL) {
>          error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> --
> 2.13.5
>
>
>

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

* Re: [Qemu-devel] [PATCHv2] filter-mirror: segfault when specifying non existent device
  2017-09-29 12:03 [Qemu-devel] [PATCHv2] filter-mirror: segfault when specifying non existent device Eduardo Otubo
  2017-09-29 12:56 ` Zhang Chen
@ 2017-10-16 20:16 ` Michael Tokarev
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2017-10-16 20:16 UTC (permalink / raw)
  To: Eduardo Otubo, qemu-devel; +Cc: qemu-trivial, lizhijian, Zhang Chen

29.09.2017 15:03, Eduardo Otubo wrote:
> v2:
>     Removed "err:" label from the end of the function and replaced by
>     two separate error messages. One when outdev is not specified and
>     one when outdev does not exist.
> 
>     Fixed the error message that was referencing nf->netdev_id and not
>     s->outdev.
> 
> When using filter-mirror like the example below where the interface
> 'ndev0' does not exist on the host, QEMU crashes into segmentation
> fault.
> 
>  $ qemu-system-x86_64 -S -machine pc -netdev user,id=ndev0 -object filter-mirror,id=test-object,netdev=ndev0
> 
> This happens because the function filter_mirror_setup() does not checks
> if the device actually exists and still keep on processing calling
> qemu_chr_find(). This patch fixes this issue.

Applied to -trivial, with a tiny fix in the commit message (checkS).

Thanks!

/mjt

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

end of thread, other threads:[~2017-10-16 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 12:03 [Qemu-devel] [PATCHv2] filter-mirror: segfault when specifying non existent device Eduardo Otubo
2017-09-29 12:56 ` Zhang Chen
2017-10-16 20:16 ` Michael Tokarev

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.