From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 1/2] net: add missing syncookie statistics for BPF custom syncookies
Date: Tue, 28 Apr 2026 00:12:16 +0000 [thread overview]
Message-ID: <20260428001217.20C32C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260427001006.14465-2-jiayuan.chen@linux.dev>
Sashiko AI review found 1 potential issue(s):
- [Critical] Calling reqsk_free(req) leaves a dangling pointer in skb->sk, leading to a Use-After-Free and Double-Free during SKB destruction.
--
commit 8129f2cd328fc83b2ec7df7d84c626dcf9b375be
Author: Jiayuan Chen <jiayuan.chen@linux.dev>
net: add missing syncookie statistics for BPF custom syncookies
This commit updates BPF custom syncookie handling to use CONFIG_BPF_SYSCALL
instead of CONFIG_BPF, and adds a net parameter to cookie_bpf_check().
It also adds missing SNMP statistics for SYN cookie failures and receptions
in the BPF path.
> diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
> index df479277fb80..9251d4a15c88 100644
> --- a/net/ipv4/syncookies.c
> +++ b/net/ipv4/syncookies.c
[ ... ]
> @@ -305,6 +306,9 @@ struct request_sock *cookie_bpf_check(struct sock *sk, struct sk_buff *skb)
> if (cookie_tcp_reqsk_init(sk, skb, req)) {
> reqsk_free(req);
> req = NULL;
> + __NET_INC_STATS(net, LINUX_MIB_SYNCOOKIESFAILED);
This isn't a bug introduced by this patch, but does freeing the request socket
here leave a dangling pointer in skb->sk that leads to a use-after-free and
double-free during SKB destruction?
When BPF assigns a syncookie request_sock to skb->sk via
bpf_sk_assign_tcp_reqsk(), it sets the SKB's destructor to sock_pfree().
In tcp_v4_rcv(), skb_steal_sock() extracts the listener socket but
intentionally leaves skb->sk and skb->destructor intact for syncookie
request sockets.
If cookie_tcp_reqsk_init() fails, reqsk_free() is called, but skb->sk is not
cleared. When cookie_bpf_check() returns NULL, the caller drops the SKB via
kfree_skb().
During SKB destruction, sock_pfree(skb) is invoked, which reads the already
freed memory via sk->sk_state and then calls reqsk_free() a second time,
causing a double-free.
> + } else {
> + __NET_INC_STATS(net, LINUX_MIB_SYNCOOKIESRECV);
> }
>
> return req;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260427001006.14465-1-jiayuan.chen@linux.dev?part=1
next prev parent reply other threads:[~2026-04-28 0:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 0:09 [PATCH bpf-next v3 0/2] bpf,net: add missing custom syncookie statistics and add selftest Jiayuan Chen
2026-04-27 0:09 ` [PATCH bpf-next v3 1/2] net: add missing syncookie statistics for BPF custom syncookies Jiayuan Chen
2026-04-28 0:12 ` sashiko-bot [this message]
2026-04-27 0:09 ` [PATCH bpf-next v3 2/2] selftests/bpf: verify syncookie statistics in tcp_custom_syncookie Jiayuan Chen
2026-04-28 0:12 ` sashiko-bot
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=20260428001217.20C32C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jiayuan.chen@linux.dev \
--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