From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "MahnurA" <s.mahnur.a@gmail.com>, <bpf@vger.kernel.org>,
<ast@kernel.org>, <daniel@iogearbox.net>
Cc: <netdev@vger.kernel.org>, <andrii@kernel.org>
Subject: Re: [PATCH bpf] bpf: Fix NULL pointer dereference in bpf_sock_from_file
Date: Wed, 19 Aug 2026 15:44:19 -0400 [thread overview]
Message-ID: <DKT6EZTQI7LB.3ENA5VQ5OVMNQ@etsalapatis.com> (raw)
In-Reply-To: <20260818174253.492196-1-s.mahnur.a@gmail.com>
On Tue Aug 18, 2026 at 1:42 PM EDT, MahnurA wrote:
> bpf_sock_from_file should not dereference a NULL file pointer.
> KASAN detects a null-ptr-deref when eBPF tracing
> fentry/fexit programs are attached to points such as
> __mmap_region and file_map_prot_check kernel functions. This can
> result in a NULL file pointer flowing from context to the helper.
>
> A minimal check before dereferencing can fix this.
>
> Fixes: b60da4955f53 ("bpf: Only provide bpf_sock_from_file with CONFIG_NET")
> Signed-off-by: MahnurA <s.mahnur.a@gmail.com>
Patch looks fine and the crash replicates. Please resend with a full
name since we don't take pseudonymous contributions. Once you do,
please feel free to add my reviewed-by tag.
pw-bot: cr
> ---
> net/core/filter.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 16845987b244..7c3caae4bafc 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -12182,7 +12182,10 @@ const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto = {
>
> BPF_CALL_1(bpf_sock_from_file, struct file *, file)
> {
> - return (unsigned long)sock_from_file(file);
> + if (file)
> + return (unsigned long)sock_from_file(file);
> +
> + return (unsigned long)NULL;
> }
>
> BTF_ID_LIST(bpf_sock_from_file_btf_ids)
prev parent reply other threads:[~2026-08-19 19:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 17:42 [PATCH bpf] bpf: Fix NULL pointer dereference in bpf_sock_from_file MahnurA
2026-08-18 19:13 ` bot+bpf-ci
2026-08-19 19:44 ` Emil Tsalapatis [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=DKT6EZTQI7LB.3ENA5VQ5OVMNQ@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=s.mahnur.a@gmail.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