All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, Ian Jackson <iwj@xenproject.org>,
	Wei Liu <wl@xen.org>
Subject: [PATCH] tools/xenstore: fix use after free bug in xenstore_control
Date: Mon, 25 Jan 2021 08:23:31 +0100	[thread overview]
Message-ID: <20210125072331.22093-1-jgross@suse.com> (raw)

There is a very unlikely use after free bug and a memory leak in
live_update_start() of xenstore_control. Fix those.

Coverity-Id: 1472399
Fixes: 7f97193e6aa858 ("tools/xenstore: add live update command to xenstore-control")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/xenstore/xenstore_control.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/xenstore/xenstore_control.c b/tools/xenstore/xenstore_control.c
index 0c95cf767c..f6f4626c06 100644
--- a/tools/xenstore/xenstore_control.c
+++ b/tools/xenstore/xenstore_control.c
@@ -43,7 +43,12 @@ static int live_update_start(struct xs_handle *xsh, bool force, unsigned int to)
     if (len < 0)
         return 1;
 
+    ret = strdup("BUSY");
+    if (!ret)
+        return 1;
+
     for (time_start = time(NULL); time(NULL) - time_start < to;) {
+        free(ret);
         ret = xs_control_command(xsh, "live-update", buf, len);
         if (!ret)
             goto err;
-- 
2.26.2



             reply	other threads:[~2021-01-25  7:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25  7:23 Juergen Gross [this message]
2021-01-25 10:41 ` [PATCH] tools/xenstore: fix use after free bug in xenstore_control Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210125072331.22093-1-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=iwj@xenproject.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.