From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Alexander Lobakin <aleksander.lobakin@intel.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
"Larysa Zaremba" <larysa.zaremba@intel.com>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Song Liu" <song@kernel.org>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Menglong Dong" <imagedong@tencent.com>,
"Mykola Lysenko" <mykolal@fb.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>, bpf <bpf@vger.kernel.org>,
"Network Development" <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next v3 0/4] xdp: recycle Page Pool backed skbs built from XDP frames
Date: Wed, 15 Mar 2023 19:00:47 +0100 [thread overview]
Message-ID: <e07dd94022ad5731705891b9487cc9ed66328b94.camel@linux.ibm.com> (raw)
In-Reply-To: <de59c0fca26400305ab34cc89e468e395b6256ac.camel@linux.ibm.com>
On Wed, 2023-03-15 at 15:54 +0100, Ilya Leoshkevich wrote:
> On Wed, 2023-03-15 at 11:54 +0100, Alexander Lobakin wrote:
> > From: Alexander Lobakin <aleksander.lobakin@intel.com>
> > Date: Wed, 15 Mar 2023 10:56:25 +0100
> >
> > > From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> > > Date: Tue, 14 Mar 2023 16:54:25 -0700
> > >
> > > > On Tue, Mar 14, 2023 at 11:52 AM Alexei Starovoitov
> > > > <alexei.starovoitov@gmail.com> wrote:
> > >
> > > [...]
> > >
> > > > test_xdp_do_redirect:PASS:prog_run 0 nsec
> > > > test_xdp_do_redirect:PASS:pkt_count_xdp 0 nsec
> > > > test_xdp_do_redirect:PASS:pkt_count_zero 0 nsec
> > > > test_xdp_do_redirect:FAIL:pkt_count_tc unexpected pkt_count_tc:
> > > > actual
> > > > 220 != expected 9998
> > > > test_max_pkt_size:PASS:prog_run_max_size 0 nsec
> > > > test_max_pkt_size:PASS:prog_run_too_big 0 nsec
> > > > close_netns:PASS:setns 0 nsec
> > > > #289 xdp_do_redirect:FAIL
> > > > Summary: 270/1674 PASSED, 30 SKIPPED, 1 FAILED
> > > >
> > > > Alex,
> > > > could you please take a look at why it's happening?
> > > >
> > > > I suspect it's an endianness issue in:
> > > > if (*metadata != 0x42)
> > > > return XDP_ABORTED;
> > > > but your patch didn't change that,
> > > > so I'm not sure why it worked before.
> > >
> > > Sure, lemme fix it real quick.
> >
> > Hi Ilya,
> >
> > Do you have s390 testing setups? Maybe you could take a look, since
> > I
> > don't have one and can't debug it? Doesn't seem to be Endianness
> > issue.
> > I mean, I have this (the below patch), but not sure it will fix
> > anything -- IIRC eBPF arch always matches the host arch ._.
> > I can't figure out from the code what does happen wrongly :s And it
> > happens only on s390.
> >
> > Thanks,
> > Olek
> > ---
> > diff --git
> > a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> > b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> > index 662b6c6c5ed7..b21371668447 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> > @@ -107,7 +107,7 @@ void test_xdp_do_redirect(void)
> > .attach_point = BPF_TC_INGRESS);
> >
> > memcpy(&data[sizeof(__u32)], &pkt_udp, sizeof(pkt_udp));
> > - *((__u32 *)data) = 0x42; /* metadata test value */
> > + *((__u32 *)data) = htonl(0x42); /* metadata test value */
> >
> > skel = test_xdp_do_redirect__open();
> > if (!ASSERT_OK_PTR(skel, "skel"))
> > diff --git
> > a/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
> > b/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
> > index cd2d4e3258b8..2475bc30ced2 100644
> > --- a/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
> > +++ b/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
> > @@ -1,5 +1,6 @@
> > // SPDX-License-Identifier: GPL-2.0
> > #include <vmlinux.h>
> > +#include <bpf/bpf_endian.h>
> > #include <bpf/bpf_helpers.h>
> >
> > #define ETH_ALEN 6
> > @@ -28,7 +29,7 @@ volatile int retcode = XDP_REDIRECT;
> > SEC("xdp")
> > int xdp_redirect(struct xdp_md *xdp)
> > {
> > - __u32 *metadata = (void *)(long)xdp->data_meta;
> > + __be32 *metadata = (void *)(long)xdp->data_meta;
> > void *data_end = (void *)(long)xdp->data_end;
> > void *data = (void *)(long)xdp->data;
> >
> > @@ -44,7 +45,7 @@ int xdp_redirect(struct xdp_md *xdp)
> > if (metadata + 1 > data)
> > return XDP_ABORTED;
> >
> > - if (*metadata != 0x42)
> > + if (*metadata != __bpf_htonl(0x42))
> > return XDP_ABORTED;
> >
> > if (*payload == MARK_XMIT)
>
> Okay, I'll take a look. Two quick observations for now:
>
> - Unfortunately the above patch does not help.
>
> - In dmesg I see:
>
> Driver unsupported XDP return value 0 on prog xdp_redirect (id
> 23)
> dev N/A, expect packet loss!
I haven't identified the issue yet, but I have found a couple more
things that might be helpful:
- In problematic cases metadata contains 0, so this is not an
endianness issue. data is still reasonable though. I'm trying to
understand what is causing this.
- Applying the following diff:
--- a/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
+++ b/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
@@ -52,7 +52,7 @@ int xdp_redirect(struct xdp_md *xdp)
*payload = MARK_IN;
- if (bpf_xdp_adjust_meta(xdp, 4))
+ if (false && bpf_xdp_adjust_meta(xdp, 4))
return XDP_ABORTED;
if (retcode > XDP_PASS)
causes a kernel panic even on x86_64:
BUG: kernel NULL pointer dereference, address: 0000000000000d28
...
Call Trace:
<TASK>
build_skb_around+0x22/0xb0
__xdp_build_skb_from_frame+0x4e/0x130
bpf_test_run_xdp_live+0x65f/0x7c0
? __pfx_xdp_test_run_init_page+0x10/0x10
bpf_prog_test_run_xdp+0x2ba/0x480
bpf_prog_test_run+0xeb/0x110
__sys_bpf+0x2b9/0x570
__x64_sys_bpf+0x1c/0x30
do_syscall_64+0x48/0xa0
entry_SYSCALL_64_after_hwframe+0x72/0xdc
I haven't looked into this at all, but I believe this needs to be
fixed - BPF should never cause kernel panics.
next prev parent reply other threads:[~2023-03-15 18:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 21:55 [PATCH bpf-next v3 0/4] xdp: recycle Page Pool backed skbs built from XDP frames Alexander Lobakin
2023-03-13 21:55 ` [PATCH bpf-next v3 1/4] selftests/bpf: robustify test_xdp_do_redirect with more payload magics Alexander Lobakin
2023-03-13 21:55 ` [PATCH bpf-next v3 2/4] net: page_pool, skbuff: make skb_mark_for_recycle() always available Alexander Lobakin
2023-03-13 21:55 ` [PATCH bpf-next v3 3/4] xdp: recycle Page Pool backed skbs built from XDP frames Alexander Lobakin
2023-03-15 14:55 ` Jesper Dangaard Brouer
2023-03-15 14:58 ` Alexander Lobakin
2023-03-16 17:10 ` Jesper Dangaard Brouer
2023-03-17 13:36 ` Alexander Lobakin
2023-03-13 21:55 ` [PATCH bpf-next v3 4/4] xdp: remove unused {__,}xdp_release_frame() Alexander Lobakin
2023-03-14 11:37 ` Yunsheng Lin
2023-03-14 12:27 ` Alexander Lobakin
2023-03-14 11:57 ` [PATCH bpf-next v3 0/4] xdp: recycle Page Pool backed skbs built from XDP frames Alexander Lobakin
2023-03-14 18:52 ` Alexei Starovoitov
2023-03-14 23:54 ` Alexei Starovoitov
2023-03-15 9:56 ` Alexander Lobakin
2023-03-15 10:54 ` Alexander Lobakin
2023-03-15 14:54 ` Ilya Leoshkevich
2023-03-15 18:00 ` Ilya Leoshkevich [this message]
2023-03-15 18:12 ` Alexander Lobakin
2023-03-15 18:26 ` Ilya Leoshkevich
2023-03-16 13:22 ` Alexander Lobakin
2023-03-15 16:55 ` Alexei Starovoitov
2023-03-14 22:30 ` patchwork-bot+netdevbpf
-- strict thread matches above, loose matches on Subject: below --
2023-03-13 21:42 Alexander Lobakin
2023-03-16 11:57 ` Alexander Lobakin
2023-03-13 19:08 Alexander Lobakin
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=e07dd94022ad5731705891b9487cc9ed66328b94.camel@linux.ibm.com \
--to=iii@linux.ibm.com \
--cc=aleksander.lobakin@intel.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=imagedong@tencent.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=song@kernel.org \
--cc=toke@redhat.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