From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86C0C1F00896; Mon, 30 Nov 2026 16:14:12 +0000 (UTC) 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== Subject: Re: [PATCH net] netfilter: nf_queue: do not queue BPF syncookie request sockets From: netdev-bot+sashiko@kernel.org To: bestswngs@gmail.com 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 Date: Mon, 30 Nov 2026 16:14:12 +0000 Message-ID: <179605525205.3146.8322072085993490126@kernel.org> In-Reply-To: <20261129161228.4185092-2-bestswngs@gmail.com> References: <20261129161228.4185092-2-bestswngs@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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