From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
To: Yunjian Wang <wangyunjian@huawei.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "konstantin.v.ananyev@yandex.ru" <konstantin.v.ananyev@yandex.ru>,
"luyicai@huawei.com" <luyicai@huawei.com>,
"stable@dpdk.org" <stable@dpdk.org>, nd <nd@arm.com>,
Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>,
nd <nd@arm.com>
Subject: RE: [dpdk-dev] [PATCH] ring: fix use after free in ring release
Date: Tue, 18 Apr 2023 23:53:22 +0000 [thread overview]
Message-ID: <DBAPR08MB581409286B5529C3C0053D23989D9@DBAPR08MB5814.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <d175f9250542291dd0b86f4587a5fde018b945b1.1681736644.git.wangyunjian@huawei.com>
> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Monday, April 17, 2023 8:12 AM
> To: dev@dpdk.org
> Cc: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>;
> konstantin.v.ananyev@yandex.ru; luyicai@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] ring: fix use after free in ring release
>
> When using the ring to find out tailq entry, however it had been freed by
> rte_memzone_free function. This change prevents that from happening.
I am unable to follow the problem you are describing.
After the memzone for the ring is released, the contents of the memzone are not being used. I understand that the variable 'r' is being used, but that should not cause any issues.
>
> Fixes: 4e32101f9b01 ("ring: support freeing")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
> lib/ring/rte_ring.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index
> 8ed455043d..17d2d7f8a8 100644
> --- a/lib/ring/rte_ring.c
> +++ b/lib/ring/rte_ring.c
> @@ -333,11 +333,6 @@ rte_ring_free(struct rte_ring *r)
> return;
> }
>
> - if (rte_memzone_free(r->memzone) != 0) {
> - RTE_LOG(ERR, RING, "Cannot free memory\n");
> - return;
> - }
Why do we need to free the memzone later?
> -
> ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list);
> rte_mcfg_tailq_write_lock();
>
> @@ -349,7 +344,7 @@ rte_ring_free(struct rte_ring *r)
>
> if (te == NULL) {
> rte_mcfg_tailq_write_unlock();
> - return;
> + goto free_memzone;
> }
>
> TAILQ_REMOVE(ring_list, te, next);
> @@ -357,6 +352,10 @@ rte_ring_free(struct rte_ring *r)
> rte_mcfg_tailq_write_unlock();
>
> rte_free(te);
> +
> +free_memzone:
> + if (rte_memzone_free(r->memzone) != 0)
> + RTE_LOG(ERR, RING, "Cannot free memory\n");
> }
>
> /* dump the status of the ring on the console */
> --
> 2.33.0
next prev parent reply other threads:[~2023-04-18 23:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 13:11 Yunjian Wang
2023-04-18 23:53 ` Honnappa Nagarahalli [this message]
2023-04-19 7:08 ` wangyunjian
2023-04-19 21:44 ` Honnappa Nagarahalli
2023-04-20 6:48 ` wangyunjian
2023-04-20 6:43 ` [dpdk-dev] [PATCH v2] " Yunjian Wang
2023-04-20 16:56 ` Honnappa Nagarahalli
2023-05-01 12:32 ` Konstantin Ananyev
2023-05-01 19:06 ` Honnappa Nagarahalli
2023-05-02 23:06 ` Konstantin Ananyev
2023-05-03 5:44 ` Honnappa Nagarahalli
2023-05-03 22:32 ` Konstantin Ananyev
2023-05-03 23:45 ` Honnappa Nagarahalli
2023-05-05 1:26 ` wangyunjian
2023-05-05 6:48 ` [dpdk-dev] [PATCH v3] " Yunjian Wang
2023-05-23 10:16 ` Thomas Monjalon
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=DBAPR08MB581409286B5529C3C0053D23989D9@DBAPR08MB5814.eurprd08.prod.outlook.com \
--to=honnappa.nagarahalli@arm.com \
--cc=dev@dpdk.org \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=luyicai@huawei.com \
--cc=nd@arm.com \
--cc=stable@dpdk.org \
--cc=wangyunjian@huawei.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).