Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796062556; b=s8Dh5ekE5tTHXOyNpbgS2i2K7Rnb3hXBzrmbpIintqtClLRNbkyTwHHBAHjFj248dOo/ HzUPh1T2kUyNCOVkUA7Q+aiUtcLh0si8HUIO+JFTghpcWEHKoX4eThMrtFlYBbuzvQOyB RpGQUX0mPEaR/VQb9yXGLNPNT41n/Uduso9casjau5VVuk0mC2BRx1Aq6Ne46/fs785wo zEp1R9EbDoWvJr8/1qEm+7uxBrDTwJPNAjQhfTFLGtqw/qz+rCYsn439XV4bn3W/PZrh6 tI0lFhhWhea7GvcvJkKbp3U+d2zHbsVMluBjBTAaEM2UJYWGY6i3mllL4xXlUrwZfPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796062556; h=DMARC-Filter:DKIM-Signature:X-MC-Rep:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Message-ID:Date:MIME-Version:User-Agent:Subject: To:Cc:References:From:In-Reply-To:X-Mimecast-Spam-Score: X-Mimecast-MFC-PROC-ID:X-Mimecast-Originator:Content-Language: Content-Type:Content-Transfer-Encoding; bh=CQKx0x/qXhd7VwsVo0jCUGBlN5nhHbilVDrUqxr/mwU=; b=Ox6mkpQItkggDmuFFQQchkZeXkXLOo09nUnNDqGGsXfav7GNxbRLk3SgRAqxnUpGAxs9 voTK9FgqsB9lr5uOutWuQ+61bsZvcoc5EObo0F3jslQsax44NayHUkJVJyHGZ/18fJq4J 6scb+ypqaoKwSTUb31F6I96B7FWYgEB+evuHIoKnBWsQ9qqImnqyU9sgirzvofvAjS915 WOPjrS3b7/Grv6M6iNuux9Va1cU6ru1UfD1gx6iuHCd3tUaTFL1FLp+gzmcC+OS7GlVpg 4M6pw2JnL6NmnW76U/Yh5zZBIirCwe7O8mj78uc3m56ya7WfjVpkOnXYGaoeegJrTIg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VWq3fqyq; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2961606A31C for ; Mon, 30 Nov 2026 18:15:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D2961606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VWq3fqyq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796062554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CQKx0x/qXhd7VwsVo0jCUGBlN5nhHbilVDrUqxr/mwU=; b=VWq3fqyqz0MhXe0YHAm5Giczino+m67yz8Mdih6MQTh++luX6o3JftPpkUiEq6mAKbEckw L+lTMzs9Pekrxo/RWCc2r+tUyddF7utzPFxE4nbFkJY9DC7HBGp2tRzHTaHwnsFVP7YjEs XbjThKnNBEWmtwpO1OSIfMGo/YtHt84= X-MC-Rep: binary re single Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-yrXnTHMvPbGY734sWpMmkg-1; Mon, 30 Nov 2026 18:15:52 +0000 X-MC-Unique: yrXnTHMvPbGY734sWpMmkg-1 X-Mimecast-MFC-AGG-ID: yrXnTHMvPbGY734sWpMmkg_1796062551 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4bb818d8dcfso53522255e9.3 for ; Mon, 30 Nov 2026 10:15:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796062551; x=1796667351; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to: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=CQKx0x/qXhd7VwsVo0jCUGBlN5nhHbilVDrUqxr/mwU=; b=VEyhVJj2qNBufVTxU0oLL5/GMfeS5j8kJcbqzaloeHe4wZ+PeAOT3Z9Dm4ZeKNJ1kJ i7rROtNrn0UDmHP9P5cXwXbIkA4dJ3dMny6ns/GJ0nv8pi277Sc2LksC6tFFfxI8GMbD tJRCzkmupptputf8v1sX2VvOYDzSPDFJcFzWgZuHmE5VklPHYgRKrygaQWJV8y6kPm3y rq1jqolfDvbLjczVSXNrfrZubP6/J46vcyQD8WWgPwF+TcRdtoB/oCrGE6QKcZLqrgSe xdc9440zoUr74fgPzy4/8wzddiPJ4vMHrH3TAtY5oRdn6FsW6s3EvYyss5ZsSmEt3AuV i2NQ== X-Forwarded-Encrypted: i=1; AL+hErHsinMEFXvFV3sJwOmhONAAe/y0pnr8/KTC86uJrkZV7ol3hm7eckENdJMvLnpK6TicXqVoIw==@lists.linux.dev X-Gm-Message-State: APuU4Z/hnyxAVwh+7X4S/er47tIjUzIklZCPjFJdLW3nZcYeKZJXnYCH G/QAMprK/jNzr7UTtkM2X6kjPCA8GR2UePfSaxTxcbqWp5FoG8mzemv5xGJ64/8FZ3IAE0/WGvW iaYkbDzB2apm104XMaBIKrf8F/ydA61Qkjq7tlzzDBWhgJZUrDOiMUqGm X-Gm-Gg: AZFdTZcq8Gp3SAicJB2Lu8jpLO6bqs5Rn5zjGLPFXm/9iF63rZJI/kurU5UsujRSFNh xwMulsvcTnSAYSzlI4QAn/NQx3cbXTMGggoeH2atvPI91GKwke18eE6+le4Tz65KTBQdPLWGZm8 zv+WwyTqtV5YDKPkDtbtLlKSksENsef1GuEyTkiZ3+qvb44y88NMx7uOrKDG2Hmo56ZmXMbet49 UXo9vgQ0LL/VjyFYeETWJzdRCoPNdBgNEuUTbFhTjlVWxPINcS9KajAhdpTCazKEPm9O+u2/ALS gptV38WlzzV45OgstpSn2rmRgxnv82BEVUTE3rWRHvLfk9nOMJA6io4kpWWhDdgQiFvyxR5ElU+ Ngbkdxt1EFOspr4Skb8/x7TvwplUqO1HfwTwG5nOBUldHzpI8VM5EMJt8Sz0wnji4DL3zoEd4dg mnpWau6uZhONMQWC3kOnySDeUOaHGFCbPf6FO4iCMkKG4Y X-Received: by 2002:a05:600c:3b0e:b0:4a1:efba:511 with SMTP id 5b1f17b1804b1-4bb8882508emr728899945e9.35.1796062551418; Mon, 30 Nov 2026 10:15:51 -0800 (PST) X-Received: by 2002:a05:600c:3b0e:b0:4a1:efba:511 with SMTP id 5b1f17b1804b1-4bb8882508emr728899505e9.35.1796062551006; Mon, 30 Nov 2026 10:15:51 -0800 (PST) Received: from [192.168.88.30] (ip231-128-192-82.pool-bba.aruba.it. [82.192.128.231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884b8429sm1488606775e9.14.2026.11.30.10.15.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 10:15:50 -0800 (PST) Message-ID: Date: Mon, 30 Nov 2026 19:15:49 +0100 X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net 01/10] tcp: drain the queues of a listen() that fails To: Kuniyuki Iwashima , Neal Cardwell Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, Davide Caratti , Chris Mason , stable@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Simon Horman , Willem de Bruijn , Christoph Paasch , "Matthieu Baerts (NGI0)" , Mat Martineau , Eric Dumazet , Geliang Tang , Florian Westphal References: <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-0-278042217e8d@kernel.org> <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-1-278042217e8d@kernel.org> From: Paolo Abeni In-Reply-To: <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-1-278042217e8d@kernel.org> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _XRFRXadmuvkp2tp0ON1-aVPpl8xXd5fHxSZ_LhcvQ0_1796062551 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/23/26 14:24, Matthieu Baerts (NGI0) wrote: > From: Chris Mason > > If listen() fails on a TCP socket that has listened before, the sockets > of connections from the earlier listen() can leak, together with their > network namespace. > > inet_csk_listen_start() sets TCP_LISTEN before it calls get_port() and > hash(), and its error path sets TCP_CLOSE again, then purges the Fast > Open RST queue since commit 342e62fd34c2 ("tcp: purge Fast Open RST > queue when listen() fails"), but not the accept queue. Pending request > socks outlive an earlier listen() and still point to the socket, so in > TCP_LISTEN, inet_csk_reqsk_queue_add() adds them to the accept queue, > with their new child. These entries, and the sockets that they hold, > are never freed, since close() drains this queue only in TCP_LISTEN and > the next listen() stores NULL in rskq_accept_head. > > The fix used here is to call inet_csk_listen_stop() after the error path > sets TCP_CLOSE, which also purges the RST queue, except for an MPTCP > subflow, which needs mptcp_subflow_queue_clean() first: only its RST > queue is purged here, and mptcp_listen() has to drain its accept queue, > which is done in the next patch, "mptcp: drain the queues of a listen() > that fails". > > This issue has been found with the help of an LLM, and reproduced in a > VM, with the reproducer shared with the original version of this patch, > run as an unprivileged user: listen() failing with EADDRINUSE in a loop, > while the connections of an earlier listen() complete. Without this > patch, sockets were leaked, and network namespaces too when each round > was in its own one, without any message from the kernel: > > result: request socks: 10000 made, 2535 left. Sockets: 33373 made, 5070 left > [...] > result: namespaces: 1000 made, 694 taken down, 306 left > > Fixes: 079096f103fa ("tcp/dccp: install syn_recv requests into ehash table") > Cc: stable@vger.kernel.org > Signed-off-by: Chris Mason > [ Shorter comments. Commit message: how the issue was found, and its > symptoms. On top of commit 342e62fd34c2, with a Fixes tag for the > accept queue. ] > Signed-off-by: Matthieu Baerts (NGI0) @Kuniyuki, @Neal: an explicit ack would be appreciated here. /P