From: David Marchand <david.marchand@redhat.com>
To: Robin Jarry <rjarry@redhat.com>
Cc: dev@dpdk.org, Jerin Jacob <jerinj@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Nithin Dabilpuram <ndabilpuram@marvell.com>,
Zhirun Yan <yanzhirun_163@163.com>
Subject: Re: [PATCH v3] graph: avoid id collisions
Date: Tue, 18 Jun 2024 15:13:04 +0200 [thread overview]
Message-ID: <CAJFAV8yYAPikYVHN-Yyb5zLGdL4eEfMnDuNOVttFF1t_SpONyg@mail.gmail.com> (raw)
In-Reply-To: <20240618092324.54166-2-rjarry@redhat.com>
On Tue, Jun 18, 2024 at 11:24 AM Robin Jarry <rjarry@redhat.com> wrote:
>
> The graph id is determined based on a global variable that is
> incremented every time a graph is created, and decremented every time
> a graph is destroyed. This only works if graphs are destroyed in the
> reverse order in which they have been created.
>
> The following code produces duplicate graph IDs which can lead to
> use-after-free bugs and other undefined behaviours:
>
> a = rte_graph_create(...); // id=0 graph_id=1
> b = rte_graph_create(...); // id=1 graph_id=2
> rte_graph_destroy(a); // graph_id=1
> c = rte_graph_create(...); // id=1 graph_id=2 (duplicate with b)
> rte_graph_destroy(c); // frees memory still used by b
>
> Remove the global counter. Make sure that the graph list is always
> ordered by increasing graph ids. When creating a new graph, pick a free
> id which is not allocated.
>
> Update unit tests to ensure it works as expected.
Fixes: a91fecc19c5c ("graph: implement create and destroy")
Cc: stable@dpdk.org
>
> Signed-off-by: Robin Jarry <rjarry@redhat.com>
Acked-by: Kiran Kumar Kokkilagadda <kirankumark@marvell.com>
Applied, thanks.
--
David Marchand
prev parent reply other threads:[~2024-06-18 13:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 9:23 Robin Jarry
2024-06-18 9:49 ` [EXTERNAL] " Kiran Kumar Kokkilagadda
2024-06-18 13:13 ` David Marchand [this message]
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=CAJFAV8yYAPikYVHN-Yyb5zLGdL4eEfMnDuNOVttFF1t_SpONyg@mail.gmail.com \
--to=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=rjarry@redhat.com \
--cc=yanzhirun_163@163.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).