Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp441821rdb; Thu, 8 Feb 2024 10:07:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqXZ2/vgbEAoWTUPrDqhoMUt3JJouvK1mPDzddd3AuRaImpRFTmbE+Kxf1k+Bp8/2R+kjL X-Received: by 2002:a4a:7605:0:b0:599:7389:967b with SMTP id t5-20020a4a7605000000b005997389967bmr329925ooc.4.1707415627443; Thu, 08 Feb 2024 10:07:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415627; cv=pass; d=google.com; s=arc-20160816; b=PJ4ylUU6SogLQXdebPv9qgLrVOkpe8fuU6znf/67W+ZkwPopg/NK5Tip84IDY0o0hK ylVH8LTBcHyAIJOKI5K+BUfcOKT+1mp8geEoWNtoeTqUWCX6r1eW8ayWfSFkEoH5KXWu Bkmz+B0fQ2yGh7IsnoiEbksTh8Sf3fKPnpjRk8/f9SloI9BTSX1IbCbSad0j9F+SB/od vG7FDN2oHHYyMFGDLUIDnoecx6rSQzkmRLf0vSFXhEYU8dQqF3zzKXcA5vGI+UcEP3zA QbWfh1xCztWycv16GY+P3ZDREdB52qRBsgr+NRccOkivn2y4vqutO4uXQrtTvu9xPwFn rOJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=5pmYhDRBW1IkjDW++UifYZcQTHEE1aqZabEZ6nUX1Nc=; fh=Xmj/5jqjLXqgQHqSIsG1MIbjdWOpETrty0521/CpZsU=; b=nheXA2wuUsPAMtyEZbwhp5Wf/NPv975wnAGD/vEw2MtQD3B2ND0+3RmyWp7Mwpljpm DgTGwvWKingVfl06YSLPIxMqbpfWOGBrMX2eDhg8RU7q/OHodgKo5/aW12zbSTDe0zYa UoZcGNycmF7BFIejTPJHgVcqzV38+qNBQEnsAv/s67B/nedfA/G8JFbtIUDEHJ2o69G2 B6RmxE+nZe/r9A9o5m3glyK7AZppC4F3bPlQxWGgIs0XRE5iyqy+jxiaWYP5nsWHsOGd siLBOQr2hWYBvJkF6vRQa2BA8VXk/n2tmzTdJaaj7/mDJS0q3HmsLkD/cusFGb3zggLb bEIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jJ27hc0d; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58511-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCX9XJcynD3RT5o/YmkqwCiwdfyykTHJlz6KDB9GvkV9u004TtQMXPYnRr4wz0uDYYq1huL/H8KY4/sHZO2dtQF3r20jSqjCejz+DpeuWQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ce8-20020a056820218800b00599e897fdc2si1808545oob.43.2024.02.08.10.07.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:07:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58511-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jJ27hc0d; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58511-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D1D93282F6C for ; Thu, 8 Feb 2024 18:06:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 410C1129A7B; Thu, 8 Feb 2024 18:04:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jJ27hc0d" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 57EDE1292EC; Thu, 8 Feb 2024 18:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415485; cv=none; b=KPddzjQ9qLFm6mOdizzamKBqfFAPqmLJ/D+i09BcFwrSY6dWAatJGLiOVOPdMjeGn/v4UBP8YklX3cM/mbqpLuUNDEP2zg5io0UOaxGfXglspBGnbjRaaGdNV6Fmwd1Zs6/HcxRa+gsyjF75Uldwb4C5Wq8AaohivkkXISLSMVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415485; c=relaxed/simple; bh=r/gq3pLyzLbtSrMv4ZRs7gB0vsiao3xcDTWrjPKBybM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JV4pVzIrsauPmu2wpge6m13ZQqoNEXSQofozYaveGd01ahFtwMWsyIxB7xl+x65UfugUM51zEO0FifEk+XZKJ8amA2q+QEFdzd/afTkGpugNRsmZq0HO+EfZk6dN9fd3j+TejRb34CIkHYPvwmEq9+qrKovx4DpXOA9DK4Wr/uk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jJ27hc0d; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5119CC43394; Thu, 8 Feb 2024 18:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415484; bh=r/gq3pLyzLbtSrMv4ZRs7gB0vsiao3xcDTWrjPKBybM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jJ27hc0dnYocwuK2M0zn/x1HALa/GNyyY8Kasu3+DrzFHISxYGgGDQOff01tANjE0 MWhJijoM8gleA8DIKr+LzkNxSPdTSJXRD8YAQJCqGIv9wYZ1VVq1PTKKmVv3gIonwz qIr1prV4iWsteLjzETfXYFRMB5Dkvv6yZFgj6d+dN97rqKy2gi/jguoc8+ErOfuFHz BRAQdpVxhY5uCq4IAxkglctiaRuorLYz/h5qcbAA1eqSVDZGKksGDniCt5f5y9C3PR xF3eWg42+J+/M68Y5mBUiXyzsVyZZ6BZhYbRnbNk6Q5bswFUoAWbneJE4RPNaoikxW qnknJdEtcDJMw== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:54 +0100 Subject: [PATCH net 6/7] mptcp: really cope with fastopen race Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-6-f75cc5b97e5a@kernel.org> References: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-0-f75cc5b97e5a@kernel.org> In-Reply-To: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-0-f75cc5b97e5a@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kishen Maloor , Florian Westphal , Peter Krystad , Dmytro Shytyi , Benjamin Hesmans Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Paasch , "Matthieu Baerts (NGI0)" , stable@vger.kernel.org, syzbot+c53d4d3ddb327e80bc51@syzkaller.appspotmail.com X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1482; i=matttbe@kernel.org; h=from:subject:message-id; bh=7St1EIuD4jOroFFmBmJJjLJG0zQDFjSrZU1TgGoBZ4o=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxReiZsjM2YLGYloOqWhio7IaFMr8gh9SGHTh9 n0LbilZceSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXogAKCRD2t4JPQmmg cxqpEACWaUxiGKk/u59y1R0CdAfyxBluBLO1aeH3adsgZAUA/wmZSNGz7P8/zoIee+LKtyE2nhT AhWxtkEngjcO+UmlPcJu9U3aZ0ttDzWVzWEuFbbFpTb53+C8hTLrwpfWwAWSq9DDH7bkVdtc2fn 6sKhwVAtvO5b8IA3ItNq5CKPUTAsIkNPS5mbV/hOMh91Y2277W+PNQ3CM+AJz27S2anN9fwC7uD BkFw+fkarBzQ+8vm4FzYSPO7wx9PDMkrwIAjq52gB3AJLztDDqujKpvu98BCzNTi0s1YHhPzzgj 740TEiNvhJ+t/s9WskPrfalQvURvFk9y/EG5+W3RbivJmWUi80gC10AnBpnwHj9lXCoWROH4ZRE vsh3yLh81sH240xu295ZAr09c38nzMh+8SYZkuNuOSwXfsO8UiL/VxDR2k3WroZGEthiMGuBegA 6EVwrC3w+zG5NnSqwlhwhvpgkzNQd7K3p9DgG7xFI1RForcjDI3lO+VYvlZgus+OE3I2pkoIbdU 5Z1aRVHRc0A08bSiA7Zkd/IUstbkOzBrTcmFb2z4UIGhbX/ykC/ebZhthJAH6WR9SpXZtZIlj+k SuOjmZN4Zs/nx2XWBlyyFiLT5IwencUfMMgNaurHMHJdNhYtTT6Os5un4yBXM3byvkdwylLMJY+ ss//RAXVz4qPFzg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller. In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked. Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1. Fixes: 1e777f39b4d7 ("mptcp: add MSG_FASTOPEN sendmsg flag support") Fixes: 4fd19a307016 ("mptcp: fix inconsistent state on fastopen race") Cc: stable@vger.kernel.org Reported-by: syzbot+c53d4d3ddb327e80bc51@syzkaller.appspotmail.com Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/458 Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index fefcbf585411..ed50f2015dc3 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1129,7 +1129,8 @@ static inline bool subflow_simultaneous_connect(struct sock *sk) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); - return (1 << sk->sk_state) & (TCPF_ESTABLISHED | TCPF_FIN_WAIT1) && + return (1 << sk->sk_state) & + (TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 | TCPF_CLOSING) && is_active_ssk(subflow) && !subflow->conn_finished; } -- 2.43.0