From: Bruce Richardson <bruce.richardson@intel.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Kevin Laatz <kevin.laatz@intel.com>,
dev@dpdk.org, stephen@networkplumber.org, stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2] net/ring: fix unchecked return value
Date: Mon, 12 Oct 2020 14:11:50 +0100 [thread overview]
Message-ID: <20201012131150.GE565@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <80153586-6f6c-5227-9e0d-ffca61424045@intel.com>
On Mon, Oct 12, 2020 at 02:04:26PM +0100, Ferruh Yigit wrote:
> On 10/12/2020 1:45 PM, Bruce Richardson wrote:
> > On Mon, Oct 12, 2020 at 12:57:11PM +0100, Ferruh Yigit wrote:
> > > On 10/1/2020 6:09 PM, Kevin Laatz wrote:
> > > > Add a check for the return value of the sscanf call in
> > > > parse_internal_args(), returning an error if we don't get the expected
> > > > result.
> > > >
> > > > Coverity issue: 362049
> > > > Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
> > > >
> > > > ---
> > > > v2: added consumed characters count check
> > > > ---
> > > > drivers/net/ring/rte_eth_ring.c | 7 ++++++-
> > > > 1 file changed, 6 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> > > > index 40fe1ca4ba..66367465fd 100644
> > > > --- a/drivers/net/ring/rte_eth_ring.c
> > > > +++ b/drivers/net/ring/rte_eth_ring.c
> > > > @@ -538,8 +538,13 @@ parse_internal_args(const char *key __rte_unused, const char *value,
> > > > {
> > > > struct ring_internal_args **internal_args = data;
> > > > void *args;
> > > > + int n;
> > > > - sscanf(value, "%p", &args);
> > > > + if (sscanf(value, "%p%n", &args, &n) != 1 || (size_t)n != strlen(value)) {
> > >
> > > two small details,
> > >
> > > 1- I see following note in the sscanf manual: https://linux.die.net/man/3/sscanf
> > > "
> > > The C standard says: "Execution of a %n directive does not increment the
> > > assignment count returned at the completion of execution" but the
> > > Corrigendum seems to contradict this. Probably it is wise not to make any
> > > assumptions on the effect of %n conversions on the return value.
> > > "
> > >
> > > So what do you think checking return value as " == 0" ?
> > >
> >
> > Maybe in that copy of the man page but on my Ubuntu system there is no such
> > disclaimer, and I don't see it either on the kernel.org man page reference:
> >
> > https://man7.org/linux/man-pages/man3/sscanf.3.html
> >
> > That official man page reference clearly states that the behaviour is that
> > %n does not increase the reference count.
> >
>
> My Linux box also doesn't have that note, but just to prevent the PMD fails
> for something like this.
>
> Do you see any downside of checking as "sscanf() == 0"?
>
Nope, no issue with checking that too.
/Bruce
next prev parent reply other threads:[~2020-10-12 13:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 17:20 [dpdk-dev] [PATCH] " Kevin Laatz
2020-09-23 8:06 ` David Marchand
2020-09-23 9:39 ` Bruce Richardson
2020-09-23 9:43 ` David Marchand
2020-09-23 10:04 ` Kevin Laatz
2020-09-23 10:25 ` Bruce Richardson
2020-09-25 12:43 ` Ferruh Yigit
2020-10-01 14:14 ` Kevin Laatz
2020-10-01 14:51 ` Ferruh Yigit
2020-10-01 17:09 ` [dpdk-dev] [PATCH v2] " Kevin Laatz
2020-10-12 11:57 ` Ferruh Yigit
2020-10-12 12:45 ` Bruce Richardson
2020-10-12 13:04 ` Ferruh Yigit
2020-10-12 13:11 ` Bruce Richardson [this message]
2020-10-13 13:07 ` [dpdk-dev] [PATCH v3] " Kevin Laatz
2020-10-13 17:23 ` 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=20201012131150.GE565@bricha3-MOBL.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=kevin.laatz@intel.com \
--cc=stable@dpdk.org \
--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).