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/2026…%40gmail.com