From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Alexander Lobakin <aleksander.lobakin@intel.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Larysa Zaremba <larysa.zaremba@intel.com>,
Ilya Leoshkevich <iii@linux.ibm.com>, Song Liu <song@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+e1d1b65f7c32f2a86a9f@syzkaller.appspotmail.com
Subject: Re: [PATCH bpf-next 1/2] bpf, test_run: fix crashes due to XDP frame overwriting/corruption
Date: Thu, 16 Mar 2023 21:09:32 +0100 [thread overview]
Message-ID: <878rfwa26b.fsf@toke.dk> (raw)
In-Reply-To: <20230316175051.922550-2-aleksander.lobakin@intel.com>
Alexander Lobakin <aleksander.lobakin@intel.com> writes:
> syzbot and Ilya faced the splats when %XDP_PASS happens for bpf_test_run
> after skb PP recycling was enabled for {__,}xdp_build_skb_from_frame():
>
> BUG: kernel NULL pointer dereference, address: 0000000000000d28
> RIP: 0010:memset_erms+0xd/0x20 arch/x86/lib/memset_64.S:66
> [...]
> Call Trace:
> <TASK>
> __finalize_skb_around net/core/skbuff.c:321 [inline]
> __build_skb_around+0x232/0x3a0 net/core/skbuff.c:379
> build_skb_around+0x32/0x290 net/core/skbuff.c:444
> __xdp_build_skb_from_frame+0x121/0x760 net/core/xdp.c:622
> xdp_recv_frames net/bpf/test_run.c:248 [inline]
> xdp_test_run_batch net/bpf/test_run.c:334 [inline]
> bpf_test_run_xdp_live+0x1289/0x1930 net/bpf/test_run.c:362
> bpf_prog_test_run_xdp+0xa05/0x14e0 net/bpf/test_run.c:1418
> [...]
>
> This happens due to that it calls xdp_scrub_frame(), which nullifies
> xdpf->data. bpf_test_run code doesn't reinit the frame when the XDP
> program doesn't adjust head or tail. Previously, %XDP_PASS meant the
> page will be released from the pool and returned to the MM layer, but
> now it does return to the Pool with the nullified xdpf->data, which
> doesn't get reinitialized then.
> So, in addition to checking whether the head and/or tail have been
> adjusted, check also for a potential XDP frame corruption. xdpf->data
> is 100% affected and also xdpf->flags is the field closest to the
> metadata / frame start. Checking for these two should be enough for
> non-extreme cases.
>
> Fixes: 9c94bbf9a87b ("xdp: recycle Page Pool backed skbs built from XDP frames")
> Reported-by: syzbot+e1d1b65f7c32f2a86a9f@syzkaller.appspotmail.com
> Link: https://lore.kernel.org/bpf/000000000000f1985705f6ef2243@google.com
> Reported-by: Ilya Leoshkevich <iii@linux.ibm.com>
> Link: https://lore.kernel.org/bpf/e07dd94022ad5731705891b9487cc9ed66328b94.camel@linux.ibm.com
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
next prev parent reply other threads:[~2023-03-16 20:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 17:50 [PATCH bpf-next 0/2] double-fix bpf_test_run + XDP_PASS recycling Alexander Lobakin
2023-03-16 17:50 ` [PATCH bpf-next 1/2] bpf, test_run: fix crashes due to XDP frame overwriting/corruption Alexander Lobakin
2023-03-16 20:09 ` Toke Høiland-Jørgensen [this message]
2023-03-16 21:21 ` Ilya Leoshkevich
2023-03-16 17:50 ` [PATCH bpf-next 2/2] selftests/bpf: fix "metadata marker" getting overwritten by the netstack Alexander Lobakin
2023-03-16 20:10 ` Toke Høiland-Jørgensen
2023-03-17 13:38 ` Alexander Lobakin
2023-03-16 21:22 ` Ilya Leoshkevich
2023-03-17 13:40 ` Alexander Lobakin
2023-03-17 5:30 ` [PATCH bpf-next 0/2] double-fix bpf_test_run + XDP_PASS recycling patchwork-bot+netdevbpf
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=878rfwa26b.fsf@toke.dk \
--to=toke@redhat.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=hawk@kernel.org \
--cc=iii@linux.ibm.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=netdev@vger.kernel.org \
--cc=song@kernel.org \
--cc=syzbot+e1d1b65f7c32f2a86a9f@syzkaller.appspotmail.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