🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24781

Re: [PATCH net] netfilter: nf_queue: do not queue BPF syncookie request sockets

#24781
From: Nikolay Aleksandrov
Date: Mon, 30 Nov 2026 20:17
62 lines
14475 bytes
On 30/11/2026 13:48, Pablo Neira Ayuso wrote:
> On Sun, Nov 29, 2026 at 08:12:29AM -0800, Weiming Shi wrote:
>> bpf_sk_assign_tcp_reqsk() allocates a request socket with
>> inet_reqsk_alloc(ops, sk, false), stores the listener in
>> req->rsk_listener without taking a reference, and attaches it to the
>> skb with skb->destructor = sock_pfree.  Because neither the request
>> socket (rsk_refcnt == 0) nor req->rsk_listener is refcounted, the
>> listener pointer is only valid within the ingress RCU read-side
>> critical section.
>>
>> __nf_queue() lets the skb outlive that critical section while waiting
>> for a userspace verdict.  Its prefetched-socket check only handles
>> !sk_is_refcounted(sk), which is false for TCP_NEW_SYN_RECV because
>> sk_fullsock() is false for request sockets, and
>> nf_queue_entry_get_refs() only pins state->sk (NULL at prerouting).
>> If the listener is closed and its RCU grace period elapses while the
>> packet is queued, reinjection returns the freed req->rsk_listener from
>> skb_steal_sock() into inet_steal_sock() and tcp_v[46]_rcv():
>>
>>    BUG: KASAN: slab-use-after-free in tcp_v4_rcv (include/net/sock.h:2295
>>     include/net/inet_hashtables.h:458 include/net/inet_hashtables.h:496
>>     net/ipv4/tcp_ipv4.c:2121)
>>    Read of size 1 at addr ffff888025542812 by task exploit/194
>>    Call Trace:
>>     tcp_v4_rcv (net/ipv4/tcp_ipv4.c:2121)
>>     ip_protocol_deliver_rcu (net/ipv4/ip_input.c:207)
>>     ip_local_deliver_finish (net/ipv4/ip_input.c:241)
>>     ip_local_deliver (net/ipv4/ip_input.c:262)
>>     ip_rcv_finish (net/ipv4/ip_input.c:492)
>>     nfqnl_reinject (net/netfilter/nfnetlink_queue.c:544)
>>     nfqnl_recv_verdict (net/netfilter/nfnetlink_queue.c:1905)
>>     ...
>>     __x64_sys_sendto (net/socket.c:2286)
>>
>> 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.  Calling skb_orphan() instead would discard
>> the validated request socket and cause tcp_v[46]_rcv() to fail
>> cookie_tcp_check() and send a spurious RST on reinjection.  Matching
>> on !refcount_read(&sk->sk_refcnt) instead of inet_reqsk(sk)->syncookie
>> also avoids a data race against reqsk_timer_handler() updating
>> num_timeout in the same bitfield byte on hashed request sockets.
> 
> Cc: Nikolay.
> 
> I have seen working on this. I am not sure if this will require more
> checks in more spots (and more follow up incremental patches), which
> would be better to avoid.
> 

Indeed, this has been a part of larger set of fixes that were deferred
recently since a different proposal has been discussed in the past[2]:
https://lore.kernel.org/bpf/20261123084138.723275-1-razor@blackwall.org/
https://lore.kernel.org/bpf/3c96d878-0326-43c2-9869-e941cae675f4@linux.dev/

[2] and before that has been discussed:
https://lore.kernel.org/netdev/20260403015851.148209-1-jiayuan.chen@linux.dev/
https://lore.kernel.org/netdev/20260608125846.157004-1-jiayuan.chen@linux.dev/

Cheers,
  Nik
Technical Details
Message-ID: <b6a545aa-0327-459b-9400-1d6fae012ff1@blackwall.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374454-linux-kernel-netdev=dewy.ru
References: <20261129161228.4185092-2-bestswngs@gmail.com> <aw1ieNBG88kMLaob@chamomile>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374454-linux-kernel-netdev=dewy.ru
From: razor@blackwall.org (Nikolay Aleksandrov)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] netfilter: nf_queue: do not queue BPF syncookie
 request sockets
Date: Mon, 30 Nov 2026 22:17:44 +0200
Organization: Usenet Network
Message-ID: <b6a545aa-0327-459b-9400-1d6fae012ff1@blackwall.org>
References: <20261129161228.4185092-2-bestswngs@gmail.com>
 <aw1ieNBG88kMLaob@chamomile>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1528693"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:/imszSjeGAepTllf+1gNwVWGBQY= sha256:LN6a7M/lHuNnNlDjL7wTS/rMhvXZ1popwJuQ+taq/TA=
	sha1:H9buPqP08skc1JFaaCikkCJZ9Bs= sha256:0sgSq9SgwAm0k7ZQ1+yqq4qLnMcw5yxxr9D85XCgMps=
Content-Language: en-US, bg
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 E5335126001; Mon, 30 Nov 2026 23:18:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	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=blackwall.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 SiXeFY4d1lXp;
	Mon, 30 Nov 2026 23:18:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374454-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=blackwall.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A9E79126006; Mon, 30 Nov 2026 23:17:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B683328A34; Mon, 30 Nov 2026 20:17:50 +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=1796069869;
	b=oCDsOFUkAvNd7yPwmjsKzs46dm8nKAc8UV4C5P923RKQPVSUj1PZPQzedv0JyeL+yzkT
	 3oDyo40WTs7AwYByvOoa2r8b7i2Hna5NtnmMm2d/HbxxmUuV7v71D2+ORDxEHrnUm+qwB
	 In7jqU3zZyPwPvrevzx0AoacxuBqMACWpyqfaIkPpGoeGZcwnwk7ksbzIYVDsf8TlZ1MR
	 JSexyebQd7kfsSToRA3zWLCTrOVhbNxT/0h3sNMBCoFOZWL/SnnSozDKkTx+2+OWz6Cyy
	 WbiP5kxKPgvtgEV4ZW/rjGjdFJFnRQaF1LZqtNLZQF/dDUFcjKySPOPgrqP5Ygqgp3Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796069869;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:Message-ID:Date:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:User-Agent:Subject:Content-Language:To:Cc:
	 References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=oYIzlhbKG1vDNnVnObVA8NNvgz/s38KqJ+tsMtXJPWI=;
	b=J/bhKMhUCcFj45CqobLz6EjEGrMqRoStMw0a4EXKCcXlFtI4xFzo8qqBZNfSYBLV2B5W
	 J/h4hf6xpskguiWymOvTeJtSunY6ZSMVPONL3CTRCyMVOW4qKZNCNpu1ud6ez611ANmFq
	 S5DZg0vRQzpYrYMc3xS9pPpbnbePMv6LYfBOUoCm1DszQP2sOdbGoKjq7NRGybnWGe4PQ
	 y2aLOOpKY3rEv7saW8j7aCEGmaXqayaQaxj2aujoip4IF0Oewiwy7gypi5ZaBwFQSQIo2
	 1ByoqJxDDrCsRNzbXq2cTQkcE4+ED4NblXT9wrQU1UQsG73X0Vw+XLSvyGtEP3kuL0A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=WAaWkurN;
	dmarc=none header.from=blackwall.org;
	spf=none smtp.mailfrom=blackwall.org;
	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 AD82C606A685;
	Mon, 30 Nov 2026 20:17:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=WAaWkurN
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.52
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796069868;
	b=40lLO4p8HYjKflKQ5dumuemiKp5j8yjDMf2+oSm4NC/1iagcdsTzAmoHxII/YfL/E3mV
	 TJA1FLd5KdqqZRePZ1JQci9cmF/1+GjT+aXbDvp+IvMy6IZMnx0veXqPkkRIA5NNNNCzf
	 Nmr2hL12RAGCzhHHCBcubwAHNJqRssCnMgFkLx0ECVeP5oXBJrkAwZp/yyDYhk03F3qRL
	 HSGaqaNSSDhdIDqcV5r9Ht6uyVFGZOww4WSvE7sb57BIoNDvYUzbaauPzTV0D5eJj3TMn
	 eSZeQsUykBHo+jAiisXWqYyzaZ8O9xZaqO3hZNY6HiyZSwQU7PAnzp9VzbTZDLY0S6A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796069868;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Message-ID:Date:MIME-Version:User-Agent:Subject:Content-Language:To:
	 Cc:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=oYIzlhbKG1vDNnVnObVA8NNvgz/s38KqJ+tsMtXJPWI=;
	b=WuihUFYmxGQQS83/qywlRLCRjOghr1z98cPQzNyaPifgV9vKF7kOS0o+QPU4fSf2sWx2
	 LxmKedHy9lN2FfVkMnjjwbx5jF60r2Cft4ToyZfkWpxpdrDuJtnvLblWnzt8hmuklp4J8
	 ujTVa546oBLot0aBdIdUYg/dDxfvBpCT3qBk07EbOcF5RgtnuAbJ0uFzVe9orXNaGL6Lq
	 TkxA5jkjVIn5bZOgXsf2yY9rkzbhHe2fV5xLni6Edfv//8qQXmu6JOI614W43qBvlP797
	 T4NEiFFg+7pEfEQJlYL3h4Kdg9Skf5tgbk4LD09yeUNwEiWlsQMvDEQ2hg4SR3SeU8w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=blackwall.org;
	spf=none smtp.mailfrom=blackwall.org;
	dkim=pass header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=WAaWkurN;
	arc=none smtp.remote-ip=209.85.221.52
X-Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D9F1606A327
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 20:17:48 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7D9F1606A327
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=blackwall.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=blackwall.org
X-Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-4a32576da88so6382805f8f.3
        for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 12:17:48 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=blackwall.org; s=google; t=1796069867; x=1796674667; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from:references
         :cc:to:content-language:subject:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=oYIzlhbKG1vDNnVnObVA8NNvgz/s38KqJ+tsMtXJPWI=;
        b=WAaWkurNiIF7Wkkb0Nx+gnnoxIPCtsolIoYryIEOyoFXsEoWGj+j57Ly1HIwmeMKLg
         ZkmrT53VuVTfTud8ol7xM648Y6wBYhAxsB8G6gpIlijvx4TquxGEGgmzRyBR4ABomwKf
         XMkDX0leZMhgE/hc2s7gY6CI/2DDKA1YNIZzaZwpoz9WSgBp/Plwmwd7duLGZha6o5h5
         ejg03mAJ/iVQ1LTnoCLzqqXF5r+52C/FOolafoezKTsD10C3VN/4uiBUha+HZ9kIXEYE
         PL02/Wmjlmgomcpdh80YAs/e+1NE6wsm9NhP+pZEh8DPLF/bJqJ28S0ZPmet2USBZELB
         5U9A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796069867; x=1796674667;
        h=content-transfer-encoding:content-type:in-reply-to:from:references
         :cc:to:content-language:subject:user-agent:mime-version:date
         :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=oYIzlhbKG1vDNnVnObVA8NNvgz/s38KqJ+tsMtXJPWI=;
        b=MuhfyB8DsDgfHmj4c67gZXbA/wOE5CQKDmQyG4AoCUREhJ3kT5/0Tg6JnjUKhsKpcJ
         uXg4Lg5nmM2uXEfA8X++cdosSb4OxGDlMKtN60LZL4wLhL46ZSa63SmELidGNY9gQUfG
         +gAtHwn2VCHBhxyEnYqrOWrg7eVftIG3byw4bD9wa9vHfhwWcL+htlIcV+TwR4jeu5o+
         LFCGvG4IRubAyVQMaL1ivc276ORc74sVPQeXMeL12+vwTLcikDcA2DAkDhDuRMXpFNcU
         bvN0sbrtrVCC0K7U+LxJYq0IJBMm8Mg2UOhizdNm6N5GI/qtCfDrf7arOU2j855zryon
         SVxQ==
X-Forwarded-Encrypted: i=1; AL+hErHC70/+fLYVGCMpatOiKK5311A+24U3yINLsdByJiPHoxkG5Q7GYxPEZhmh9KJIqbd0RXqx968=@vger.kernel.org
X-Gm-Message-State: APuU4Z8/t6s9rEoe6eNYWZue+5Y4iBPJKrPTRsL5+HgBw+Xe7B/atdJM
	tqyw5RTw+EcYocOoT2ZVgGO8/h5u5SKs3aIc94Yfk/FzTDfpeXk5FQtwzP4s0/igTTQ=
X-Gm-Gg: AZFdTZdMJsDlOBMmXK00/t/wy19zyjy/AlQ5vttjEKL1sISWIcplRo647yKeT+vKKU5
	+j8l69ieyOixk/ChB0eEJpqLzUotkJTIDuhxMw8ddaEGYwXmuzJ+dGIYfXIxErXnylV51nT9lk4
	8CTI+6MFG4q2b6TxwGJzJ1doyToCW+tYTBJG3X38yfqEJkWe+SxOxnHRFZ+dH6QqWS+jZCCj1dN
	N7v29z+2JRPqNRvYbtL5JC/qczNqQk43XAjTjwjAHo4ukLz70GlGk8iQCvQx7tjpQ3ByjaQ3FZ9
	EcKtaR8HFX39jCpdIqai1VEHFq60HcA/ihKub1OrymKUBLWlqztFYSnlKqhz68GsRpfFrNYVPV5
	Tugr2DCynvket4rQzvjKkdxdkG2uiwUHcu9op+NpccaBkbvlMRHiMmLUGvOt6nSarydHSkaq1ff
	Nu1tCxMJhdSYQ+ErPkSWWEoqKJcvTrEN99pMuJuD48Le2K18qgt3Iqymq772pjPI9StCQNE7O17
	3pbBmG8V+BaYjPUGGVAyAE3HOsQfI9wUEAgg0cekx5g/ZimK3WTbnaXbQLE7DFRukkn35Vq9Hxk
	EphJdc3GGD/f4bQPSijG65rwM98lDO/t55DBr+E/dGJptF2UZdTMZOgJ2a4=
X-Received: by 2002:a05:6000:2b94:b0:4a8:714:7ad4 with SMTP id ffacd0b85a97d-4abb59e28a5mr42889009f8f.32.1796069866325;
        Mon, 30 Nov 2026 12:17:46 -0800 (PST)
X-Received: from [192.168.0.161] (78-154-14-127.ip.btc-net.bg. [78.154.14.127])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a68048esm69872817f8f.29.2026.11.30.12.17.45
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Mon, 30 Nov 2026 12:17:45 -0800 (PST)
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
X-User-Agent: Mozilla Thunderbird
X-Cc: Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
 "David S . Miller" <davem@davemloft.net>, Eric Dumazet
 <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>,
 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
 netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
 netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
 Xiang Mei <xmei5@asu.edu>, co+685321905e91e206@bugs.sh
X-In-Reply-To: <aw1ieNBG88kMLaob@chamomile>