From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796083714; b=bHF51H3I0bUYbMiZwztWHx3ASNEqvQqJQmsS2Z4tfE1+stYhvZN+XgIReUwr8uFMF1L2 kreMb5dWzeuZqsZBj/iBiPRB+n88zjT5P5bc71HJLNb1BKAJWAS+2E9vnSP+l19GaZEmC uH4rSWf7f2SN+ylTDHYydGWpHu5vZjII2OtrdQ2Bf82siEu7YFoD9aTn/APuSNpOIDFkQ /GOguiZhu2kzqpbmR4j1AMxVY7B/+4xGTbQDqeNrFOUN3Qgp3kUHiuWwdnJIoPx4p7+Nc L10o3uLJ1Ejk2Iu7sqH0Ek5gax80+kajFsHEaVqSgU/Ywa7/lZ2xe1dQmtpbsJOJKrQ== 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=DeR+tHcJ9fFCNvxiNEN3LESICdrih8+c30fc4tW1TSu+LkVG/RN0qAFTmdPZPEBGt+kk 2cHjbVuGjKQ02PzUF4LtCEgAnIwPOyawrXElX5JzfGKWQSCL3XYohbtdz95fj12z9NEGr gWR8ggFx2nxzR5vj5kXqRUzR3LVCpExx3e2bBynIpzl1XdrF8kL3UkrE58dm6W0+T+iQv 1ajFPOwBze2jmHwvT+Km3kOTAzrxANGpgB8G3I6m0HoDRLhXy/rUrWUD61x+G9UnMe4dW 8MSMJeJB7Aej6BIc8ArU8mBbnAg/IJsIcaFc0B1QPqTmaCdQjkP5m/DqfkY10j9cxnw== 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=gYgPYigj; arc=none smtp.remote-ip=209.85.215.198 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 8C6F4606A325 for ; Tue, 1 Dec 2026 00:08:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8C6F4606A325 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=gYgPYigj Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cdb91e288d7so8574776a12.3 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=lists.linux.dev; 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=gYgPYigjwp5kmlTHWs8qzzNuYyYobEA+z9D+7Xd8jeTW/hSaK1VEDaFHSdNr8pFSDs yz9rfcE6d8l5Nj0zcMgHFyQIXUKy2n5vU67qdrD0/go5riOeio9ZCSIX/EZP2kHUbRas fsKsqrV4DuRijeitMX6AgCPlD5ERzJQcok/7xY0OgE+5J4n//Bm6WDFolZBPB+X7VdA/ wF9ktHDmskhgXWnmejvfo7ZsbW5mfn31Knkl9MwYmFSc9N0EeMaM89ssQbOptQxd36YR JOuSBU9POnS3oA3W95IwDUAVW4KX3YWS+UfgsaMR6jbfhltf89vFSQkHhxycqDNLxvNE F1Aw== 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=wmRsmHbmLYmPIn7RzZOuCy2ziTZIGsPr+Uy1ECxiafUemJOfCdqTIjOmCfGZvunNS1 kWsMarE2sv2ilOIUOtKR/I2j4y6ckmqDL+qZ8bEvxeTK4qH1eCMqTvYYUzVV77QB21Bw N6SIDZtVKOBcNf++edEtrxHDvYqeeD/qSircWSVAz6HSS8LwcyvCbiU+KXii8OMW2vhS avbMjhqA2ifGsHjrgNg1x3/rlW0w4tCR6cNhpgCD2o0LLVV9nNwF7Hd/1UuhChJBH4HP 2ZHXwH+jmxvnYGQKIDd0+Vb0kRpB3NJvG/t3pdyuNhPSnk77uGtMPSCq78Pda/nE7O7I jpIA== X-Forwarded-Encrypted: i=1; AL+hErH9TUs4skRyd3NWWjuP4TtkBaivDLANEfdKWjqWgTr0tALauW6qBHCzSv83Z/XKEKaR1a6aMg==@lists.linux.dev X-Gm-Message-State: APuU4Z9dqeW3+2cutZDsA1TeWohAqNByI5ReBM5c4Pwv+3tadr9kNBfY /8qsMCCaKNsqkN6p5/HktESaPPqrrZHuEyGh3xW+hR3vY0UBd6XoapCQ7uVNWWxwDXAPw2laHLD IJyB1GA== 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: mptcp@lists.linux.dev 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