From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796062557; b=rsrIOMQM50gbaspp3WG2TusfdHaO+bbpSmlgVQTOONwj9SCDkEzI1od+N+EiUHhAQXxQ S6NbtWtIu1/QduZkhK/ejCaEnI3of2tyTr1U2eQMYZ/Mrn+AX/nUGDqGBftTyuoOiOaRT 0HzUEVvLM9R6LnJa5cjcApQbILTW5pjUS8F+b7IKuun5N5/cZY7wZ4ua6ePQS+HihkMEy uVAVVFNdPw0VUtVIFOi2col5P1giHNx58ciHBT/b9n10q0g9NwgcHT9GMuRQZNVchZ1zC EJbNGM0ZhoNl6XA/+zkGyiqnBM8U4z64NRBKpteBZ2/URfTVtVR5PGDHwfv/ZH9o7ag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796062557; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=CQKx0x/qXhd7VwsVo0jCUGBlN5nhHbilVDrUqxr/mwU=; b=Y3kPl1/4ht51vFZrwethG4MFAOaFbARI/gdFClcIHJKDuaq3pdNwIZ7j7FPgeI6xPDaC P7scKblbDoSKrnFtixUQH4trO21dLgZDOXBBkqV+iC4/1Xn+EJp04ohNlYJ6yCqWev8mR MzYi21KQx+laN+X+dukRdHHL8b+ryRtWeOGFKJCbZL8xfM85RhW48OWHvimqirVEEjhj1 hLqW4T8nvUwadbcHOHozaQVzMTARNeh9oGJ37cAeoA67n/v1UeUEcugGBZBM2jTsbAdpJ b5piSBzV/Xd2Hgr3AAaZpU/u4kJiDSz8JGuxc5EuARTs8X4dnf6rLoPNNF/zJydk01g== 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=GkZgz9DT; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=JWSBEPuX; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 8A343606A327 for ; Mon, 30 Nov 2026 18:15:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8A343606A327 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=GkZgz9DT; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=JWSBEPuX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796062555; 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=GkZgz9DTdOc/1I3PuW9GrHDkp91+H7/Pqrh95FB2nxq4OnTIuVPGYCnsFFMW3Tea/QbRVJ Y5dYqme7mTi3i7XogzW+jLbEypHUObWgm039h/HzdSByy/P6JNPDTWXirjXLkRoGs6945p gEBm8j1TggRICX/46g7+ykJNVVxQVkA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-144-Ikq3i6nNN5CmYFtCw1-PlA-1; Mon, 30 Nov 2026 18:15:52 +0000 X-MC-Unique: Ikq3i6nNN5CmYFtCw1-PlA-1 X-Mimecast-MFC-AGG-ID: Ikq3i6nNN5CmYFtCw1-PlA_1796062551 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4a68703d177so5196895f8f.2 for ; Mon, 30 Nov 2026 10:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796062551; x=1796667351; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CQKx0x/qXhd7VwsVo0jCUGBlN5nhHbilVDrUqxr/mwU=; b=JWSBEPuX7C2iLdCzPwiv7zGSy94SbXIbGx6XLm5dgBTnQOYEY9ISIq8GcOZ2kIf7Qw bCn977RmBXJIOaHEQXaVipPcs4cniP1p9xIF7A8+3FO3izUWzy7+DBjH5O0hMsqVu9X3 UN3c6Frn+VkbPhXZZJi/wII2ZLvUuvAFe0V3OJXsNKTLhKZIHOxKQcqmVSlMD50sD3aj Ap8AgPhjhzHL/6n8dbBAzLP+VbDJ19c57ogJctSQAzmajQGUHR+eGgk0M+34VPTuP1WW GvgAktgH7SjOcUpqRvbj8QVMcIu6OBEHSa6hrMQvKCCLNVxCsTOkUvikFT6Ecu9QV03K lM+A== 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=XFZuH94rf7USxSfWs8gMNTYPjSSO+FL/TPbSKpAQCWejBfwuZZbhI/knH6KgQoP6s5 ou32Qo4CSZHtHrmD7OHOkwvPBn1Wy2gaMujqcYdzNF/ksXGRd3vLc6fkGndTlmYeEI2b J5jRXTk8lvuD8G0WQqLwt+P3P7URmLnS3n7UfYrsc4EkxD5XvIBSA0vvmlS2RP5+PyZT J96mdw2IQq6IYuGo8OpD7eGD0tnKCVf9aHYN0417OKtYQjiaQhKs8/KloriS316Ffg1L wS4t1EbJdSckyB72wdjuiMMpsN8RrBoMlMuI3bGX4xKgWd6keD82Q6yAHpKrSMkBBGe7 BMXw== X-Gm-Message-State: APuU4Z/3QGZh50hkB3ebH4T32B39aDmJXBPminZawJWio0nSN4LViltT gtsHb0Ew8CHobV0IAiqGKzSRndsVY4QXecSzGCU2QLF4h2zmroqhbjKstutbQvu/kEZsAjuG+mG +0Ad+YB69U2brTfsfycsEJSk9EdefLTZ+0veOCKioANw4ttYkpi7RIgEW3A== X-Gm-Gg: AZFdTZdV3MkKCA85RTEn+ExV+sFxRFzISOYsiPY/zZvmaRmFYzuku183kTnRuSGab1Y amjsKJcQQJEGBW3dtdCEPfiuL+oQe595iCE347LFBTn+okp8dUPcptNXwjP+Aaw57Gt7LmQqQsh qwNoCPgZmVEwfsMx/nTNn0D1jbNvvYmlfEU0iyxiraGq9bsCZQxkIKf1dinzEo/+7XcuEHT5VP8 ZzluVC/afHqVvoqBNchU5K8COaoHQdwZi6hPuSTDfbz0SwUI/Wh2ftdYTNKWrJACLa0LKZsJ/Lq 9g/DqGndI9aSKu5ej9GfeEnZqfZbunp5M9DVUPtPI7t4W49Blm6CatQ38XjF8Ac5352aTaaejgL dhaui8pbwZ7zKEUD1aH8TqvaOtak+PhXpa5yKMb18EKC4L9tiOIZPZ4HkyExTVW7trdWCQP8kvX L9ww6fGYj2qMHoOxPJaR3xIE/wuLpqX5PWvS9NDcrJ6AzT X-Received: by 2002:a05:600c:3b0e:b0:4a1:efba:511 with SMTP id 5b1f17b1804b1-4bb8882508emr728899895e9.35.1796062551406; 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: netdev@vger.kernel.org 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> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20261123-net-mptcp-misc-fixes-7-4-rc5-v1-1-278042217e8d@kernel.org> 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