From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: ast@kernel.org, "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: syzbot <syzbot+e1d1b65f7c32f2a86a9f@syzkaller.appspotmail.com>,
<bpf@vger.kernel.org>, <daniel@iogearbox.net>,
<davem@davemloft.net>, <edumazet@google.com>, <hawk@kernel.org>,
<john.fastabend@gmail.com>, <kuba@kernel.org>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<pabeni@redhat.com>, <syzkaller-bugs@googlegroups.com>
Subject: Re: [syzbot] [bpf?] [net?] BUG: unable to handle kernel NULL pointer dereference in __build_skb_around
Date: Wed, 15 Mar 2023 13:54:41 +0100 [thread overview]
Message-ID: <9acb9b6e-d998-fd7e-c370-3b6160cfda40@intel.com> (raw)
In-Reply-To: <ec94dad7-188b-96d8-9005-74f507d96967@intel.com>
From: Alexander Lobakin <aleksander.lobakin@intel.com>
Date: Wed, 15 Mar 2023 13:51:23 +0100
> From: Alexander Lobakin <aleksander.lobakin@intel.com>
> Date: Wed, 15 Mar 2023 13:10:44 +0100
>
>> From: Syzbot <syzbot+e1d1b65f7c32f2a86a9f@syzkaller.appspotmail.com>
>> Date: Wed, 15 Mar 2023 05:03:47 -0700
>>
>>> Hello,
[...]
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index 6a8b33a103a4..5b9ca36ff21d 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -217,12 +217,12 @@ static bool ctx_was_changed(struct xdp_page_head *head)
>
> static void reset_ctx(struct xdp_page_head *head)
> {
> - if (likely(!ctx_was_changed(head)))
> - return;
> + if (unlikely(!ctx_was_changed(head))) {
Must be `unlikely(ctx_was_changed(head))` obviously, I've got attention
deficit or what :D
> + head->ctx.data = head->orig_ctx.data;
> + head->ctx.data_meta = head->orig_ctx.data_meta;
> + head->ctx.data_end = head->orig_ctx.data_end;
> + }
>
> - head->ctx.data = head->orig_ctx.data;
> - head->ctx.data_meta = head->orig_ctx.data_meta;
> - head->ctx.data_end = head->orig_ctx.data_end;
> xdp_update_frame_from_buff(&head->ctx, &head->frm);
> }
>
> ---
> Alternative version, which fixes only this particular problem, but is
> less safe as still assumes only xdpf->data could be nulled-out. It can
> save a bunch o'cycles on hotpath tho, thus attaching it as well:
>
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index 6a8b33a103a4..55789772f039 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -217,13 +217,15 @@ static bool ctx_was_changed(struct xdp_page_head *head)
>
> static void reset_ctx(struct xdp_page_head *head)
> {
> - if (likely(!ctx_was_changed(head)))
> - return;
> + if (unlikely(ctx_was_changed(head))) {
(here it's correct)
> + head->ctx.data = head->orig_ctx.data;
> + head->ctx.data_meta = head->orig_ctx.data_meta;
> + head->ctx.data_end = head->orig_ctx.data_end;
> + head->frm.data = NULL;
> + }
>
> - head->ctx.data = head->orig_ctx.data;
> - head->ctx.data_meta = head->orig_ctx.data_meta;
> - head->ctx.data_end = head->orig_ctx.data_end;
> - xdp_update_frame_from_buff(&head->ctx, &head->frm);
> + if (head->frm.data != head->ctx.data)
> + xdp_update_frame_from_buff(&head->ctx, &head->frm);
> }
>
> static int xdp_recv_frames(struct xdp_frame **frames, int nframes,
Olek
prev parent reply other threads:[~2023-03-15 12:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 12:03 [syzbot] [bpf?] [net?] BUG: unable to handle kernel NULL pointer dereference in __build_skb_around syzbot
2023-03-15 12:10 ` Alexander Lobakin
2023-03-15 12:51 ` Alexander Lobakin
2023-03-15 12:54 ` Alexander Lobakin [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=9acb9b6e-d998-fd7e-c370-3b6160cfda40@intel.com \
--to=aleksander.lobakin@intel.com \
--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=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+e1d1b65f7c32f2a86a9f@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--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