patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Varghese, Vipin" <Vipin.Varghese@amd.com>
To: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>,
	Sunil Kumar Kori <skori@marvell.com>,
	Rakesh Kudurumalla <rkudurumalla@marvell.com>,
	Jerin Jacob <jerinj@marvell.com>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "stable@dpdk.org" <stable@dpdk.org>
Subject: RE: [PATCH] app/graph: fix overrun error (destination buffer too small)
Date: Fri, 8 Aug 2025 03:32:20 +0000	[thread overview]
Message-ID: <PH7PR12MB8596EB855E0097265B14B82D822FA@PH7PR12MB8596.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20250807110640.1094029-1-14pwcse1224@uetpeshawar.edu.pk>

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Khadem,

Thank you for sharing, please find my comment below

Snipped

>
> Some memory locations will be written with incorrect values, possibly corrupting
> data structures or data integrity.
> Size of destination buffer is smaller than the size argument specified.
>
> Coverity issue: 415430
> Fixes: 3850cb06ab9c ('app/graph: add ethdev commands')
> Cc: stable@dpdk.org
>
> Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
> ---
>  app/graph/ethdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c index 2f4cf65c96..f6d4bce9ab
> 100644
> --- a/app/graph/ethdev.c
> +++ b/app/graph/ethdev.c
> @@ -663,11 +663,12 @@ cmd_ethdev_parsed(void *parsed_result, __rte_unused
> struct cmdline *cl, void *da
>         struct cmd_ethdev_result *res = parsed_result;
>         struct ethdev_config config;
>         int rc;
> -
> +       size_t len;
>         memset(&config, 0, sizeof(struct ethdev_config));
>         config.rx.n_queues = res->nb_rxq;
>         config.rx.queue_size = ETHDEV_RX_DESC_DEFAULT;
> -       memcpy(config.rx.mempool_name, res->mempool, strlen(res->mempool));
> +       len = strnlen(res->mempool, sizeof(config.rx.mempool_name));
> +       memcpy(config.rx.mempool_name, res->mempool, len);

Yes indeed the strnlen is good choice. What I assume you are doing here to get the exact size `config.rx_mempool_size` by seeking for first `\0`. But the api `strnlen` intention of use is not of the same. The second argument is treated as maximum seek size, that is either return string len less than max-size or if not found return second argument.

There will no difference in using ` strlen(res->mempool)` and ` strnlen(res->mempool, sizeof(config.rx.mempool_name));` in this code case.

Can you please rework and share again. Hence NACK

NACK: Vipin Varghese <Vipin.varghese@amd.com>

>
>         config.tx.n_queues = res->nb_txq;
>         config.tx.queue_size = ETHDEV_TX_DESC_DEFAULT;
> --
> 2.43.0


      reply	other threads:[~2025-08-08  3:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-07 11:06 Khadem Ullah
2025-08-08  3:32 ` Varghese, Vipin [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=PH7PR12MB8596EB855E0097265B14B82D822FA@PH7PR12MB8596.namprd12.prod.outlook.com \
    --to=vipin.varghese@amd.com \
    --cc=14pwcse1224@uetpeshawar.edu.pk \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=rkudurumalla@marvell.com \
    --cc=skori@marvell.com \
    --cc=stable@dpdk.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).