From: Ferruh Yigit <ferruh.yigit@intel.com>
To: "Min Hu (Connor)" <humin29@huawei.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] net/bonding: fix socket id check
Date: Mon, 26 Apr 2021 15:54:57 +0100 [thread overview]
Message-ID: <de6cf244-0ab0-fea3-d36a-a7f2e11292f5@intel.com> (raw)
In-Reply-To: <1619075569-33619-1-git-send-email-humin29@huawei.com>
On 4/22/2021 8:12 AM, Min Hu (Connor) wrote:
> From: Chengchang Tang <tangchengchang@huawei.com>
>
> The socket ID entered by user is cast to an unsigned integer. However,
> the value may be an illegal negative value, which may cause some
> problems. In this case, an error should be returned.
>
+1 to fix
> In addition, the socket ID may be an invalid positive number, which is
> also processed in this patch.
>
> Fixes: 2efb58cbab6e ("bond: new link bonding library")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
> drivers/net/bonding/rte_eth_bond_args.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
> index 8c5f90d..bcc0fe3 100644
> --- a/drivers/net/bonding/rte_eth_bond_args.c
> +++ b/drivers/net/bonding/rte_eth_bond_args.c
> @@ -207,12 +207,12 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused,
> return -1;
>
> errno = 0;
> - socket_id = (uint8_t)strtol(value, &endptr, 10);
> + socket_id = strtol(value, &endptr, 10);
'strtol()' returns 'long int', but implicitly casting it to 'int'. My concern is
if this cause a static analysis tool warning.
What do you think to have 'socket_id' type as 'long int'?
> if (*endptr != 0 || errno != 0)
> return -1;
>
> /* validate socket id value */
> - if (socket_id >= 0) {
> + if (socket_id >= 0 && socket_id < RTE_MAX_NUMA_NODES) {> *(uint8_t *)extra_args = (uint8_t)socket_id;
Here there is an assumption that RTE_MAX_NUMA_NODES will be less than
'UCHAR_MAX', perhaps it can be good to add a check to verify this assumption.
> return 0;
> }
>
next prev parent reply other threads:[~2021-04-26 14:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-22 7:12 Min Hu (Connor)
2021-04-26 14:54 ` Ferruh Yigit [this message]
2021-04-27 2:44 ` Chengchang Tang
2021-04-27 10:45 ` Ferruh Yigit
2021-04-27 9:16 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
2021-04-27 10:47 ` Ferruh Yigit
2021-04-27 11:39 ` [dpdk-dev] [PATCH v4] " Min Hu (Connor)
2021-04-27 12:51 ` Ferruh Yigit
-- strict thread matches above, loose matches on Subject: below --
2020-06-16 9:46 [dpdk-dev] [PATCH] " David Marchand
2020-06-16 10:09 ` Chas Williams
2020-07-09 10:36 ` Ferruh Yigit
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=de6cf244-0ab0-fea3-d36a-a7f2e11292f5@intel.com \
--to=ferruh.yigit@intel.com \
--cc=dev@dpdk.org \
--cc=humin29@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).