From: Auger Eric <eric.auger@redhat.com>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Cc: quintela@redhat.com
Subject: Re: [PATCH] test-vmstate: fix bad GTree usage, use-after-free
Date: Thu, 27 Aug 2020 18:34:03 +0200 [thread overview]
Message-ID: <c52960c3-d88c-010d-584a-75917bc9b702@redhat.com> (raw)
In-Reply-To: <20200827161826.1165971-1-marcandre.lureau@redhat.com>
Hi Marc-Andre
On 8/27/20 6:18 PM, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> According to g_tree_foreach() documentation:
> "The tree may not be modified while iterating over it (you can't
> add/remove items)."
Hum I did not see that.
>
> Fixes: 9a85e4b8f6 ("migration: Support gtree migration")
> Cc: Eric Auger <eric.auger@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> tests/test-vmstate.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index f7b3868881..31aefa78f0 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -1078,7 +1078,6 @@ static gboolean diff_tree(gpointer key, gpointer value, gpointer data)
> struct match_node_data d = {tp->tree2, key, value};
>
> g_tree_foreach(tp->tree2, tp->match_node, &d);
> - g_tree_remove(tp->tree1, key);
it does not test the same thing I am afraid. If one of the trees
contains more elements than the others this won't be detected.
Also there is another case of removal inside the traversal in the
match_node(): in match_interval_mapping_node() and match_domain_node()
Thanks
Eric
> return false;
> }
>
> @@ -1088,7 +1087,7 @@ static void compare_trees(GTree *tree1, GTree *tree2,
> struct tree_cmp_data tp = {tree1, tree2, function};
>
> g_tree_foreach(tree1, diff_tree, &tp);
> - assert(g_tree_nnodes(tree1) == 0);> + g_tree_destroy(g_tree_ref(tree1));
> assert(g_tree_nnodes(tree2) == 0);
> }
>
>
next prev parent reply other threads:[~2020-08-27 16:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 16:18 [PATCH] test-vmstate: fix bad GTree usage, use-after-free marcandre.lureau
2020-08-27 16:28 ` Juan Quintela
2020-08-27 16:34 ` Auger Eric [this message]
2020-08-27 18:35 ` Marc-André Lureau
2020-08-28 7:19 ` Auger Eric
2020-08-28 7:52 ` Auger Eric
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=c52960c3-d88c-010d-584a-75917bc9b702@redhat.com \
--to=eric.auger@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).