From: Shani Peretz <shperetz@nvidia.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
Bruce Richardson <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Parav Pandit <parav@nvidia.com>,
Xueming Li <xuemingl@nvidia.com>,
Nipun Gupta <nipun.gupta@amd.com>,
Nikhil Agarwal <nikhil.agarwal@amd.com>,
Hemant Agrawal <hemant.agrawal@nxp.com>,
Sachin Saxena <sachin.saxena@nxp.com>,
Rosen Xu <rosen.xu@intel.com>, Chenbo Xia <chenbox@nvidia.com>,
Tomasz Duszynski <tduszynski@marvell.com>,
Chengwen Feng <fengchengwen@huawei.com>,
"NBU-Contact-longli (EXTERNAL)" <longli@microsoft.com>,
Wei Hu <weh@microsoft.com>, Kevin Laatz <kevin.laatz@intel.com>,
Tyler Retzlaff <roretzla@linux.microsoft.com>,
Jan Blunck <jblunck@infradead.org>
Subject: RE: [PATCH v5 2/4] lib: fix comparison between devices
Date: Wed, 19 Feb 2025 13:26:17 +0000 [thread overview]
Message-ID: <SA1PR12MB94913776F11F95E0C8C1B462BFC52@SA1PR12MB9491.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20250211100456.084338aa@hermes.local>
Hey,
Sorry for my late response, I sent a fix (v7):
https://patches.dpdk.org/project/dpdk/patch/20250212163836.178976-2-shperetz@nvidia.com/
I added another parameter to the parse function - the size of the memory pointed by addr.
so the function signature now is:
int XXX_parse(const char *name, void *addr, int addr_size, int *out_size)
So I now use it in rte_strscpy.
In addition, should I replace the call to rte_strscpy with strlcpy?
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, 11 February 2025 20:05
> To: Bruce Richardson <bruce.richardson@intel.com>
> Cc: Shani Peretz <shperetz@nvidia.com>; dev@dpdk.org; Parav Pandit
> <parav@nvidia.com>; Xueming Li <xuemingl@nvidia.com>; Nipun Gupta
> <nipun.gupta@amd.com>; Nikhil Agarwal <nikhil.agarwal@amd.com>; Hemant
> Agrawal <hemant.agrawal@nxp.com>; Sachin Saxena
> <sachin.saxena@nxp.com>; Rosen Xu <rosen.xu@intel.com>; Chenbo Xia
> <chenbox@nvidia.com>; Tomasz Duszynski <tduszynski@marvell.com>;
> Chengwen Feng <fengchengwen@huawei.com>; NBU-Contact-longli
> (EXTERNAL) <longli@microsoft.com>; Wei Hu <weh@microsoft.com>; Kevin
> Laatz <kevin.laatz@intel.com>; Tyler Retzlaff <roretzla@linux.microsoft.com>;
> Jan Blunck <jblunck@infradead.org>
> Subject: Re: [PATCH v5 2/4] lib: fix comparison between devices
>
> External email: Use caution opening links or attachments
>
>
> On Tue, 11 Feb 2025 17:54:26 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
>
> > On Tue, Feb 11, 2025 at 09:48:32AM -0800, Stephen Hemminger wrote:
> > > On Thu, 6 Feb 2025 02:08:36 +0200
> > > Shani Peretz <shperetz@nvidia.com> wrote:
> > >
> > > > static int
> > > > -cdx_parse(const char *name, void *addr)
> > > > +cdx_parse(const char *name, void *addr, int *size)
> > > > {
> > > > - const char **out = addr;
> > > > int ret;
> > > >
> > > > ret = strncmp(name, CDX_DEV_PREFIX, strlen(CDX_DEV_PREFIX));
> > > >
> > > > - if (ret == 0 && addr)
> > > > - *out = name;
> > > > + if (ret != 0)
> > > > + return ret;
> > > > +
> > > > + if (size != NULL)
> > > > + *size = strlen(name) + 1;
> > > > +
> > > > + if (addr != NULL)
> > > > + rte_strscpy(addr, name, strlen(name) + 1);
> > >
> > > Why use rte_strscpy() here?
> > >
> > > The intention of strscpy() is to handle case where the resulting
> > > buffer is limited in size. By using the input string length you
> > > aren't really doing anything different than strcpy(). Still unsafe if output
> (addr) is not big enough.
> >
> > And using strlcpy is probably fine too, without having to use
> > dpdk-specific string functions.
> >
> > /Bruce
>
> The issue is that any length argument needs to come from caller based on the
> size of the target buffer. Not from length of source string.
>
> If you want to make parse code string safe, then either size needs to be always
> present and in/out parameter or need to have a src_size and resulting size as
> separate params.
next prev parent reply other threads:[~2025-02-19 13:26 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 20:01 [PATCH] eal/common: fix inconsistent representation of PCI numbers Shani Peretz
2024-07-01 22:00 ` Stephen Hemminger
2024-07-08 16:51 ` [PATCH v3] " Shani Peretz
2024-07-12 13:49 ` David Marchand
2024-07-12 17:55 ` Thomas Monjalon
2025-01-29 8:54 ` [PATCH v4] bus: " Shani Peretz
2025-01-29 9:45 ` Bruce Richardson
2025-01-29 16:25 ` Stephen Hemminger
2025-02-05 16:36 ` Shani Peretz
2025-02-05 16:42 ` Stephen Hemminger
2025-02-05 17:37 ` Shani Peretz
2025-02-05 18:46 ` Stephen Hemminger
2025-02-05 20:16 ` Shani Peretz
2025-02-06 0:40 ` Stephen Hemminger
2025-01-29 17:17 ` Stephen Hemminger
2025-01-29 18:06 ` Bruce Richardson
2025-02-05 1:55 ` fengchengwen
2025-02-06 0:08 ` [PATCH v5 0/4] fix comparison between devices Shani Peretz
2025-02-06 0:08 ` [PATCH v5 1/4] bus/pci: fix registration of PCI device Shani Peretz
2025-02-06 11:22 ` Thomas Monjalon
2025-02-06 0:08 ` [PATCH v5 2/4] lib: fix comparison between devices Shani Peretz
2025-02-06 7:55 ` Hemant Agrawal
2025-02-06 11:25 ` Thomas Monjalon
2025-02-10 1:18 ` Xu, Rosen
2025-02-11 17:48 ` Stephen Hemminger
2025-02-11 17:54 ` Bruce Richardson
2025-02-11 18:04 ` Stephen Hemminger
2025-02-19 13:26 ` Shani Peretz [this message]
2025-02-06 0:08 ` [PATCH v5 3/4] app/test: add tests to find devices Shani Peretz
2025-02-06 1:03 ` Stephen Hemminger
2025-02-06 0:08 ` [PATCH v5 4/4] lib: change find device and cmp dev name functions Shani Peretz
2025-02-06 10:54 ` [PATCH v6 1/4] bus/pci: fix registration of PCI device Shani Peretz
2025-02-06 10:54 ` [PATCH v6 2/4] lib: fix comparison between devices Shani Peretz
2025-02-06 10:54 ` [PATCH v6 3/4] app/test: add tests to find devices Shani Peretz
2025-02-06 10:54 ` [PATCH v6 4/4] lib: change find device and cmp dev name functions Shani Peretz
2025-02-11 17:04 ` [PATCH v6 1/4] bus/pci: fix registration of PCI device Bruce Richardson
2025-02-12 0:39 ` Stephen Hemminger
2025-02-12 16:38 ` [PATCH v7 " Shani Peretz
2025-02-12 16:38 ` [PATCH v7 2/4] lib: fix comparison between devices Shani Peretz
2025-02-19 16:50 ` Stephen Hemminger
2025-02-20 18:33 ` Stephen Hemminger
2025-02-12 16:38 ` [PATCH v7 3/4] app/test: add tests to find devices Shani Peretz
2025-02-19 16:47 ` Stephen Hemminger
2025-02-12 16:38 ` [PATCH v7 4/4] lib: change find device and cmp dev name functions Shani Peretz
2025-02-19 16:44 ` [PATCH v7 1/4] bus/pci: fix registration of PCI device Stephen Hemminger
2025-02-19 16:48 ` Stephen Hemminger
2024-10-04 22:21 ` [PATCH] eal/common: fix inconsistent representation of PCI numbers Stephen Hemminger
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=SA1PR12MB94913776F11F95E0C8C1B462BFC52@SA1PR12MB9491.namprd12.prod.outlook.com \
--to=shperetz@nvidia.com \
--cc=bruce.richardson@intel.com \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=hemant.agrawal@nxp.com \
--cc=jblunck@infradead.org \
--cc=kevin.laatz@intel.com \
--cc=longli@microsoft.com \
--cc=nikhil.agarwal@amd.com \
--cc=nipun.gupta@amd.com \
--cc=parav@nvidia.com \
--cc=roretzla@linux.microsoft.com \
--cc=rosen.xu@intel.com \
--cc=sachin.saxena@nxp.com \
--cc=stephen@networkplumber.org \
--cc=tduszynski@marvell.com \
--cc=weh@microsoft.com \
--cc=xuemingl@nvidia.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).