From: sashiko-bot@kernel.org
To: "Ren Wei" <enjou1224z@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v2 1/1] bpf: Check sk_state before sk_protocol in bpf_tcp_*_syncookie
Date: Tue, 04 Aug 2026 15:34:25 +0000 [thread overview]
Message-ID: <20260804153426.5B1FC1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <6218aa3534d0d2d3f448fde70a8dc2769d7a8201.1785823138.git.rakukuip@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch completely misses an identical slab out-of-bounds read vulnerability in the `bpf_sock_destroy` kfunc when a mini-socket is passed.
--
--- Patch [1]: [PATCH bpf v2 1/1] bpf: Check sk_state before sk_protocol in bpf_tcp_*_syncookie ---
commit fe03c404200965b4022b50ca58915a717cbea479
Author: Luxiao Xu <rakukuip@gmail.com>
bpf: Check sk_state before sk_protocol in bpf_tcp_*_syncookie
This commit fixes a slab out-of-bounds read vulnerability in the
bpf_tcp_gen_syncookie and bpf_tcp_check_syncookie helpers. It ensures
sk_state is checked before accessing sk_protocol to avoid reading past
the memory boundary of mini-sockets.
Link: https://lore.kernel.org/all/ca8d8c570509b02355bb4bd4e56859f3e2564c9c.1785576172.git.rakukuip@gmail.com/
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 11bb0d236822a..16845987b2449 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -7684,7 +7684,7 @@ BPF_CALL_5(bpf_tcp_check_syncookie, struct sock *, sk, void *, iph, u32, iph_len
> return -EINVAL;
>
> /* sk_listener() allows TCP_NEW_SYN_RECV, which makes no sense here. */
> - if (sk->sk_protocol != IPPROTO_TCP || sk->sk_state != TCP_LISTEN)
> + if (sk->sk_state != TCP_LISTEN || sk->sk_protocol != IPPROTO_TCP)
> return -EINVAL;
[Severity: High]
This isn't a bug introduced by this patch, but does the same slab
out-of-bounds read occur in bpf_sock_destroy()?
It looks like bpf_sock_destroy() takes a struct sock_common but casts it
unconditionally to struct sock before accessing sk->sk_protocol, which
could also be a mini-socket (like request_sock or inet_timewait_sock).
net/core/filter.c:bpf_sock_destroy() {
...
if (!sk->sk_prot->diag_destroy || (sk->sk_protocol != IPPROTO_TCP &&
sk->sk_protocol != IPPROTO_UDP))
return -EOPNOTSUPP;
...
}
Should we validate the socket type before dereferencing sk->sk_protocol
there too?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/6218aa3534d0d2d3f448fde70a8dc2769d7a8201.1785823138.git.rakukuip@gmail.com?part=1
next prev parent reply other threads:[~2026-08-04 15:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 14:29 [PATCH bpf v2 0/1] bpf: Check sk_state before sk_protocol in bpf_tcp_*_syncookie Ren Wei
2026-08-04 14:29 ` [PATCH bpf v2 1/1] " Ren Wei
2026-08-04 15:01 ` Eric Dumazet
2026-08-04 15:34 ` sashiko-bot [this message]
2026-08-04 17:50 ` Kuniyuki Iwashima
2026-08-05 20:30 ` [PATCH bpf v2 0/1] " 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=20260804153426.5B1FC1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=enjou1224z@gmail.com \
--cc=sashiko-reviews@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