[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] filter-mirror: segfault when specifying non e

From: Zhang Chen
Subject: Re: [Qemu-trivial] [PATCH] filter-mirror: segfault when specifying non existent device
Date: Tue, 22 Aug 2017 09:19:20 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 08/21/2017 11:50 PM, Eduardo Otubo wrote:
When using filter-mirror like the example below where the interface
'ndev0' does not exist on the host, QEMU crashes into segmentation

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

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 <address@hidden>

Looks good for me.

Reviewed-by: Zhang Chen<address@hidden>

Zhang Chen

  net/filter-mirror.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/net/filter-mirror.c b/net/filter-mirror.c
index 90e2c92337..e18a4b16a0 100644
--- a/net/filter-mirror.c
+++ b/net/filter-mirror.c
@@ -213,14 +213,22 @@ static void filter_mirror_setup(NetFilterState *nf, Error 
      MirrorState *s = FILTER_MIRROR(nf);
      Chardev *chr;
+ if (s->outdev == NULL) {
+        goto err;
+    }
      chr = qemu_chr_find(s->outdev);
      if (chr == NULL) {
-        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
-                  "Device '%s' not found", s->outdev);
-        return;
+        goto err;
qemu_chr_fe_init(&s->chr_out, chr, errp);
+    error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found",
+              nf->netdev_id);
+    return;
static void redirector_rs_finalize(SocketReadState *rs)

Zhang Chen

reply via email to

[Prev in Thread] Current Thread [Next in Thread]