From: sashiko-bot@kernel.org
To: "Weiming Shi" <bestswngs@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf] bpf: Fix NULL pointer dereference in bpf_sk_storage_clone and diag paths
Date: Tue, 21 Apr 2026 18:09:34 +0000 [thread overview]
Message-ID: <20260421180934.AAADBC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260420161432.3919396-2-bestswngs@gmail.com>
Sashiko AI review found 1 potential issue(s):
- [Medium] diag_get() returns -EMSGSIZE when a storage element is concurrently deleted, which falsely signals an out-of-buffer condition to the netlink subsystem.
--
commit 522b6760e7969af1ad0bb15843d5c06084d686f7
Author: Weiming Shi <bestswngs@gmail.com>
bpf: Fix NULL pointer dereference in bpf_sk_storage_clone and diag paths
This commit addresses a NULL pointer dereference in bpf_sk_storage_clone
and diagnostic paths by adding checks for when a concurrent RCU reader
observes a storage element with a NULL smap.
> diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
> index 14eb7812bda4a..3e21d79558154 100644
> --- a/net/core/bpf_sk_storage.c
> +++ b/net/core/bpf_sk_storage.c
[ ... ]
> @@ -544,6 +544,8 @@ static int diag_get(struct bpf_local_storage_data *sdata, struct sk_buff *skb)
> return -EMSGSIZE;
>
> smap = rcu_dereference(sdata->smap);
> + if (!smap)
> + goto errout;
When a storage element is concurrently deleted, smap evaluates to NULL here
and goes to errout, which returns -EMSGSIZE.
In netlink diagnostics, doesn't -EMSGSIZE specifically signal an
out-of-buffer condition?
Could propagating -EMSGSIZE for a concurrently deleted element cause socket
dumps to unnecessarily abort the current message and retry, or cause
exact-match diagnostic queries to falsely fail with an EMSGSIZE error
returned to userspace?
Would it be better to return 0 after cancelling the nested attribute to
gracefully skip the deleted element, or perhaps pass the already validated
smap from the caller directly into diag_get()?
> if (nla_put_u32(skb, SK_DIAG_BPF_STORAGE_MAP_ID, smap->map.id))
> goto errout;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260420161432.3919396-2-bestswngs@gmail.com?part=1
prev parent reply other threads:[~2026-04-21 18:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 16:14 [PATCH bpf] bpf: Fix NULL pointer dereference in bpf_sk_storage_clone and diag paths Weiming Shi
2026-04-20 18:36 ` Martin KaFai Lau
2026-04-21 18:09 ` sashiko-bot [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=20260421180934.AAADBC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bestswngs@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
/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