From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Dengdui Huang" <huangdengdui@huawei.com>, <dev@dpdk.org>
Cc: <honest.jiang@foxmail.com>, <fengchengwen@huawei.com>,
<roretzla@linux.microsoft.com>, <lihuisong@huawei.com>,
<haijie1@huawei.com>, <liuyonglong@huawei.com>,
<stephen@networkplumber.org>
Subject: RE: [PATCH v2 1/2] eal: fix uncheck worker ID
Date: Thu, 27 Mar 2025 10:32:02 +0100 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9FB7A@smartserver.smartshare.dk> (raw)
In-Reply-To: <20250327090116.3357137-2-huangdengdui@huawei.com>
> From: Dengdui Huang [mailto:huangdengdui@huawei.com]
> Sent: Thursday, 27 March 2025 10.01
>
> The worker_id may come from user input.
> So it is necessary to verify it.
>
> Fixes: a95d70547c57 ("eal: factorize lcore main loop")
> Cc: stable@dpdk.org
>
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> ---
> lib/eal/common/eal_common_launch.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/eal/common/eal_common_launch.c
> b/lib/eal/common/eal_common_launch.c
> index 5320c3bd3c..76313d5cdf 100644
> --- a/lib/eal/common/eal_common_launch.c
> +++ b/lib/eal/common/eal_common_launch.c
> @@ -35,6 +35,9 @@ rte_eal_remote_launch(lcore_function_t *f, void *arg,
> unsigned int worker_id)
> {
> int rc = -EBUSY;
>
Also check the lcore_id:
+ if (unlikely(lcore_id >= RTE_MAX_LCORE))
+ return -EINVAL;
+
> + if (!rte_lcore_has_role(worker_id, ROLE_RTE))
> + return -EINVAL;
> +
Although rte_lcore_has_role() checks the lcore_id and returns -EINVAL if invalid, "if (!-EINVAL))" will not take the branch to return -EINVAL here. So this check alone does not suffice. You could change it to "if (rte_lcore_has_role(worker_id, ROLE_RTE) <= 0) return -EINVAL;".
However, I prefer the separate lcore_id check, as mentioned above, rather than changing this check.
> /* Check if the worker is in 'WAIT' state. Use acquire order
> * since 'state' variable is used as the guard variable.
> */
> --
> 2.33.0
<feature creep>
While you are at it, please also add "if (unlikely(lcore_id >= RTE_MAX_LCORE)) return -EINVAL;" checks in the other functions in eal_common_lcore.c where lcore_id comes from user input and the check is missing.
</feature creep>
next prev parent reply other threads:[~2025-03-27 9:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 4:03 [PATCH 0/2] fix the problem of dma-perf infinite loop Dengdui Huang
2025-03-21 4:03 ` [PATCH 1/2] eal: fix wake a incorrect lcore Dengdui Huang
2025-03-21 4:03 ` [PATCH 2/2] app/dma-perf: fix infinite loop Dengdui Huang
2025-03-21 15:58 ` Stephen Hemminger
2025-03-24 3:42 ` huangdengdui
2025-03-21 7:49 ` [PATCH 0/2] fix the problem of dma-perf " David Marchand
2025-03-24 3:42 ` huangdengdui
2025-03-27 8:58 ` [PATCH] app/dma-perf: fix " Dengdui Huang
2025-03-27 8:58 ` [PATCH 1/2] eal: fix uncheck worker ID Dengdui Huang
2025-03-27 8:58 ` [PATCH 2/2] app/dma-perf: fix infinite loop Dengdui Huang
2025-03-27 9:01 ` [PATCH v2 0/2] fix the problem of dma-perf " Dengdui Huang
2025-03-27 9:01 ` [PATCH v2 1/2] eal: fix uncheck worker ID Dengdui Huang
2025-03-27 9:32 ` Morten Brørup [this message]
2025-03-27 9:01 ` [PATCH v2 2/2] app/dma-perf: fix infinite loop Dengdui Huang
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=98CBD80474FA8B44BF855DF32C47DC35E9FB7A@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=haijie1@huawei.com \
--cc=honest.jiang@foxmail.com \
--cc=huangdengdui@huawei.com \
--cc=lihuisong@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=roretzla@linux.microsoft.com \
--cc=stephen@networkplumber.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 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).