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=1796083715; b=ZMVXJIbNa9+KtsZ8TjMhLIEJYayLCDbWp/ViSgakRBMgWS/tymzSeOQDuzMqTzDLMOMP iRVB7ZultApXm/V1pzw731HQHCwHhUl92LmQm1n/ZUmkKTyk9wq5hBLdNrpGnKwbkLcEZ GiR4fFSdtfM3OBj6CUJpLG/ZgbCnPXpuuN+9g/GBufJj691RV7myS6KhyhcuLBzxByR0V ZmURxLyUyFu//v/c3mmkLdPziUGLTgv8XEFUYPQQ0EVqOJAxYBNIbv28TQc2fJjMUJ0Gb U7PhucFarwW38L+gMAyjAaZdTV7J7fIPafeImtmBPyGubmMJg0Mnos+Q6gdidjUSs9Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796083715; 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=xfErhQ8gjVoM9Xx8kKGNoqIIaKkGPJ5v7SwsKAe7PDV/2vvzNHqTBNoU2Ou7V/NUqWrd FJ533upbQt26Tm5hzh2FHQRVfiGN6J7ffGIKucGIosbg2y5QJAmRO+VE5jiOPGTSmkB6R XZ1iHx8gMVvPe5s1r5Q90XZtoz6lMnHam9wvcTS6tEARmpvdtvpaSuQJW76/ytR3e+G7g pQXW+ER5WbMhZLAa9DdNZ7dM4RegFUj5mvvbS8Wl34PU/mWWrINtSs8CEWfWTFagStKUy Sy/xg6ruSLtrReSoQPPcnMdg5BHlVutKXoPFM+645/jjFrJQB75edQU5LZtQk2S5p4Q== 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 6B185606A320 for ; Tue, 1 Dec 2026 00:08:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B185606A320 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-cdea3a64d1bso5553455a12.1 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=XbGE8Zfc3bTKEAmETRIHwIXd+ER+z998Rd7IE9zfxl2JtyRAIATfFtvzYn/8xvBQen 3Yqe8vdKPKYsa0hQ0Eu0ZbatFhSPMVvI7TGwwAYjzklyzYTnY1vCPslMURBlyzcuPJw1 bTQi1meCiDyYY7DuWui0aMiQAxdKJDogqPDGlNZU9l6vTHZ9Xuniz/ejQ1vexFpYoN4j 8my+CrUD4B8GIPmW26VSrjpKWaCUqpNeyAbEnjOa7NTnxk5KuQIUq2Jat5HnsW8kjvyk MEIWZ+HERz5iHcppZKXRAJ4pqkZm2u8ZaM5sBvGlDogYj3IKpY7pAHWD4hfv24sGOgos rwug== X-Forwarded-Encrypted: i=1; AL+hErHAVAttMBoyIIm1t58EoselUC8Mr3zBtW7Kpa+ytLf/EREhsBQokIdbF9bQukG4ZHwpUawdPaY=@vger.kernel.org X-Gm-Message-State: APuU4Z/hoVsQqjRD+42V6TaNgVMzCsxLkZ5VzraytpSh6oaTYb4WM4v+ OtOkiFTC9fQnB8SIwGd3GjMw3A1eIDJUo72nmRfB8+HQIEfNPPVhjejont7camBG7ukvnaK/RpO chaTcjg== 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: stable@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