πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9962

Re: [PATCH net v5 1/2] inet: reject unhashed sockets during established lookups

#9962
From: netdev-bot+sashiko
Date: Mon, 02 Nov 2026 22:06
77 lines
10938 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In this commit by itself, the new
  `hlist_nulls_unhashed_lockless(&sk->sk_nulls_node)` check in…

--

inet: reject unhashed sockets during established lookups

This commit adds a hlist_nulls_unhashed_lockless() check after the
reference is taken in __inet_lookup_established() and
__inet6_lookup_established(). A lookup that races with SLAB_TYPESAFE_BY_RCU
reuse can no longer return a request socket that was never hashed. It also
changes the SYN cookie, Fast Open and request migration failure paths to
drop references with reqsk_put() instead of calling __reqsk_free().

> diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
> index 5abcb0debb270..b0239d203f045 100644
> --- a/net/ipv4/inet_hashtables.c
> +++ b/net/ipv4/inet_hashtables.c
> @@ -552,8 +552,9 @@ struct sock *__inet_lookup_established(const struct net *net,
>  		if (likely(inet_match(net, sk, acookie, ports, dif, sdif))) {
>  			if (unlikely(!refcount_inc_not_zero(&sk->sk_refcnt)))
>  				goto out;
> -			if (unlikely(!inet_match(net, sk, acookie,
> -						 ports, dif, sdif))) {
> +			if (unlikely(hlist_nulls_unhashed_lockless(&sk->sk_nulls_node) ||
> +				     !inet_match(net, sk, acookie, ports, dif,
> +						 sdif))) {

[Severity: Low]
If this commit is applied by itself, is the new unhashed check ordered
after the refcount increment?

refcount_inc_not_zero() here is a relaxed cmpxchg. The writers that make
never-hashed request sockets referenceable also use a plain refcount_set():

net/ipv4/syncookies.c:tcp_get_cookie_sock() {
    ...
	if (child) {
		refcount_set(&req->rsk_refcnt, 1);
    ...
}

The same applies to tcp_fastopen_create_child(), and to the migration
clones in reqsk_timer_handler(), inet_csk_complete_hashdance() and
inet_csk_listen_stop().

On weakly ordered CPUs, can the pprev load in
hlist_nulls_unhashed_lockless() and the inet_match() reload be satisfied
before the increment? They could then see the old, hashed incarnation,
while the increment succeeds on the new, unhashed SYN cookie request whose
rsk_listener is NULL. That is the tcp_v4_rcv() NULL dereference this
commit describes. __inet6_lookup_established() has the same pattern.

The next patch in the series, "net: restore refcount ordering for lockless
socket access", resolves this. It switches both lookups to
refcount_inc_not_zero_acquire(), and switches tcp_get_cookie_sock(),
tcp_fastopen_create_child() and the three migration writers to
refcount_set_release().

Both patches are tagged Cc: stable. Should the two be backported together,
so stable trees don't pick up this one without the ordering fix?

>  				sock_gen_put(sk);
>  				goto begin;
>  			}

[ ... ]

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261029214219.1035176-1-imv4bel%40gmail.com
Technical Details
Message-ID: <179365718057.3131.4671197978037510599@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355076-linux-kernel-netdev=dewy.ru
References: <20261029214219.1035176-2-imv4bel@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355076-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5 1/2] inet: reject unhashed sockets during
 established lookups
Date: Mon, 02 Nov 2026 22:06:20 +0000
Organization: Usenet Network
Message-ID: <179365718057.3131.4671197978037510599@kernel.org>
References: <20261029214219.1035176-2-imv4bel@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3042815"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xheltFDWOxMPb0Zn1Io/Ld4xkaI= sha256:ryt11uHMDobwC9+IEgh6RCgnVv3WnuehZVD8EY6Jp3Q=
	sha1:1z+2AzmQAgVXnBImaGbxq7fy/Bw= sha256:qYs75UaY13RWYU+MWOY+fmteIiv1kyNF/HjpXtodBzg=
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 137A81126AA; Tue,  3 Nov 2026 01:12:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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, URIBL_BLOCKED=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 on5GidMgU7zk;
	Tue,  3 Nov 2026 01:12:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-355076-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 80A43112668; Tue,  3 Nov 2026 01:12:17 +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 40A0431D3B; Mon,  2 Nov 2026 22:06:34 +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=1793657188;
	b=eTILWdQ+pdVpL9FzrGadBCxqmVGj3cQ33KlMScou2G232jG95UiEWg80+kfskUA9m1rq
	 PZkOzIgqiPVakrMgV9E3q7opG/LIsx0n7T1J387zP3/4Y6g+h6hjSBN2IauXt1RLdWCQd
	 DFZ/5xqlJxG8YJwotRX+C4/G3Sj/C21V74rLcN9uGC+Uw2OIMoD+t7veCrKsyRcxGtWXX
	 FnqMzJ3zLcEOn+6Tmds0GImvWQ2xGLMI1KXR2AmReDh5sVILxjCNpQEcX4fUi/WWewwWT
	 kPcXfv4t6m+nBXPe/1ZuY5EArFYhAjd/3QPCO4+3aOSRhZHa5C6G22LULnkKGxFQuxQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793657188;
	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=Um07/kiEpvfKEz+oA0JV8ogF50fMeuEiH91twRDY2rE=;
	b=UxfCjl13xLxE+yPRrhobA19iCAsw7e4r2h00hDe2BSARgbzmshoZnsVVZlFniRtNsfJo
	 5pB9eVOgg0Vx9guDG7EZ/htNZlKST8Xya5zCjwObTGwVs6g2kzemAr6MrxJ2v2z1eElLc
	 POV8Qbu/afRlyF9JiaJK1nzm0fQf9s2TmnCEYc0urnfar3N0aaaKf6qxzsy2llriggdF1
	 /W2RaAGFadocSkYY6kKvEzo9I8QrsuZ0ETrLhybpqmkFvjGYNMhWSeAXueLCgHxvtKE1m
	 qYa8YYjdEDZ5HdpSc9WyOtJbJPm6x9v+OoCbylIrVWHDkvaC8oxs0lGN6QrTOKQD4Ag==
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=Jw8uLxxn;
	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 4EE7D606A32C;
	Mon,  2 Nov 2026 22:06:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Jw8uLxxn
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=1793657182;
	b=jf8qOwFioWAuWIdRmvBRYEjmrK+4Y6Lt8cVFCQi6stqUL6OWv7GLvCGeCbn83N2cvqvN
	 ac7NS+ukfhv/VAxYYblBdtKZPZKnRRRi3/NivlctrjGNFDz1qIHoHPT+nl8dEata4avQ/
	 Nsrnuez4+Oi5JhqmtlsfDlsPwEZsSnDW9VJuu/hxYEg+4sjnxxNiNy/XAyOabh1PvoFTn
	 GvmtHbQpb0DMms4zhb7FBTjwRtOoc55z7OqMF9MwmjWxL5vxthW0mwlSfskXn9SKi2Zmv
	 NVb476fgt/77m36MryZQBtVJZ2+V41eNFASQhkTKF/vr1YPPU5Qfd01hLjKdfgZn8mQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793657182;
	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=Um07/kiEpvfKEz+oA0JV8ogF50fMeuEiH91twRDY2rE=;
	b=IQXLLEkOiOmJMRlRhuIwZ0lkvbt2hcxP088KAx2iOUhwHqMTVuj3S5U/aSUh8YTCqkmu
	 6GcjS8zhcFWM5DX9MEbV8zmVeD9vYyla1y8UFDA5dwQSoXQgUVvcpMK+6nYvJO8JUDrAO
	 i7yR73OUU3RrRlSJpsjZ4gynZyYErQhs7+UQKELNPSsU1y5aQ3fPtAzCvPN8BuGzwLH93
	 EpM1cxYsFORtEXi9df8HkcLy7ZjUV22v57Nzib+lsWoGpeU+0GFDvU0k5UtGOSGW6g4Ck
	 JLfM+f4jft+3Yxoarldao3ADt5ZhnzL8TzkmLog7xF7usXOGNB9FQFIXS75IBtkdhZA==
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=Jw8uLxxn;
	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 2CF63606A329;
	Mon,  2 Nov 2026 22:06:21 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07ACE1F00A16;
	Mon,  2 Nov 2026 22:06:20 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793657181;
	bh=Um07/kiEpvfKEz+oA0JV8ogF50fMeuEiH91twRDY2rE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Jw8uLxxnoQskGA+iwpftLPclOxu4AuAOvBvwzxu1OBYaSNwMCIvLHTAMEK21uGlkX
	 7P12cuk9IrDK+Qimk4z7l6qVLFK2jxGfgchzRlAfNbhxqVbX0R41/iedGThfqoWEv0
	 jXZ8OVhPiopwo7SQUC5SkH5Fs9H4vXgL9lKLpwPSBkMEVY6DInnriVfgJAMRJ3FOeO
	 aMpUgYpMWbThjMvp2CtC6cD0rvjTX4Fjhjfq45ugsSm0aJEdWk3Wh94QUtn40awBzV
	 X/uwTgQoeErFRmLWtjhNYQ+qgS4j0nHBduPrqgPnI7f4iuSR2wrYlEWMSKYOgIEDCn
	 P7vdF6IKqP63A==
X-Cc: edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com,
 davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 martin.lau@linux.dev, john.fastabend@gmail.com, weiwan@google.com,
 sd@queasysnail.net, jiayuan.chen@linux.dev, netdev@vger.kernel.org,
 stable@vger.kernel.org
X-In-Reply-To: <20261029214219.1035176-2-imv4bel@gmail.com>
X-sashiko-severity: Low
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