Article View: linux.kernel.netdev
Article #24688Re: [PATCH net] netfilter: nf_queue: do not queue BPF syncookie request sockets
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 16:14
Date: Mon, 30 Nov 2026 16:14
129 lines
12380 bytes
12380 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In net/netfilter/nf_queue.c, __nf_queue() now returns
-ENOTCONN for every prefetched TCP_NEW_SYN_RECV socket with refcnt 0,…
- [Medium] The commit message says only that nf_queue() 'drops the skb',
and argues this beats skb_orphan() because skb_orphan() would cause a…
--
netfilter: nf_queue: do not queue BPF syncookie request sockets
This patch makes __nf_queue() reject skbs that carry a prefetched,
unrefcounted TCP_NEW_SYN_RECV request socket, the kind created by
bpf_sk_assign_tcp_reqsk(). It returns -ENOTCONN so that nf_queue() drops
the skb. The goal is to stop the skb from outliving the ingress RCU
section while req->rsk_listener is not pinned.
> diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
> index bd603e3a99a59..54d902169065e 100644
> --- a/net/netfilter/nf_queue.c
> +++ b/net/netfilter/nf_queue.c
> @@ -198,6 +198,10 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
> if (skb_sk_is_prefetched(skb)) {
> struct sock *sk = skb->sk;
>
> + if (READ_ONCE(sk->sk_state) == TCP_NEW_SYN_RECV &&
> + !refcount_read(&sk->sk_refcnt))
> + return -ENOTCONN;
> +
[Severity: Medium]
Does this early return also drop packets that nfnetlink_queue would have
passed through in the same RCU section?
The check runs before qh->outfn(), so nfnetlink_queue never sees these
skbs. Two configurations look affected.
The first is --queue-bypass with no daemon bound to the queue.
nfqnl_enqueue_packet() used to return -ESRCH here:
net/netfilter/nfnetlink_queue.c:nfqnl_enqueue_packet() {
...
queue = instance_lookup(q, queuenum);
if (!queue)
return -ESRCH;
...
}
nf_queue() treats only that case as a bypass:
net/netfilter/nf_queue.c:nf_queue() {
...
if (ret < 0) {
if (ret == -ESRCH &&
(verdict & NF_VERDICT_FLAG_QUEUE_BYPASS))
return 1;
kfree_skb(skb);
}
...
}
The second is NFQA_CFG_F_FAIL_OPEN when the queue is full or the unicast
fails. In that case __nfqnl_enqueue_packet() reinjects synchronously:
if (failopen)
nfqnl_reinject(entry, NF_ACCEPT);
In both cases the skb stayed inside the current RCU read-side section, so
the stale req->rsk_listener could not be hit.
With this patch __nf_queue() returns -ENOTCONN, which nf_queue() does not
treat as a bypass, so it calls kfree_skb(). Will BPF SYN cookie ACKs then
be silently dropped in exactly the setups that are configured to fail
open?
[Severity: Medium]
Does the commit message describe how wide the effect of this check is?
It says:
Reject prefetched unrefcounted TCP_NEW_SYN_RECV request sockets in
__nf_queue() with -ENOTCONN before the !sk_is_refcounted() check so
nf_queue() drops the skb.
bpf_sk_assign_tcp_reqsk() allocates a new unrefcounted request socket on
every call:
net/core/filter.c:bpf_sk_assign_tcp_reqsk() {
...
req = inet_reqsk_alloc(ops, sk, false);
...
req->rsk_listener = sk;
req->syncookie = 1;
...
skb->sk = req_to_sk(req);
skb->destructor = sock_pfree;
...
}
As a result, every cookie ACK the BPF program validates (including
retransmissions) matches the new check. If an NFQUEUE verdict applies on
the ingress path, the packet is dropped, so the client sees an
established connection that the server never accepts.
Before this patch the combination failed only when the listener closed
while a packet was queued. After it, bpf_sk_assign_tcp_reqsk() and
NFQUEUE look like they cannot work together at all.
Could the commit message state this? The other approach, pinning
req->rsk_listener on struct nf_queue_entry the way the existing
refcount_inc_not_zero()/sock_edemux handling pins prefetched sockets,
appears only below the cut line. Would that approach be preferable here,
since it keeps this combination working?
> if (!sk_is_refcounted(sk)) {
> if (!refcount_inc_not_zero(&sk->sk_refcnt))
> return -ENOTCONN;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129161228.4185092-2-bestswngs%40gmail.com
Technical Details
Message-ID:
<179605525205.3146.8322072085993490126@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374309-linux-kernel-netdev=dewy.ruReferences:
<20261129161228.4185092-2-bestswngs@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374309-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] netfilter: nf_queue: do not queue BPF syncookie request sockets Date: Mon, 30 Nov 2026 16:14:12 +0000 Organization: Usenet Network Message-ID: <179605525205.3146.8322072085993490126@kernel.org> References: <20261129161228.4185092-2-bestswngs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1465301"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:cLuzkDnO2IW8MePvN43kXiHHmyI= sha256:eODrD3ZywCMjeGsnlnf9Epmqx9uQ4WcJkM906/qG508= sha1:5a1wgPQfZ4G6Bkgh41nAKTXA5wU= sha256:z7YoSRpmn1dNgwzeyZ+qH5y2vSgM1TKblMXyWSqG/o0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 42B27125FF5; Mon, 30 Nov 2026 19:14:33 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O5SWPtvjMWVe; Mon, 30 Nov 2026 19:14:29 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374309-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 10393125FF2; Mon, 30 Nov 2026 19:14:20 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id B742A27C7B; Mon, 30 Nov 2026 16:14:17 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796055255; b=GWWlTQ4ioXE6B97DInyNGcyNIiPIUS9IG646lsH6DC00NlkUJ3fJK1LKQy5bFGkxCYMz DSCwJxUyGVEszcpXCrgeyUspUL5/5zElz0eZnoi4iQ1nWkA4fflN7FbFdKGdLqlI5N16e u7yWBJ49PJNl6WE2pXTciuV+HN0vBIOH3fucwdHQmn6qxmBD4/rhxsS1svj4bsuCvavjR lSSxp+L2U0LVynVUwjfoTUD6JF/876TqyhooMgYSL4+aQ4L5JVDRsJ/RAVfkkg45NsRdo AkUeE2g9XHDAxuj4Rj37SGARQObCgIZpousgSHcd3T3rBVO/c2l4aL6ZICk9tjI0jew== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796055255; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=sH+boAF0N3rRlhqNd7SzQ2r1LAyh5ICwI52uPjTjuAA=; b=f+9xtAZmerwrBCko8hKon8K22ohG+MpfeDElQF+zz062QmIbVzl//A25Tk8zFDGSRYhD DKRtM9OOFzi4wYThmAKaucMQJ55vxTT+5yqmLmyQMX7Ex4LfthI59VFAzu8qzvEsRlLre L2h+UOtPmApmoSrugeMKK1Gyyk+7xZbKv87bzOn50/bboOlYfofJUo6iQnIMqrWGm/Haq bqukVCWpzWZmWah+T6yH9XpbV8tWInOpeYy1oyne65Mv86wwavbQqdvRuR98Nh6HqaHCR xS55AijLwEE4fakV16PpjoBLMrrYtre/e906Sd9B7fJiY1B3gZHWuFHs0cM+U+umE9Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gQeFXX6J; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEC73606A332; Mon, 30 Nov 2026 16:14:14 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gQeFXX6J X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796055254; b=XYerTnHzdzTxVm9klCpNhAiJs2qGHFkaC9QjuPlREgVNoQGvNnM7Xj24FqYbwLfhRCni 3RT+O22+74AbhyUQX/N/1zCspFDyr4CShk8l7DqLetYwZsRPnlFoVyBcMyvt3GNcKeonZ UZTZchvAMT04f+jLoIgf+DIqHNfei6y5OmTZk1h24nCpmVzl6I88aVuWyvhYAyR5DX5tx Axo7uATzb+1/pcjsPuyFgzBcdTjP2/aGE7OdmdZVFIXv+Ulic51luUBdGavNgiIu5yITK 3bdBKHuOTfE8IA6YgNY0PMvAQbnkQUfEzn4bK9sA0+rLkp3br6EJ1J5jL2/v11PgX8g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796055254; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=sH+boAF0N3rRlhqNd7SzQ2r1LAyh5ICwI52uPjTjuAA=; b=W5YD9eKZ63D9FdfsFtyOdVSflVsL+zWymhwQOovxIcasVOjCibFwDJ8LOzQBei05yKAi 7A/FTnuXAPS48rhOTWNLtYZb+IgSJXCF+A2AednGZhM5ZVt16+T0nUePhlrKxxucAs4gv yoovBj12vtlIWD2fLmdP1n2yWKAqEomx5opxx7fba/ybu/iUsA+7DlQAmhAGU9t6rrtH7 J9hqof5fsfHIxNPSLaWzKKMXpNY56kQfkGf3hF2GeSUGMN+FZht7vMLd9I/SnCBDk/1Km qWYklwc0eZ2ghtuZThVv9tQ7SCrctQbGESDgnm0Ygeh7q2MzK3aNFxJTWlFFNLSTncA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gQeFXX6J; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05DCE606A31C; Mon, 30 Nov 2026 16:14:13 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86C0C1F00896; Mon, 30 Nov 2026 16:14:12 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796055253; bh=sH+boAF0N3rRlhqNd7SzQ2r1LAyh5ICwI52uPjTjuAA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=gQeFXX6JqlWub+Z7oijbeldSa1LHe0MBvt/4YL5f9rz0dvam4N6Nm5wTdL2Vbco+y lEY8Vu+CrQFuksiOXjlb9ViI8eb90AIE4B3G6ThyPo6XZYtY3ku3dj7bLDBac6QDgu H+MsOO8E4ZbBSvpT7KoQZ3Dx0MNsjLG75DAzU6WP+R54CTS3vMEgXl2SxySA0A0Hqp jMD4cdjl1uT2hojPrNiVT4oLZFLBQiz+U4A8wIAoUksuCU+XtnyC6HMGNA4v6caRGI 8OGt1Yoa42SpD8wxbWaokmkIhwaQXgs6ODyiz/V6PjsPWYKd6FXuZa8XPVgM03c/hn LzrEY4U3u6m9w== X-Cc: pablo@netfilter.org, fw@strlen.de, phil@nwl.cc, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, xmei5@asu.edu, co+685321905e91e206@bugs.sh X-In-Reply-To: <20261129161228.4185092-2-bestswngs@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list