From patchwork Wed Mar 6 23:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 13584717 Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB597CA4E; Wed, 6 Mar 2024 23:05:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=99.78.197.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766347; cv=none; b=BJ03jv5zd4b+nTmvPWPa4tzHCrkoituVfAWPw40SMBhZoEp2fURmfShZLZ69slX8DwctLOq/Dab8mPY7OQHaJ6vvkuRIkPAkqcGs6WxIIHHljTlCLw7fhApnWyRmyhBFenh1JIj8YaShPFBg3+iorgqSySZ8cbY4mbzv61sQq7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766347; c=relaxed/simple; bh=i/0OhZU0UMNFGtZJSkXf7ib+APaaauaQK+ZfJgpJR7c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dq8b69eEGs016Q+k8ID150YXSnKSOfZNKT+gzr/ZRqhDUcycrjQtmvgCj2olOF5AHiCJ0eItIdhJ9NrgZvGwERRgCc/tPtV1xO4IinNig5tsS+pSvziROkScFtgfkZl1uD6J3uQAIEIw45nfYdmW+vjzhg+ZpioBRH6SU7i0lXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=LLKnEP7W; arc=none smtp.client-ip=99.78.197.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="LLKnEP7W" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1709766345; x=1741302345; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X7nBtPJHjw1WBuP8Uf9okhml5369rnBo8/KDqgxWMKs=; b=LLKnEP7WX8JJ8LEoySA8Qzc6jbfGP4jxn/qIVueFJ6p0LEwmLnmUrGgy K+eHeRWnaNWWQ2aedSc5yw8QJvakWJsXgbSuBd6pQLM1E7gJAI0JXDyjr qCVh5Hvyhm7AolT0ibt4uiUEs44+SWWUbvdadvc5QWjwOyVtlw3nVgnEs Y=; X-IronPort-AV: E=Sophos;i="6.06,209,1705363200"; d="scan'208";a="71297243" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 23:05:43 +0000 Received: from EX19MTAUWC002.ant.amazon.com [10.0.7.35:65423] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.58.222:2525] with esmtp (Farcaster) id 4a7e7381-df83-43ef-9d51-560fd90f6361; Wed, 6 Mar 2024 23:05:43 +0000 (UTC) X-Farcaster-Flow-ID: 4a7e7381-df83-43ef-9d51-560fd90f6361 Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWC002.ant.amazon.com (10.250.64.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 6 Mar 2024 23:05:35 +0000 Received: from 88665a182662.ant.amazon.com (10.187.171.26) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 6 Mar 2024 23:05:33 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Allison Henderson CC: Kuniyuki Iwashima , Kuniyuki Iwashima , , , Subject: [PATCH v3 net 1/2] tcp: Restart iteration after removing reqsk in inet_twsk_purge(). Date: Wed, 6 Mar 2024 15:04:57 -0800 Message-ID: <20240306230458.28784-2-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240306230458.28784-1-kuniyu@amazon.com> References: <20240306230458.28784-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D033UWA003.ant.amazon.com (10.13.139.42) To EX19D004ANA001.ant.amazon.com (10.37.240.138) Commit 740ea3c4a0b2 ("tcp: Clean up kernel listener's reqsk in inet_twsk_purge()") added changes in inet_twsk_purge() to purge reqsk in per-netns ehash during netns dismantle. inet_csk_reqsk_queue_drop_and_put() will remove reqsk from per-netns ehash, but the iteration uses sk_nulls_for_each_rcu(), which is not safe. After removing reqsk, we need to restart iteration. Note that we need not check net->ns.count here because per-netns ehash does not have reqsk in other live netns. We will check net->ns.count in the following patch. Fixes: 740ea3c4a0b2 ("tcp: Clean up kernel listener's reqsk in inet_twsk_purge()") Reported-by: Eric Dumazet Signed-off-by: Kuniyuki Iwashima --- net/ipv4/inet_timewait_sock.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 5befa4de5b24..00cbebaa2c68 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c @@ -287,6 +287,8 @@ void inet_twsk_purge(struct inet_hashinfo *hashinfo, int family) struct request_sock *req = inet_reqsk(sk); inet_csk_reqsk_queue_drop_and_put(req->rsk_listener, req); + + goto restart; } continue;