From: Stanislav Fomichev <stfomichev@gmail.com>
To: "Song, Yoong Siang" <yoong.siang.song@intel.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemb@google.com>,
"Bezdeka, Florian" <florian.bezdeka@siemens.com>,
Donald Hunter <donald.hunter@gmail.com>,
Jonathan Corbet <corbet@lwn.net>, Bjorn Topel <bjorn@kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@intel.com>,
"Fijalkowski, Maciej" <maciej.fijalkowski@intel.com>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Alexei Starovoitov <ast@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
"Damato, Joe" <jdamato@fastly.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Mina Almasry <almasrymina@google.com>,
Daniel Jurgens <danielj@nvidia.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykola Lysenko <mykolal@fb.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
"Nguyen, Anthony L" <anthony.l.nguyen@intel.com>,
"Kitszel, Przemyslaw" <przemyslaw.kitszel@intel.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"linux-stm32@st-md-mailman.stormreply.com"
<linux-stm32@st-md-mailman.stormreply.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"intel-wired-lan@lists.osuosl.org"
<intel-wired-lan@lists.osuosl.org>,
"xdp-hints@xdp-project.net" <xdp-hints@xdp-project.net>
Subject: Re: [PATCH bpf-next v5 2/4] selftests/bpf: Add launch time request to xdp_hw_metadata
Date: Wed, 15 Jan 2025 16:30:52 -0800 [thread overview]
Message-ID: <Z4hTPNEGreEo6igW@mini-arch> (raw)
In-Reply-To: <PH0PR11MB58300DA3845D1E3F788C4FC8D8192@PH0PR11MB5830.namprd11.prod.outlook.com>
On 01/15, Song, Yoong Siang wrote:
> On Wednesday, January 15, 2025 10:57 PM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> >On 1/14/25 4:27 PM, Song Yoong Siang wrote:
> >[...]
> >> + /* Add mqprio qdisc with TC and hardware queue one-to-one mapping */
> >> + char map[256] = {0};
> >> + char queues[256] = {0};
> >> +
> >> + for (i = 0; i < rxq; i++) {
> >> + char buf[8];
> >> +
> >> + snprintf(buf, sizeof(buf), "%d ", i);
> >> + strcat(map, buf);
> >> +
> >> + snprintf(buf, sizeof(buf), "1@%d ", i);
> >> + strcat(queues, buf);
> >> + }
> >> + run_command("sudo tc qdisc add dev %s handle 8001: parent root mqprio
> >num_tc %d map %s queues %s hw 0",
> >> + ifname, rxq, map, queues);
> >
> >Fyi, above triggers selftest build errors:
> >
> > xdp_hw_metadata.c: In function ‘main’:
> > xdp_hw_metadata.c:763:45: error: ‘%d’ directive output may be truncated
> >writing between 1 and 10 bytes into a region of size 8 [-Werror=format-
> >truncation=]
> > 763 | snprintf(buf, sizeof(buf), "%d ", i);
> > | ^~
> > TEST-OBJ [test_progs] arg_parsing.test.o
> > xdp_hw_metadata.c:763:44: note: directive argument in the range [0,
> >2147483646]
> > 763 | snprintf(buf, sizeof(buf), "%d ", i);
> > | ^~~~~
> > xdp_hw_metadata.c:763:17: note: ‘snprintf’ output between 3 and 12 bytes into
> >a destination of size 8
> > 763 | snprintf(buf, sizeof(buf), "%d ", i);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > xdp_hw_metadata.c:766:47: error: ‘%d’ directive output may be truncated
> >writing between 1 and 10 bytes into a region of size 6 [-Werror=format-
> >truncation=]
> > 766 | snprintf(buf, sizeof(buf), "1@%d ", i);
> > | ^~
> > xdp_hw_metadata.c:766:44: note: directive argument in the range [0,
> >2147483646]
> > 766 | snprintf(buf, sizeof(buf), "1@%d ", i);
> > | ^~~~~~~
> > xdp_hw_metadata.c:766:17: note: ‘snprintf’ output between 5 and 14 bytes into
> >a destination of size 8
> > 766 | snprintf(buf, sizeof(buf), "1@%d ", i);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Thanks for pointing this out.
> Btw, do you know which build command will trigger these errors?
> I am using "make -C tools/testing/selftests/bpf" but cannot
> reproduce the build error.
>
> Thanks & Regards
> Siang
Last time I used the following to reproduce similar issues on my side:
make -C tools/testing/selftests TARGETS="bpf" LLVM=1 USERCFLAGS="-Wformat-truncation"
You can also try to use something like asprintf instead of managing the buffer
sizes manually.
WARNING: multiple messages have this Message-ID (diff)
From: Stanislav Fomichev <stfomichev@gmail.com>
To: "Song, Yoong Siang" <yoong.siang.song@intel.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemb@google.com>,
"Bezdeka, Florian" <florian.bezdeka@siemens.com>,
Donald Hunter <donald.hunter@gmail.com>,
Jonathan Corbet <corbet@lwn.net>, Bjorn Topel <bjorn@kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@intel.com>,
"Fijalkowski, Maciej" <maciej.fijalkowski@intel.com>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Alexei Starovoitov <ast@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
"Damato, Joe" <jdamato@fastly.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Mina Almasry <almasrymina@google.com>,
Daniel Jurgens <danielj@nvidia.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykola Lysenko <mykolal@fb.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Jose Abreu <joabreu@synopsys.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
"Nguyen, Anthony L" <anthony.l.nguyen@intel.com>,
"Kitszel, Przemyslaw" <przemyslaw.kitszel@intel.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"linux-stm32@st-md-mailman.stormreply.com"
<linux-stm32@st-md-mailman.stormreply.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"intel-wired-lan@lists.osuosl.org"
<intel-wired-lan@lists.osuosl.org>,
"xdp-hints@xdp-project.net" <xdp-hints@xdp-project.net>
Subject: Re: [Intel-wired-lan] [PATCH bpf-next v5 2/4] selftests/bpf: Add launch time request to xdp_hw_metadata
Date: Wed, 15 Jan 2025 16:30:52 -0800 [thread overview]
Message-ID: <Z4hTPNEGreEo6igW@mini-arch> (raw)
In-Reply-To: <PH0PR11MB58300DA3845D1E3F788C4FC8D8192@PH0PR11MB5830.namprd11.prod.outlook.com>
On 01/15, Song, Yoong Siang wrote:
> On Wednesday, January 15, 2025 10:57 PM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> >On 1/14/25 4:27 PM, Song Yoong Siang wrote:
> >[...]
> >> + /* Add mqprio qdisc with TC and hardware queue one-to-one mapping */
> >> + char map[256] = {0};
> >> + char queues[256] = {0};
> >> +
> >> + for (i = 0; i < rxq; i++) {
> >> + char buf[8];
> >> +
> >> + snprintf(buf, sizeof(buf), "%d ", i);
> >> + strcat(map, buf);
> >> +
> >> + snprintf(buf, sizeof(buf), "1@%d ", i);
> >> + strcat(queues, buf);
> >> + }
> >> + run_command("sudo tc qdisc add dev %s handle 8001: parent root mqprio
> >num_tc %d map %s queues %s hw 0",
> >> + ifname, rxq, map, queues);
> >
> >Fyi, above triggers selftest build errors:
> >
> > xdp_hw_metadata.c: In function ‘main’:
> > xdp_hw_metadata.c:763:45: error: ‘%d’ directive output may be truncated
> >writing between 1 and 10 bytes into a region of size 8 [-Werror=format-
> >truncation=]
> > 763 | snprintf(buf, sizeof(buf), "%d ", i);
> > | ^~
> > TEST-OBJ [test_progs] arg_parsing.test.o
> > xdp_hw_metadata.c:763:44: note: directive argument in the range [0,
> >2147483646]
> > 763 | snprintf(buf, sizeof(buf), "%d ", i);
> > | ^~~~~
> > xdp_hw_metadata.c:763:17: note: ‘snprintf’ output between 3 and 12 bytes into
> >a destination of size 8
> > 763 | snprintf(buf, sizeof(buf), "%d ", i);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > xdp_hw_metadata.c:766:47: error: ‘%d’ directive output may be truncated
> >writing between 1 and 10 bytes into a region of size 6 [-Werror=format-
> >truncation=]
> > 766 | snprintf(buf, sizeof(buf), "1@%d ", i);
> > | ^~
> > xdp_hw_metadata.c:766:44: note: directive argument in the range [0,
> >2147483646]
> > 766 | snprintf(buf, sizeof(buf), "1@%d ", i);
> > | ^~~~~~~
> > xdp_hw_metadata.c:766:17: note: ‘snprintf’ output between 5 and 14 bytes into
> >a destination of size 8
> > 766 | snprintf(buf, sizeof(buf), "1@%d ", i);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Thanks for pointing this out.
> Btw, do you know which build command will trigger these errors?
> I am using "make -C tools/testing/selftests/bpf" but cannot
> reproduce the build error.
>
> Thanks & Regards
> Siang
Last time I used the following to reproduce similar issues on my side:
make -C tools/testing/selftests TARGETS="bpf" LLVM=1 USERCFLAGS="-Wformat-truncation"
You can also try to use something like asprintf instead of managing the buffer
sizes manually.
next prev parent reply other threads:[~2025-01-16 0:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 15:27 [PATCH bpf-next v5 0/4] xsk: TX metadata Launch Time support Song Yoong Siang
2025-01-14 15:27 ` [Intel-wired-lan] " Song Yoong Siang
2025-01-14 15:27 ` [PATCH bpf-next v5 1/4] xsk: Add launch time hardware offload support to XDP Tx metadata Song Yoong Siang
2025-01-14 15:27 ` [Intel-wired-lan] " Song Yoong Siang
2025-01-16 0:27 ` Stanislav Fomichev
2025-01-16 0:27 ` [Intel-wired-lan] " Stanislav Fomichev
2025-01-14 15:27 ` [PATCH bpf-next v5 2/4] selftests/bpf: Add launch time request to xdp_hw_metadata Song Yoong Siang
2025-01-14 15:27 ` [Intel-wired-lan] " Song Yoong Siang
2025-01-15 14:56 ` Daniel Borkmann
2025-01-15 14:56 ` [Intel-wired-lan] " Daniel Borkmann
2025-01-15 16:07 ` Song, Yoong Siang
2025-01-15 16:07 ` [Intel-wired-lan] " Song, Yoong Siang
2025-01-16 0:30 ` Stanislav Fomichev [this message]
2025-01-16 0:30 ` Stanislav Fomichev
2025-01-14 15:27 ` [PATCH bpf-next v5 3/4] net: stmmac: Add launch time support to XDP ZC Song Yoong Siang
2025-01-14 15:27 ` [Intel-wired-lan] " Song Yoong Siang
2025-01-14 15:27 ` [PATCH bpf-next v5 4/4] igc: " Song Yoong Siang
2025-01-14 15:27 ` [Intel-wired-lan] " Song Yoong Siang
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=Z4hTPNEGreEo6igW@mini-arch \
--to=stfomichev@gmail.com \
--cc=alexandre.torgue@foss.st.com \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=danielj@nvidia.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=florian.bezdeka@siemens.com \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jdamato@fastly.com \
--cc=joabreu@synopsys.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jonathan.lemon@gmail.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=mcoquelin.stm32@gmail.com \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=willemb@google.com \
--cc=xdp-hints@xdp-project.net \
--cc=xuanzhuo@linux.alibaba.com \
--cc=yonghong.song@linux.dev \
--cc=yoong.siang.song@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.