From: "Toke Høiland-Jørgensen" <toke@kernel.org>
To: Yury Vostrikov <mon@unformed.ru>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: bpf@vger.kernel.org
Subject: Re: NULL pointer deref inside xdp_do_flush due to bpf_net_ctx_get_all_used_flush_lists
Date: Tue, 01 Oct 2024 15:36:09 +0200 [thread overview]
Message-ID: <875xqcq71y.fsf@toke.dk> (raw)
In-Reply-To: <5627f6d1-5491-4462-9d75-bc0612c26a22@app.fastmail.com>
"Yury Vostrikov" <mon@unformed.ru> writes:
> Hi,
>
> I stumbled upon a NULL pointer derefence inside BPF code. The triggering condition is
> message from OOM killer + netconsole. The crash happens at
>
> u32 kern_flags = bpf_net_ctx->ri.kern_flags;
>
> line of bpf_net_ctx_get_all_used_flush_lists() function. bpf_net_ctx is NULL here. With trivial fix
>
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index 7d7578a8eac1..cba16bf307f7 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -844,6 +844,9 @@ static inline void bpf_net_ctx_get_all_used_flush_lists(struct list_head **lh_ma
> struct list_head **lh_xsk)
> {
> struct bpf_net_context *bpf_net_ctx = bpf_net_ctx_get();
> + WARN_ON(bpf_net_ctx == NULL);
> + if (bpf_net_ctx == NULL)
> + return;
> u32 kern_flags = bpf_net_ctx->ri.kern_flags;
> struct list_head *lh;
>
> I get the following backtrace instead of crash:
[...]
> [ 177.216474] efx_poll+0x178/0x380 [sfc_siena]
Looks like the sfc driver is missing the context setup stuff entirely...
-Toke
prev parent reply other threads:[~2024-10-01 13:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 11:30 NULL pointer deref inside xdp_do_flush due to bpf_net_ctx_get_all_used_flush_lists Yury Vostrikov
2024-10-01 13:36 ` Sebastian Andrzej Siewior
2024-10-01 14:01 ` Edward Cree
2024-10-01 14:04 ` Sebastian Andrzej Siewior
2024-10-01 13:36 ` Toke Høiland-Jørgensen [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=875xqcq71y.fsf@toke.dk \
--to=toke@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=mon@unformed.ru \
/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