From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796083714; b=PvNR974Za7CeZVcJKUXUvEYVg8S7vgOVM0wwMWsDkTJBewN284LmqejYAYQm7SIs80YX nBGM+X1dWPerJEGUvaOznXNUtAvr2rbQx8wAM6D3fyApv8nIsBeTwo20Zfh0zR/hXDR9m j5f1tlaGa3388IPXl2ShrRj0DsRHsS8/a2p9M3VsVTMzX+TuP6WQVdz2T6/5JsbMSDauy woilqMBWyl3viPAKteds6POM9voJSg7HsXWIcwoYxDP0+gA0lFVK/j32+JRPJb2PY5W15 n38Ep8QuA+s0djAgH447rmayOoaZDwFJIgeAR0pHcp2pkrPZpqZ+OG8afhNEA7Kj7Bw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796083714; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=TpfV3XGxVaZaOE0hQUsACdbFdAVaGyDGAqd3ApIW89o=; b=qQV624MX77ZeQ+J7yD+/3Orj+6WR1cOlJXMzs/GPf7WaKqzWN+J+Fhu6pjwsYdowF5VK P0vyIo0kO/NB+7xbS3QMxf+PnmuEqJ9SeXQqxDvaHf6Cu6m/bnkaJCI5w3uq/sFIjXQSL WvNwtT+ddNa1O9rWyj0FRMdtICyibJvx4edrkyFzX5QKOgf9Q/RyE0AqIfqvISf86UGi8 1WhevvuVLLe/EVRz8GAl1qRTm72j3ntyZXsINUPIEOh6kW72WIJ8T3M3DnQBYZzAS3d9V ThurFqGTcn9CWhGWaX927OKCr6djwmegAf7eyMD3von9WC7zRfsbHl4TSZ5uDtrf5nA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=S13+hdGC; arc=none smtp.remote-ip=209.85.215.200 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (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 6B0ED606A31A for ; Tue, 1 Dec 2026 00:08:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B0ED606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=S13+hdGC Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cdd9fa2a558so8831798a12.0 for ; Mon, 30 Nov 2026 16:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796083714; x=1796688514; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=TpfV3XGxVaZaOE0hQUsACdbFdAVaGyDGAqd3ApIW89o=; b=S13+hdGCNjS+WNeMO4ZLVPE0Und3nyP79Ej4LXRCY5OLAhzAgxZIvDRrFgQMZH35Hy 1HoV8fAXlVa7kF+iiFwB6AWcCCzrBM2AkjIaO/SoMap6kSYYWVjNAILRtkgns/okUyPa iV6RbjF20ZE2lPwQf00JBrxd5uCzoUP9DFkYOfHjy5MZCvEuk/gsPlyU8Q+DGQp/3AIg 0M7DohZdd2+1iQ7Eit2JAwAea6LX4PyrsFUABIiXB7CxVPjfU61fGySCcoKAige4U3XA Fx79xn6iyHgc3biM6lBpbwPN16WhzPD5OxytdqNu7qIRr5TBp3xnaeF92OdNMki05cKw 8kaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796083714; x=1796688514; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TpfV3XGxVaZaOE0hQUsACdbFdAVaGyDGAqd3ApIW89o=; b=JxhPrK97zvmkh8NIEmk6NLnIyxnv3bCC0tpbZaca8DN9RQf5C43iU6gqpc3wbfjbwl g2onRYdadmNX7EWORdbFXff/XZynTS02WKS0JLSoAWUMGh7TCL5gHsdWz6n3dX+/7QPk rPWVKIQZMZnQY4C30X0cSkv5KzyEQ4HvAPNIYZtTbuMSS79+has4ZgX6u6CGkCAB77rW 96l+V0IrAPFYjkjjPN0a4JD2T2zC+ZjdiyEhFCqglIzQ+m1ynoyqm9ygsOI4XlkEsvVT PUpDGOKsmu/Ys7Q30OY4mnpvfjNlxYug3takcRHTl/hSftqYq6bUsejT/LPnJklhbke6 Bz1g== X-Forwarded-Encrypted: i=1; AL+hErFH1d/CsH6cp45k+YZHK1mNStQETPt3sZpyS4xUUGdYsXfgg1O16pDw/9oAvJcSvJLDdM+jV24=@vger.kernel.org X-Gm-Message-State: APuU4Z96kJWF33uTPD4LVUQbQpCQtzNMfHf0VS5Qf2G1LFVEQkvWodAs 0cVRylHw+3MNBeTuB3xc+8kNghz7MiIpfqyFV7z2sFSryvSY0+wVizsLLNNOHBgAE52iJ1odVKK VfYRmLg== X-Received: from pfak2.prod.google.com ([2002:aa7:92c2:0:b0:88c:e369:e5a4]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:ef0e:b0:3f9:7db7:735d with SMTP id adf61e73a8af0-4014bc55759mr31274960637.36.1796083713336; Mon, 30 Nov 2026 16:08:33 -0800 (PST) Date: Tue, 1 Dec 2026 09:08:32 +0900 In-Reply-To: X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 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> Message-ID: Subject: Re: [PATCH net 01/10] tcp: drain the queues of a listen() that fails From: Kuniyuki Iwashima To: Paolo Abeni Cc: Neal Cardwell , 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 Content-Type: text/plain; charset="us-ascii" On Mon, 30 Nov 2026 19:15:49 +0100, Paolo Abeni wrote: > 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. Sorry I missed this. Looks good, thanks ! Reviewed-by: Kuniyuki Iwashima