From: Henning Schild <henning.schild@siemens.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>, dev@dpdk.org
Subject: Re: [PATCH] lib: do not call memcpy with sz zero and null pointer
Date: Wed, 21 Sep 2022 15:57:59 +0200 [thread overview]
Message-ID: <20220921155759.7d67d523@md1za8fc.ad001.siemens.net> (raw)
In-Reply-To: <6425132.G0QQBjFxQf@thomas>
Am Wed, 21 Sep 2022 15:06:12 +0200
schrieb Thomas Monjalon <thomas@monjalon.net>:
> 07/09/2022 17:05, Henning Schild:
> > There is no point in such a call and UBSan complains about a call to
> > memcpy with a null pointer as second arg.
> >
> > When building with -Db_sanitize=undefined, Clang gives the following
> > warning
> > ../lib/bpf/bpf_load.c:37:20: runtime error: null pointer passed as
> > argument 2, which is declared to never be null
> >
> > A check of the sz before calling memcpy fixes that.
> >
> > Signed-off-by: Henning Schild <henning.schild@siemens.com>
> > ---
> > --- a/lib/bpf/bpf_load.c
> > +++ b/lib/bpf/bpf_load.c
> > @@ -34,7 +34,8 @@ bpf_load(const struct rte_bpf_prm *prm)
> >
> > memcpy(&bpf->prm, prm, sizeof(bpf->prm));
> >
> > - memcpy(buf + bsz, prm->xsym, xsz);
> > + if (xsz)
> > + memcpy(buf + bsz, prm->xsym, xsz);*
>
> I assume I can safely change it to
> if (xsz > 0)
> to comply with the code style.
Sure, thanks!
Henning
>
> Applied, thanks.
>
>
prev parent reply other threads:[~2022-09-21 13:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 15:05 Henning Schild
2022-09-21 13:06 ` Thomas Monjalon
2022-09-21 13:57 ` Henning Schild [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=20220921155759.7d67d523@md1za8fc.ad001.siemens.net \
--to=henning.schild@siemens.com \
--cc=dev@dpdk.org \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=thomas@monjalon.net \
/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).