From patchwork Thu Feb 8 18:03:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 198519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp351430dyd; Thu, 8 Feb 2024 10:06:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXTeODTLYmpq1dcMrDIf8DfDxfBSHzEfocIW4BLJiC6gev+NQBbbSZ5Ks/3yV3GsU8Wbf3p2Aqs9Mc+45waJhQXlsZhow== X-Google-Smtp-Source: AGHT+IG11UHQtBeqC01RhezO77rJ41Q+D3o/yAGWuBtzKOAKo0nR89HA2VMlu7HXN4NPh+7TObD1 X-Received: by 2002:a05:6830:4407:b0:6e0:e52b:ccad with SMTP id q7-20020a056830440700b006e0e52bccadmr338583otv.16.1707415567307; Thu, 08 Feb 2024 10:06:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415567; cv=pass; d=google.com; s=arc-20160816; b=cKTW8fp4Y3WxTO3ghxGkIC2SGBB7IC/JxicvTMTS8aEpnCeSi6ikz1W+WptdYS50xg aMTKZigvAcjfzKaGrB1iLkKlIVMRMn5uU2xcQ8KwAM/TE8Cya8UZSXJiv4afzeJPY3Az t7yvERZgSyM/a/7TdHRC0brwcKSWJNw9jpPN0llQ6FKiTKhtTs8CJ8vhP8BGvPFcEX9b G7BFjSedQghOpJXNV1OIKCgz3A5rMc49SK9sUrqtQXJQHlf1QIYRpP/KlXntEpHihF7E b3iGquQHUwU4QUQBLG2Ky15NkLaBuInrZGDMAgqmSJ1L3rI6wZIjX7rYUWpTZ02/ceJh Hekg== 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=8Hmzx0FeiSWfODNiyU6TLD6PMlZp8uyYy7KJt/msji8=; fh=YAFAYKw6SAHpqlqS3u0FolHNCwKVBMgkbxCtZZIh55A=; b=xaZ7RHcyrDyHo2HKROXv5u68JCHrWFMIava5d94dBzpKGICt+LCzCGefp/Bj/tPlKf cYC74GsF1BBy0GBZiL6+Kh2fAqTGlDWP9Fu4crcxnlKmuwhBcNmL/7x02trMEadWhusc asthHtljY0LjcagokOc+jfqxUuX8sGRLKtciJejI1aIsZ/sTzlqd/ZtHwga4dp7oC50J +MHoeOsewquTrzHYuXmMj4xPKYUkZl6a8RLxveRX6dJFTn8SJomwMnUBcs8OoXHAvKA/ ZxJKxNgyorS3KmnV7R+iQ1CvMjOvxeUNmrRb8EAjDWIdAZJKAiIjB4F7469RAHtyT3k4 G2lw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pjY24xFu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58506-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58506-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCX/b3IMAi/8izIu6UvtLHWf0gjihyPhO9A5e7q88ploxe+JwqwJINwRJ5fLoC2lHz5eA2sf3brTtONnCau8eOycNvWWhg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m13-20020a9d7e8d000000b006e2be1979d4si1106565otp.227.2024.02.08.10.06.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:06:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58506-ouuuleilei=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=pjY24xFu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58506-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58506-ouuuleilei=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 0B6FC289CD0 for ; Thu, 8 Feb 2024 18:05:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F072586AF3; Thu, 8 Feb 2024 18:04:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pjY24xFu" 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 191377EF0C; Thu, 8 Feb 2024 18:04:25 +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=1707415467; cv=none; b=WYkh4tyLmxkaE3vpQ+xgJMvfNrQR4cSRy5aT6UANiLfbXz194yBqLhbgB9XzyU/J5/35xJJi/t3xudJQHfmu1/6I6LWHS/c59Ua30gsmERe/b0fC/JVxI+vIYMqH78f8BWWm/UxxJvq17rEVUiDAtDUQHu6752Ql19eddF09GMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415467; c=relaxed/simple; bh=aCkDCXwukiBM5j5kejbQN2B8zljH82fF79qIsFgXzX4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZDy1Uum7HY7B0qPTVjhBEJ+yiDJiHczWh/m1eYVfTtokP2y2lLBS/fEGjuf4ksO5DYGPArO6FgHWVnxKJT0S5+2hYi8q1h1ptEomtGE6ACsoBOBTNAFEvgZCzQOPHy/je4GbGvoITFQ5OimgSbQNvYRElbNc1afDdsR0OOOaPvc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pjY24xFu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58F27C43399; Thu, 8 Feb 2024 18:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415465; bh=aCkDCXwukiBM5j5kejbQN2B8zljH82fF79qIsFgXzX4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pjY24xFu5QFgFKifBfG38/ntMpu0Ur8UUbSe1VEC8CHTfbHrdhmAMNErDKuCPSCKS APOTtShusS/XEmzKA8L1HVZJ63di5hFgd87KBrHRTKFgGWnICywPOcD8LMWN82v1SG zcnuIwK/CLql/2N2zcAEgRdT38Z96hxJNkqKj33xf/OK1SIO7/b/2aYcHb+L8BQGPz Lt5mU/11n/rKaXxf559r2us+mLxvlytjfEt0AiAibT6AL/x1H0WgIMC+760+lBk2xT xW0bfXPqT8VwhaSDd4bac6qfzURqd2bxZpPZb0FG9J8Vxy2bqiGycwz3GgW9y0BHAB 528p1DvrtJqNQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:49 +0100 Subject: [PATCH net 1/7] mptcp: drop the push_pending field Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-1-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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2836; i=matttbe@kernel.org; h=from:subject:message-id; bh=HEDW7t9+sgzNCTV35HeaMf5YyIAJ9ktNnQ5iSir6dlM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxRehSt3z1Z3KCCwjZLMPz6FGmixn5dnhvqtlU zvLUCOt2+6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXoQAKCRD2t4JPQmmg c0/HEADl4pEhwaSENKVzRBXH7QSm67bmWcAFJhCjxhkHieOzw4l5UJctY7QkbO/ybGekG9AUzEw fRCb13mCzt795fiGeWBgSNx65swXRnkD4M/UvAMsDRDaxZPUi79NHBpEUqipCav+aFygp8iEdTm wmZrfWFQjP3NZVRlU77RJbH5LMk8BUwT1xzSHFBaY54im9o8XBmnujHZfDglWLVNbtv4WbjRn4/ 9lR5lZhEt4iZom8J7GpS9UEx8Sg4eMDrImHxYUCLHV7YkcUEkeoX1duFsNBb1gtyBFm0+sSyvNt s+zrGY708M4yteyrNCJdNNnodh02DCtoCvPMRYDNDY+PMbEcp+FqFBPvH7BA0ZAGO6COijp+W8i p1AqZI0fi+Txj5BN1pylGsxc080z9M9Fx1FeEhEWRbaqsQulCJ2M+V81nQYuXyiOpXHu0ZaF8et IaJjfqxoCZhYKZbaEsrO/isNKLJji0HlXiHvGAQzj/8kvjY3l4K0sUIcJTvYzSOO7I8pfpnoA6m gZ8fNiin9+1B3ZIkiNzPHFTtMQ89daStKGqUbzuPDrPQkOjlEc2OltAp3nU7zKlaJEhw5wxkmNx loj/ETz1jTzDrKMicuYM4Gahxsh8csazEdqrEwZqYdXERZDJylzkpQyCq9AKEgb1F8iDmUUsTgw 8gZ+RuHJ6yvaVTg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790354985924993097 X-GMAIL-MSGID: 1790354985924993097 From: Paolo Abeni Such field is there to avoid acquiring the data lock in a few spots, but it adds complexity to the already non trivial locking schema. All the relevant call sites (mptcp-level re-injection, set socket options), are slow-path, drop such field in favor of 'cb_flags', adding the relevant locking. This patch could be seen as an improvement, instead of a fix. But it simplifies the next patch. The 'Fixes' tag has been added to help having this series backported to stable. Fixes: e9d09baca676 ("mptcp: avoid atomic bit manipulation when possible") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 12 ++++++------ net/mptcp/protocol.h | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 028e8b473626..2111819016af 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1505,8 +1505,11 @@ static void mptcp_update_post_push(struct mptcp_sock *msk, void mptcp_check_and_set_pending(struct sock *sk) { - if (mptcp_send_head(sk)) - mptcp_sk(sk)->push_pending |= BIT(MPTCP_PUSH_PENDING); + if (mptcp_send_head(sk)) { + mptcp_data_lock(sk); + mptcp_sk(sk)->cb_flags |= BIT(MPTCP_PUSH_PENDING); + mptcp_data_unlock(sk); + } } static int __subflow_push_pending(struct sock *sk, struct sock *ssk, @@ -3142,7 +3145,6 @@ static int mptcp_disconnect(struct sock *sk, int flags) mptcp_destroy_common(msk, MPTCP_CF_FASTCLOSE); WRITE_ONCE(msk->flags, 0); msk->cb_flags = 0; - msk->push_pending = 0; msk->recovery = false; msk->can_ack = false; msk->fully_established = false; @@ -3330,8 +3332,7 @@ static void mptcp_release_cb(struct sock *sk) struct mptcp_sock *msk = mptcp_sk(sk); for (;;) { - unsigned long flags = (msk->cb_flags & MPTCP_FLAGS_PROCESS_CTX_NEED) | - msk->push_pending; + unsigned long flags = (msk->cb_flags & MPTCP_FLAGS_PROCESS_CTX_NEED); struct list_head join_list; if (!flags) @@ -3347,7 +3348,6 @@ static void mptcp_release_cb(struct sock *sk) * datapath acquires the msk socket spinlock while helding * the subflow socket lock */ - msk->push_pending = 0; msk->cb_flags &= ~flags; spin_unlock_bh(&sk->sk_lock.slock); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3517f2d24a22..b905f1868298 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -286,7 +286,6 @@ struct mptcp_sock { int rmem_released; unsigned long flags; unsigned long cb_flags; - unsigned long push_pending; bool recovery; /* closing subflow write queue reinjected */ bool can_ack; bool fully_established; From patchwork Thu Feb 8 18:03:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 198527 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp372755dyd; Thu, 8 Feb 2024 10:37:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWPN9m1Z+PR7sZJKYB28xIiEhJ+MQ2oIVUL4eapHx+NWW20zrpzcSdp/caHQKDE5WGn4o7tSSGwzj95XthYg0OhuUBu2g== X-Google-Smtp-Source: AGHT+IFze84MWIqfEyOQmJTmfDIWFpnwrlPtFnUcim8Ge9sPWx8pILM5fsA/giPYasxDA3heckve X-Received: by 2002:a05:6a20:a385:b0:19e:a658:3d78 with SMTP id w5-20020a056a20a38500b0019ea6583d78mr390109pzk.22.1707417423448; Thu, 08 Feb 2024 10:37:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707417423; cv=pass; d=google.com; s=arc-20160816; b=zeAeiUvSIYUmeDcb2LqAKmlITMECFjiXxUNgiRd3r0pWeSIyP2+JTUsfLrTHdMjTD0 c6zvfcgij6NvMwjIE8HNy8u5W7YxxxJ3+VfX1IQTESOqADvxsgVT6Ts/L1pDzFDjUVx7 69GT2o+4LIkPZehTHdzV28ZVVpnXpJWoNawF0IfFttmTYT9KeDx5x+8b6SyGPyBPePhg 58jsin9qkJ07rqyAA9SfNacLH3yDZLKOubE57VFQG86hABObfheGcrtt1QhZIUrq3ihT ct32bJ67tu+fNek8vzgiicSgSeLWE57g0lqIUeC5CeP2fCme7KlK8DAMQg1XHkjcyLw3 lrNw== 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=BzTLDj18nNQoJglEpzBY/8GUD7VFpAkwEpXxttKv/Kk=; fh=sVUgwCIFdnf0wY9o8x68hHgMWwCGlka6U8e1p9EYkBU=; b=dpq741JeSANtjtrNz29s83azMxfPTwqMgJMP5iU0GCRmMMEk1lZNNa07TMUPYNxImx MVi71Zl170AqB2AV6/uWT+EHuyrDTuld8rzhjoG+tTxxAXK42axtqV4Zup13zDICKMtx XC7vw2aabDE3OnA0VzMtl0zpdqrkdX4o9ZVCyTbI1G1hyon3k3je60tSir567czs4OJy 59zJV+GhG7kKzo5w/eqHFuSFxgsE5Jgq0cC7npesljiCAmg/g+rvY3Y4clxb9acMMVn7 kT/pHQkMzA2i8tDpJCdTvoNJ8hJ4IgoibCLSVFXu0ny4nsKcpSjQgbJNNQiiM7FtDxDM F4+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l1F8eMVe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58507-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58507-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCX60uTtElxoc/Wb1lAhz+8JxHz3lL60yOINs6xI4iJCgVwWNx1GYWKdVCDWB2Q+pjsdGQg17v8FFz85TPKKJIJJNFYtjA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e23-20020a633717000000b005cdfe668943si188612pga.781.2024.02.08.10.37.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:37:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58507-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l1F8eMVe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58507-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58507-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6B088B2553E for ; Thu, 8 Feb 2024 18:05:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2596284A3A; Thu, 8 Feb 2024 18:04:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l1F8eMVe" 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 ECA5B86AF2; Thu, 8 Feb 2024 18:04:29 +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=1707415470; cv=none; b=CnTImYcMA611CxzsuVjnnQukd31Lu/IjMR1VKDPV7ghVJMvHVns6h1Ix6PDtqfP1k0fUp8LOdiXjymOG0hpxyY8T0RmbwYBdDuyJacvezJxOa6McTyFDbj5WvJDglAMwKx3WRxGeAMB35Y3UaE/d4R+B0S6CqOqBsov6AqOFL3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415470; c=relaxed/simple; bh=EOoPTeNnER7i43iXou7ntTSk1e6l39fVUtsHySrh3Fo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sxCD8k/sE7AIzjrxu2JJYw8uyooKNO78UfQfmixD8U6Agr1nOLzr3Th3omF/hSg4961T3xacMd7SNsZRF5khdFyWfl2VWHJaFCnD3IUijP4tw2ZpvVPtHeF+tvRKdPd/Tq5hNR2/h5G34GthWdD0Qn8FPMBcJeDeDNDxrXIEQHk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l1F8eMVe; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EAFDC433B1; Thu, 8 Feb 2024 18:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415469; bh=EOoPTeNnER7i43iXou7ntTSk1e6l39fVUtsHySrh3Fo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=l1F8eMVeUYOlgnfTDTMEH1O2giWk7wFtGNmQdlYAymbpn9WE713UNZY8ljtaxMjjS FKQn+8/jsAIsSY+fq2sDx/IA6jwML3ajY2x2KonSUaaRdM8jGMoMM0y2mn7b+p9zP3 cPmeHIDp6C1p6h4crEa9FhoiYIixn9bdv+2ADhS0fmEoTYZhh7Y/qXxYgPKwI+4ho3 v574ndktvL0G8hAS92XEMyq1ahMNWupijfzJ44Z072/R4s/9kpr+uHQcCwXH9fSXIB iqKRcrCEvG8SE+vF0G+ULFmFi0/zEUGL5wvkKell8FnWunudNqm8TdjYeWk/T7F7II 63PiboTeUjHCA== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:50 +0100 Subject: [PATCH net 2/7] mptcp: fix rcv space initialization Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-2-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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4231; i=matttbe@kernel.org; h=from:subject:message-id; bh=u459/uEWds6unUKdxrBRK9kc4LzzOSdfJrTQrb3+BUo=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxReh66G8XYWqiDsnrvH7A+T0+wCScbecigzt8 f6bvzZYXauJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXoQAKCRD2t4JPQmmg c8ZHD/9fQ9GFtFA+opHpLjjxDQhx+9qRdYgaO/d07oA3asjxIH0a7bEW3hF3T8zW2GchvdYjPew lln3UQvrNrZitHWpfXiBSmEyWQSzo3+027w0wqiCOUH/mMKDv6zHVaUMNatzrd/uxRqC1KLhbbD NTEn3f16j3uo6N0v5MdK2R+4t7C1OOYyBASNbfna+P5Tx2MKTXd2kbcOUtvMhT72g03a2Vfm2F8 oB9Vt5Jp5FtzKvQrGqnUjwG1ahwoQW53U48l1bILHICl72xYWtfWyVdaV8GEgO42FPEp5TSAE8g sssrhYT5z5T3eMCK81q27+Nflr0YDS3dyvWx1NeZLUpJajbBqznDUoBT1mOZ+BULayyHue6S9MT 0MzC+CvYZ33QC9zq3E9UrmYdsdM1DSU/cPEsm6ZA3t8/eo6fqHp0P7s9CZhprP/1h5jPCoWvb/k pH+pty8cLODZbhAMAgeBB98/6ytSuBIxvZ3AgSkyEQYEtKxDQ4m00y2xpx0VD5FO8y//cp2Kw+D tofIUHbqHyMVvO714CXGvZ1187d9zR9BjGrVSxNzppMwVwCb+X1VQ5jIQUUcONjv2FeN6ztwj4x H3BuCbO4VvsWvamW1U62Pzwg620fUXs4ZBTmw0Js67Zcjzgp5z23IsHsWg0dGKVF3frYOuc9cbB 1vs8YAOhSNXFVZQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790356932492198099 X-GMAIL-MSGID: 1790356932492198099 From: Paolo Abeni mptcp_rcv_space_init() is supposed to happen under the msk socket lock, but active msk socket does that without such protection. Leverage the existing mptcp_propagate_state() helper to that extent. We need to ensure mptcp_rcv_space_init will happen before mptcp_rcv_space_adjust(), and the release_cb does not assure that: explicitly check for such condition. While at it, move the wnd_end initialization out of mptcp_rcv_space_init(), it never belonged there. Note that the race does not produce ill effect in practice, but change allows cleaning-up and defying better the locking model. Fixes: a6b118febbab ("mptcp: add receive buffer auto-tuning") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 10 ++++++---- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2111819016af..7632eafb683b 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1963,6 +1963,9 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied) if (copied <= 0) return; + if (!msk->rcvspace_init) + mptcp_rcv_space_init(msk, msk->first); + msk->rcvq_space.copied += copied; mstamp = div_u64(tcp_clock_ns(), NSEC_PER_USEC); @@ -3160,6 +3163,7 @@ static int mptcp_disconnect(struct sock *sk, int flags) msk->bytes_received = 0; msk->bytes_sent = 0; msk->bytes_retrans = 0; + msk->rcvspace_init = 0; WRITE_ONCE(sk->sk_shutdown, 0); sk_error_report(sk); @@ -3247,6 +3251,7 @@ void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock *ssk) { const struct tcp_sock *tp = tcp_sk(ssk); + msk->rcvspace_init = 1; msk->rcvq_space.copied = 0; msk->rcvq_space.rtt_us = 0; @@ -3257,8 +3262,6 @@ void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock *ssk) TCP_INIT_CWND * tp->advmss); if (msk->rcvq_space.space == 0) msk->rcvq_space.space = TCP_INIT_CWND * TCP_MSS_DEFAULT; - - WRITE_ONCE(msk->wnd_end, msk->snd_nxt + tcp_sk(ssk)->snd_wnd); } void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags) @@ -3478,10 +3481,9 @@ void mptcp_finish_connect(struct sock *ssk) WRITE_ONCE(msk->write_seq, subflow->idsn + 1); WRITE_ONCE(msk->snd_nxt, msk->write_seq); WRITE_ONCE(msk->snd_una, msk->write_seq); + WRITE_ONCE(msk->wnd_end, msk->snd_nxt + tcp_sk(ssk)->snd_wnd); mptcp_pm_new_connection(msk, ssk, 0); - - mptcp_rcv_space_init(msk, ssk); } void mptcp_sock_graft(struct sock *sk, struct socket *parent) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b905f1868298..9f5ee82e3473 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -304,7 +304,8 @@ struct mptcp_sock { nodelay:1, fastopening:1, in_accept_queue:1, - free_first:1; + free_first:1, + rcvspace_init:1; struct work_struct work; struct sk_buff *ooo_last_skb; struct rb_root out_of_order_queue; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 0dcb721c89d1..56b2ac2f2f22 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -424,6 +424,8 @@ void __mptcp_sync_state(struct sock *sk, int state) struct mptcp_sock *msk = mptcp_sk(sk); __mptcp_propagate_sndbuf(sk, msk->first); + if (!msk->rcvspace_init) + mptcp_rcv_space_init(msk, msk->first); if (sk->sk_state == TCP_SYN_SENT) { mptcp_set_state(sk, state); sk->sk_state_change(sk); @@ -545,7 +547,6 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) } } else if (mptcp_check_fallback(sk)) { fallback: - mptcp_rcv_space_init(msk, sk); mptcp_propagate_state(parent, sk); } return; @@ -1744,7 +1745,6 @@ static void subflow_state_change(struct sock *sk) msk = mptcp_sk(parent); if (subflow_simultaneous_connect(sk)) { mptcp_do_fallback(sk); - mptcp_rcv_space_init(msk, sk); pr_fallback(msk); subflow->conn_finished = 1; mptcp_propagate_state(parent, sk); From patchwork Thu Feb 8 18:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 198518 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp351206dyd; Thu, 8 Feb 2024 10:05:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXw2xpVS5I4FccTorvSBuZHHvQ4bbz2MSWWVObmVSpT7L3kK+jsz8eFdBzeidgMjtmiSH0/5xCZ1cSuV8JcPkGqW6znCg== X-Google-Smtp-Source: AGHT+IGzIjkrtYMGd1OQ0J/8prsy9zEECJ4O4s7wncA4m32VBOqOQ4iYbzgK/rTBP01UbdCJyUHo X-Received: by 2002:a05:6402:74d:b0:561:c4a:2aaa with SMTP id p13-20020a056402074d00b005610c4a2aaamr280823edy.8.1707415550926; Thu, 08 Feb 2024 10:05:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415550; cv=pass; d=google.com; s=arc-20160816; b=CQzgxqUTJbgy0D2en83y0qibzHSFXaWRKRaK0riI/HqRu3VltgeVKPd/h1ebG+GjiG rSgaqAahB+tihxrwfiyebYK0nAGn+BSwQD2kkz/mHyi8TewBxItkB2dBTAqeKF2RGJIx bK7CEa63QwNClQzWnfY5eIENq0+dZ1MEDWFS5LnQ9hSlZ3D5Cm7599jXbmwUoldLWujf zY7X301Ek+xjuz3kdhOGOPxW5pzH8eZ1wssFaR7eeJ51wQToMxt/O5S4bQ9Lvhuwidu/ NTxcDTHt0FJTPQwYCNNKiytzEgTLAYgkOrdO9ODwByTWXaEhJnNWwF+qGJJFoV/cSmc5 0Mwg== 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=MZ9Q8+nkcU3rSMvDK3D+MZUQbR7DGhTtIYBaOYm7j2g=; fh=lUFDvpDd5QBw89kGoGvrNtiwvhke/zJJFDFfSv6eoxs=; b=qYo3N7hS5doUGsS6SgxEaC/yipoKo7FtBoQiICUxuESX63GvztSg79bLSFUiaWw/av AaV9teykCxErzF8RLCLH8ZDDmNgDM+AmAXXkN8PQf0jT2yDtFjC9ADvDqGzWr+2Q7wYN AkuPwv8aWWZFaMxWFPMAn1DQCswDGjfGN9GzmjJuzaYQeiUB5/ocdJYEFeJwjlZlmrK4 SDnkYVBiw89MHCuYH8xeFn6Sz5LnFqfqJpSIEVvwZ9O7RISMnacEDe4iuJPoKSwH5gkL ceK9CklWrCZ+MWghwYzXDGYrGPy6TRA/MVv9InAMBIxnh43DAnxa1Omp8qhR3Pxt6jyz sQog==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XgTGszmx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58508-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58508-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUwfBXqAMBqYJjbnkeoaeCoeap3nhZqcXblo9fRenZ862+1TTptSumL1TKleXfcar/b1gxNBeIe/ieazpATCEcDkgev6w== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ec25-20020a0564020d5900b0055ff9c2cecesi1090024edb.369.2024.02.08.10.05.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:05:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58508-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XgTGszmx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58508-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58508-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 836571F25A9B for ; Thu, 8 Feb 2024 18:05:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A099081ABC; Thu, 8 Feb 2024 18:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XgTGszmx" 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 C26AA1272D0; Thu, 8 Feb 2024 18:04:33 +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=1707415473; cv=none; b=DFOTLBnaELzmalUXhQaba24NkPcs2eeu13GpFT30PE0N/EONLX9fbFZqNeuyjVW5g7NDCgwFATyxTWmFNV7P1uTUwS/mTGLTTRj+fG6PdLaCuDC2UT8LuKCyoflar8vGp328En2A2k34ndy/+hFNIXvyZDEy4SzlzivlwJaUz1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415473; c=relaxed/simple; bh=yHJvs4che6WyhYHzxH8wT4v6HXxxwDmE2feB06/a0QY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZjdbcoLH/sI9CqBMT0MHRx50sftmfYjbbWSsZ4ERbd4FOeBd3zznCA8TLmHsWCn8B+VF8O+mbnX2u95CC5IRtXh0gK0rmBpCBV9VTCsqrGiHCOuUM3s2mScRQ5lNr5lneFgWX0l7AQMXmknY0YFbX0Wv3S+dpjpVKQB7RvfY8hs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XgTGszmx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA1A0C43390; Thu, 8 Feb 2024 18:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415473; bh=yHJvs4che6WyhYHzxH8wT4v6HXxxwDmE2feB06/a0QY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XgTGszmxQE3Wk32I7duZggjSPhqW9GNMht/S90Hhce0HOgMMHTmCh5iagf56vS/RQ lsZwnH+UjSh+9IT3ANTzDVZlhgnzBh9zs9XiOoknlEZklSFA7SjGWUOJZZVm6VrhC3 gkSlatMe561yStwVPFXfsmaPDASjbNC3vOtwoaAudkjDLZZi+oME5s5VAYZNn83MCM DkFRtvUtsjld5/Ifxyh0KsqB+UJ5WMgOQJ9hQKAbxNkka6TMaS5xQrL7R1w1pjEfUs ufGPyojuVBURq4kQe5Mzs3oLsIAVxjFFLNdOZ+rxa3oVyfpDdXBAwnnBzffx3Dz4t6 KnGsKJJV74ueQ== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:51 +0100 Subject: [PATCH net 3/7] mptcp: fix more tx path fields initialization Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-3-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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2392; i=matttbe@kernel.org; h=from:subject:message-id; bh=BH9JwtYC2RN/3BDjjpe9vHZJy5WVFOfYRfxZhvGrfHM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxRehoTpOkhQagMNL0KqONyCoHfQC3+GgB+o7X hLmr9ahZ5KJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXoQAKCRD2t4JPQmmg c6QsD/9+sUDZ1mdnC9h189TtEe7cUCxjSjCf2hgQZ6q5p9UWmq8m/CkIkxsyi0S37ONi2QSE/sq kDVg0zfgcA3HnVdGJYZ219wpOWcSTT5O6TPAot3vre7gzOFtIiiHXK0QfpuhTquTQC697z4IUIh LhBpYK6uoDZH6ezQje3PKwddcA5v3XGtCQgEfUJRfn8+pbhFcZzsUZlyxhHFHRsO1hQJohYZon8 CRfdsk8BXLvyJODr6zpN/A/BzxJYk1eOFfn1TegSKHGVYBJ/QxKT34uxw8l5p5AHojkvp8BP5yW t2ozFgG4qcKOp/28LzMPCmszncJKvXWLluI03czeiu5GefBw7tVkEFZr1NMBZvIPoDDoa5Hw+5S s/p1mQ0EWqp0Dg5d8SrzfwghkRUkyPWMYWTAat2oy7Eo+RF3cqVFmvM5sDl/yY8ILm12GRQoEbd y7LIUzCl1MK0VjhFlsoyY5MBUYSy+20awY7muTWX6mGnO1VP5cmrmC91f2NVeU4douFSbNY2VC6 f0c9FAcFIZawV9V/+42VCGL5bGoEMfjW3a1We+e7mvY4EcK84Vnkku/uJjN7OepjpGXd2PWEO/s xbtAsNle5kH1n0seFi6FOenAvNeAyHS+ob2ee8F9JJNZHvkdemZCbKjJxcoSwyq6NOC16S1NbvC knAdu5d97NpXbfw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790354968498991845 X-GMAIL-MSGID: 1790354968498991845 From: Paolo Abeni The 'msk->write_seq' and 'msk->snd_nxt' are always updated under the msk socket lock, except at MPC handshake completiont time. Builds-up on the previous commit to move such init under the relevant lock. There are no known problems caused by the potential race, the primary goal is consistency. Fixes: 6d0060f600ad ("mptcp: Write MPTCP DSS headers to outgoing data packets") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 6 ++---- net/mptcp/subflow.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 7632eafb683b..8cb6a873dae9 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3478,10 +3478,8 @@ void mptcp_finish_connect(struct sock *ssk) * accessing the field below */ WRITE_ONCE(msk->local_key, subflow->local_key); - WRITE_ONCE(msk->write_seq, subflow->idsn + 1); - WRITE_ONCE(msk->snd_nxt, msk->write_seq); - WRITE_ONCE(msk->snd_una, msk->write_seq); - WRITE_ONCE(msk->wnd_end, msk->snd_nxt + tcp_sk(ssk)->snd_wnd); + WRITE_ONCE(msk->snd_una, subflow->idsn + 1); + WRITE_ONCE(msk->wnd_end, subflow->idsn + 1 + tcp_sk(ssk)->snd_wnd); mptcp_pm_new_connection(msk, ssk, 0); } diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 56b2ac2f2f22..c2df34ebcf28 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -421,12 +421,21 @@ static bool subflow_use_different_dport(struct mptcp_sock *msk, const struct soc void __mptcp_sync_state(struct sock *sk, int state) { + struct mptcp_subflow_context *subflow; struct mptcp_sock *msk = mptcp_sk(sk); + struct sock *ssk = msk->first; - __mptcp_propagate_sndbuf(sk, msk->first); + subflow = mptcp_subflow_ctx(ssk); + __mptcp_propagate_sndbuf(sk, ssk); if (!msk->rcvspace_init) - mptcp_rcv_space_init(msk, msk->first); + mptcp_rcv_space_init(msk, ssk); + if (sk->sk_state == TCP_SYN_SENT) { + /* subflow->idsn is always available is TCP_SYN_SENT state, + * even for the FASTOPEN scenarios + */ + WRITE_ONCE(msk->write_seq, subflow->idsn + 1); + WRITE_ONCE(msk->snd_nxt, msk->write_seq); mptcp_set_state(sk, state); sk->sk_state_change(sk); } From patchwork Thu Feb 8 18:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 198520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp351963dyd; Thu, 8 Feb 2024 10:06:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWFayKjcHs+kv2eJL6tttNwOvYQkaGw/q2c8J/Ivo2NjWiDJltJFftBp9TICpxxtDaDnp54G1ieQxY3mmS7b3OyP/JmsA== X-Google-Smtp-Source: AGHT+IEYHPrn6MmjlUWdbwQ4NwOO5qrMIoNqG9yrVId1LV6xZgwemBZctJ2k0V0mnpLOWYAA5XbM X-Received: by 2002:a05:6a20:8e11:b0:19e:34ea:36ab with SMTP id y17-20020a056a208e1100b0019e34ea36abmr453705pzj.16.1707415607068; Thu, 08 Feb 2024 10:06:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415607; cv=pass; d=google.com; s=arc-20160816; b=LYBpmepL36gEUNGGhI7NjD6vz6Hhcv/+6zEdOKaWaFlzaOYYepo4Fvu9HJXKAglyYV CfHt/UUaKOUMnt0IDpxNySVyaqcXl6XtzFpzHV2uHF4p16xgmp78uA9eEj6nnhTtew9J uQMeOR7XHW5XGN5qGc5dSIjq2Ze+4a/p2cOTaul0Jr8tjuN62nPFke5/WVzwZacV3imN JjetQ//5Cqq0HrNesvPN5z5nICLOv9lCoFNHV0p8WLbHli/0qh91gUcCAdjByYfDHR+L fiD/l5HV5AwcpagTiLJcYn+phQu+7FhtxlUZZUK+2sJ+/VTmYw25OIs7XqTveXXhDonr mtAA== 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=rMw8LporBvIFszYpsE++WtdRIrlLrbUYXuAkMjImHS0=; fh=m/dM5TamoUruebv3FCi5Ua/6cC4jCmsO3fQSamY3mc0=; b=Xr/yZAEVhCNmRYfqb9nvm6rcn88qnyrL4gTt7ISUuq7GVvUvis0X6NOx5T7R/BrMgm pjWzyiW5bNcZsHprT80/qyjJk9Wv7QhfnR0FQ2mSw/VhhupaazeWFpZ4ywDLHSEzCAF+ EHy83ryC3f/PVH3skbrW0Rp2EXmGnAQnh5QbAxEtyLe9U7pcYVStKwXI/BHL68/oByY9 G3LMmJLCZv1HCw81EmHXQibm1l6S/K8G41fBvxDGarAoqDtTGhLBshqUyuSFNMacUemD 3Aqfof6urf7Dd82tSJh7AIn8yr/tcDZr5x4FRLf70fZLGlNEwHJ2vj0FkSiG4rQqjC8/ adww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=htSrZhK+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58509-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58509-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXRSClak3ZXAKHfcC05gDfkPjRiHwOu0fojhXa7s7ia3WoT0Hc+ivxNAi2V+7jaCg9wE/yuMQ199GUTKMEm5sHAMyAxYQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l17-20020a629111000000b006e037891d2dsi40285pfe.36.2024.02.08.10.06.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:06:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58509-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=htSrZhK+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58509-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58509-ouuuleilei=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 867B2280DE8 for ; Thu, 8 Feb 2024 18:06:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DB0485C56; Thu, 8 Feb 2024 18:04:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="htSrZhK+" 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 475B5128370; Thu, 8 Feb 2024 18:04:37 +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=1707415477; cv=none; b=i0ublDuiRgGX0QUJ6w21UD2ofHHL84AfHe+Q+mwAiIRubnr6Jgrh8EOUq6ZGNel6M43k3NOj15t3yp4Q1wSI5+DmatduVFFsv0phuFO7xOXcl79DXF9PyW2Fuj9G/qqd96wm9MZcI+Wd1IZgtprgMPyWSa45EAF0kMbk9EdSdSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415477; c=relaxed/simple; bh=B1tpBpXayfv5C4oprtq3aWGfISdNpEH0s3KkYlXv0Sw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DjHb/8kwslhysyG6hO3fI7H8JbZ0e2l+ROJvjMe6M523aKiheJ1uX/NpjNn80msHyvrOPkulxCQKiotyYYurT6sSDRL4oKrNmm5bUSQp+0heS9T3qTskJv5uTbtwOPQHH3QXzA/BUdS7E2AvM4BWQpA75ahNS/SVKVWfhl9o66I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=htSrZhK+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD07EC43141; Thu, 8 Feb 2024 18:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415477; bh=B1tpBpXayfv5C4oprtq3aWGfISdNpEH0s3KkYlXv0Sw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=htSrZhK+EtWBFCu0hz+Y+TgNYG5/0v0aWvvrXeZ9e2ja4D/mms7icHR2nf+dJe9P2 fEBR3e0so03OpHNeAynxXIYZRIpkRCUSfwwpyZpnrKExde06W/UPuvbDKDrKIsseZ9 izHvD7r65Dw6VDSrZcOI4sp9hhBLjbFVhh1eQLTg2yxJsFpncTPhAXV3bkhuxHT1Cn LFQbjwrZESGA47VCPwkKWckHMZLkk/ttaQ043+zQH5E5X/T+j30JPFVjoymG6rNObl bDjJMjKAlpXVIHhjq2O5OUTKYda280CQl0oq8RLFyKb4G49Bip/e8uDnxvU85ybdU+ hHWxuAJF1Xwqg== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:52 +0100 Subject: [PATCH net 4/7] mptcp: corner case locking for rx path fields initialization Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-4-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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=10427; i=matttbe@kernel.org; h=from:subject:message-id; bh=g0Rw4HDgt4Q54yco1/zI46zEx1HU/dDMukldMNg3NEA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxRehXO9RcQy3GoVM7sF5g2ZeamRGhQnQUBe/g ix2f8nSFaCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXoQAKCRD2t4JPQmmg c7/UD/9Dk4T6iEx+rbCfwt7OBN99/BeeKn5R499gV2z1y+5jjMQB+pl8XiHhSxG7v2df1wxKsyD sXA4JbKblzdMCvY/GzO/Xf/3TG1xdBj5xKY6EWbJkECEg2ln02vbewhqGdRBXmAMWCMPpjk+uiz 0NmRVWNE9I8E320+7ayfK3E8ojbURpR4xm0ZgNdQIpJGSeN4gu13aVx6IW4wwUrrqkY30kYR0dB si8XouRhGSZWnmGUb4Hxp+hCX7OxBH85R5GMTdtcav+vdcUVkOG2WfmsRh1ddE+iACwi6Dkzo69 Vn0H2dj26co/oHBt1WhQABF0KsyS9OTp1VcG7DqU+bhPrRM6bF8YP/710F0wIUOZe9SbZ8oAZin ubiPueUqPmPuIT2G+nBlPx0XD1EeHkriv3If+lwjbd/2+SYD7WBx19kaArfwF2PBoBI0kDhoer9 FYRoZpzqSZ4yh+4bJr7hsaJIJ6KQP6nmY8YyGb7DA7GrQR9P55Gdd0hllaD5/xleauPW5qYTSYT kmgGJhI+eBaYUrK1TMP5qmkEm9kQAmdNxz/7PwIoNjhA9JF/ZdDLIgC/HnzYjHjcLaat9FbTmRo 3cpdJArRTMz2q7G5/rbWm70L6QcYgygejeIegHsKeSGP2k7NjCdCJUy7GBVIyxwZuf1+IsfqRuC Raz348oDvPYW55w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790355027603869509 X-GMAIL-MSGID: 1790355027603869509 From: Paolo Abeni Most MPTCP-level related fields are under the mptcp data lock protection, but are written one-off without such lock at MPC complete time, both for the client and the server Leverage the mptcp_propagate_state() infrastructure to move such initialization under the proper lock client-wise. The server side critical init steps are done by mptcp_subflow_fully_established(): ensure the caller properly held the relevant lock, and avoid acquiring the same lock in the nested scopes. There are no real potential races, as write access to such fields is implicitly serialized by the MPTCP state machine; the primary goal is consistency. Fixes: d22f4988ffec ("mptcp: process MP_CAPABLE data option") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/fastopen.c | 6 ++---- net/mptcp/options.c | 9 +++++---- net/mptcp/protocol.c | 9 ++++++--- net/mptcp/protocol.h | 9 +++++---- net/mptcp/subflow.c | 56 ++++++++++++++++++++++++++++++---------------------- 5 files changed, 50 insertions(+), 39 deletions(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 74698582a285..ad28da655f8b 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -59,13 +59,12 @@ void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subf mptcp_data_unlock(sk); } -void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, - const struct mptcp_options_received *mp_opt) +void __mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt) { struct sock *sk = (struct sock *)msk; struct sk_buff *skb; - mptcp_data_lock(sk); skb = skb_peek_tail(&sk->sk_receive_queue); if (skb) { WARN_ON_ONCE(MPTCP_SKB_CB(skb)->end_seq); @@ -77,5 +76,4 @@ void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_ } pr_debug("msk=%p ack_seq=%llx", msk, msk->ack_seq); - mptcp_data_unlock(sk); } diff --git a/net/mptcp/options.c b/net/mptcp/options.c index d2527d189a79..e3e96a49f922 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -962,9 +962,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, /* subflows are fully established as soon as we get any * additional ack, including ADD_ADDR. */ - subflow->fully_established = 1; - WRITE_ONCE(msk->fully_established, true); - goto check_notify; + goto set_fully_established; } /* If the first established packet does not contain MP_CAPABLE + data @@ -986,7 +984,10 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, set_fully_established: if (unlikely(!READ_ONCE(msk->pm.server_side))) pr_warn_once("bogus mpc option on established client sk"); - mptcp_subflow_fully_established(subflow, mp_opt); + + mptcp_data_lock((struct sock *)msk); + __mptcp_subflow_fully_established(msk, subflow, mp_opt); + mptcp_data_unlock((struct sock *)msk); check_notify: /* if the subflow is not already linked into the conn_list, we can't diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 8cb6a873dae9..8ef2927ebca2 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3186,6 +3186,7 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, { struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req); struct sock *nsk = sk_clone_lock(sk, GFP_ATOMIC); + struct mptcp_subflow_context *subflow; struct mptcp_sock *msk; if (!nsk) @@ -3226,7 +3227,8 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, /* The msk maintain a ref to each subflow in the connections list */ WRITE_ONCE(msk->first, ssk); - list_add(&mptcp_subflow_ctx(ssk)->node, &msk->conn_list); + subflow = mptcp_subflow_ctx(ssk); + list_add(&subflow->node, &msk->conn_list); sock_hold(ssk); /* new mpc subflow takes ownership of the newly @@ -3241,6 +3243,9 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, __mptcp_propagate_sndbuf(nsk, ssk); mptcp_rcv_space_init(msk, ssk); + + if (mp_opt->suboptions & OPTION_MPTCP_MPC_ACK) + __mptcp_subflow_fully_established(msk, subflow, mp_opt); bh_unlock_sock(nsk); /* note: the newly allocated socket refcount is 2 now */ @@ -3478,8 +3483,6 @@ void mptcp_finish_connect(struct sock *ssk) * accessing the field below */ WRITE_ONCE(msk->local_key, subflow->local_key); - WRITE_ONCE(msk->snd_una, subflow->idsn + 1); - WRITE_ONCE(msk->wnd_end, subflow->idsn + 1 + tcp_sk(ssk)->snd_wnd); mptcp_pm_new_connection(msk, ssk, 0); } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 9f5ee82e3473..fefcbf585411 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -622,8 +622,9 @@ unsigned int mptcp_stale_loss_cnt(const struct net *net); unsigned int mptcp_close_timeout(const struct sock *sk); int mptcp_get_pm_type(const struct net *net); const char *mptcp_get_scheduler(const struct net *net); -void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, - const struct mptcp_options_received *mp_opt); +void __mptcp_subflow_fully_established(struct mptcp_sock *msk, + struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt); bool __mptcp_retransmit_pending_data(struct sock *sk); void mptcp_check_and_set_pending(struct sock *sk); void __mptcp_push_pending(struct sock *sk, unsigned int flags); @@ -952,8 +953,8 @@ void mptcp_event_pm_listener(const struct sock *ssk, enum mptcp_event_type event); bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); -void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, - const struct mptcp_options_received *mp_opt); +void __mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt); void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow, struct request_sock *req); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index c2df34ebcf28..c34ecadee120 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -441,20 +441,6 @@ void __mptcp_sync_state(struct sock *sk, int state) } } -static void mptcp_propagate_state(struct sock *sk, struct sock *ssk) -{ - struct mptcp_sock *msk = mptcp_sk(sk); - - mptcp_data_lock(sk); - if (!sock_owned_by_user(sk)) { - __mptcp_sync_state(sk, ssk->sk_state); - } else { - msk->pending_state = ssk->sk_state; - __set_bit(MPTCP_SYNC_STATE, &msk->cb_flags); - } - mptcp_data_unlock(sk); -} - static void subflow_set_remote_key(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, const struct mptcp_options_received *mp_opt) @@ -476,6 +462,31 @@ static void subflow_set_remote_key(struct mptcp_sock *msk, atomic64_set(&msk->rcv_wnd_sent, subflow->iasn); } +static void mptcp_propagate_state(struct sock *sk, struct sock *ssk, + struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt) +{ + struct mptcp_sock *msk = mptcp_sk(sk); + + mptcp_data_lock(sk); + if (mp_opt) { + /* Options are available only in the non fallback cases + * avoid updating rx path fields otherwise + */ + WRITE_ONCE(msk->snd_una, subflow->idsn + 1); + WRITE_ONCE(msk->wnd_end, subflow->idsn + 1 + tcp_sk(ssk)->snd_wnd); + subflow_set_remote_key(msk, subflow, mp_opt); + } + + if (!sock_owned_by_user(sk)) { + __mptcp_sync_state(sk, ssk->sk_state); + } else { + msk->pending_state = ssk->sk_state; + __set_bit(MPTCP_SYNC_STATE, &msk->cb_flags); + } + mptcp_data_unlock(sk); +} + static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); @@ -510,10 +521,9 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) if (mp_opt.deny_join_id0) WRITE_ONCE(msk->pm.remote_deny_join_id0, true); subflow->mp_capable = 1; - subflow_set_remote_key(msk, subflow, &mp_opt); MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEACTIVEACK); mptcp_finish_connect(sk); - mptcp_propagate_state(parent, sk); + mptcp_propagate_state(parent, sk, subflow, &mp_opt); } else if (subflow->request_join) { u8 hmac[SHA256_DIGEST_SIZE]; @@ -556,7 +566,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) } } else if (mptcp_check_fallback(sk)) { fallback: - mptcp_propagate_state(parent, sk); + mptcp_propagate_state(parent, sk, subflow, NULL); } return; @@ -741,17 +751,16 @@ void mptcp_subflow_drop_ctx(struct sock *ssk) kfree_rcu(ctx, rcu); } -void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, - const struct mptcp_options_received *mp_opt) +void __mptcp_subflow_fully_established(struct mptcp_sock *msk, + struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt) { - struct mptcp_sock *msk = mptcp_sk(subflow->conn); - subflow_set_remote_key(msk, subflow, mp_opt); subflow->fully_established = 1; WRITE_ONCE(msk->fully_established, true); if (subflow->is_mptfo) - mptcp_fastopen_gen_msk_ackseq(msk, subflow, mp_opt); + __mptcp_fastopen_gen_msk_ackseq(msk, subflow, mp_opt); } static struct sock *subflow_syn_recv_sock(const struct sock *sk, @@ -844,7 +853,6 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, * mpc option */ if (mp_opt.suboptions & OPTION_MPTCP_MPC_ACK) { - mptcp_subflow_fully_established(ctx, &mp_opt); mptcp_pm_fully_established(owner, child); ctx->pm_notified = 1; } @@ -1756,7 +1764,7 @@ static void subflow_state_change(struct sock *sk) mptcp_do_fallback(sk); pr_fallback(msk); subflow->conn_finished = 1; - mptcp_propagate_state(parent, sk); + mptcp_propagate_state(parent, sk, subflow, NULL); } /* as recvmsg() does not acquire the subflow socket for ssk selection From patchwork Thu Feb 8 18:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 198521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp352140dyd; Thu, 8 Feb 2024 10:07:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSF0y3q6lGYFFfDfFXAOp+CcPfft7oiMElGRzkYGl+nIwRwhutCUnsZkJtK2rFWh46JRo7 X-Received: by 2002:a17:902:f54d:b0:1d9:8ac8:d784 with SMTP id h13-20020a170902f54d00b001d98ac8d784mr9362181plf.7.1707415620616; Thu, 08 Feb 2024 10:07:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415620; cv=pass; d=google.com; s=arc-20160816; b=bsAqz3OHV8fsEn98ptfsOXYWXunCJ2+uIhTwVTj3hsP6ekQGzWMOGbK9TBHP+EtyMS BvhxjaeXQxqF2gs+diFwF98Q42HYKcb3vYCPa/qSiLScomfQikA9w3yu48VomyO+Kja3 EMtrd+U9akbNp1ktMdvDJHRgn/VZz/E6chwlV78LCdzlXdNXwGAYkNc/T52ECb2QT36W GYZ1kKx3u69YeOM1UnwgdSosIjPUHrvkHACrlSUN+NQqBn2Z2P6bLjQALnBWOOjjaxxg d2crhH8h7ZtpzDxdtPgiD6oC0BEK7l26oED0nQXMKoB7+LADaaY0Oo2y3sjzVNEm8gV6 I9TQ== 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=65AOkE2JGl02u97LcBqLl6whVDIzHfcqaQjPNgbmPzw=; fh=eyxM75L0yHmLl1wyz4uhYJ9IoTmViYr7Lqn/fHaBrpQ=; b=T7fq8q/J9KBlq5y7TJePR70HaR9jJIdEL2T/TNJinSo+QipRfrrwItMWnLn/YIqvSg z7HCYR+oRFVEpcII30QSxbf8jiQU/wFWgP4+JApKY7Ba3fYTcZdjRIVJPfGyeogoPV8U g/LaNs4IPr7CmydbHPHsOizVh/m9EUQBrxh51Tb1YfFd82sPKyLIOHCyFvMPojmoD/aq addb92DwdYiRNPRmlrgTWbsGeC9iJ2bZViK3qEWTx7ywcr6685SbhxhjrKcIGOKs4cPZ A/4gsnKnl9cBbJoJFePSyljLkfGelhKENri3d+VsDl70S4DckAczktETjNESJDUBVlse +ffQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AfsCf+hv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58510-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58510-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXsH8ff7TGS6ZhE3r9QdVt1jDwYVz5Eqbpj6Y4K0hWxtW/m76suloAsLiJQ/mAcK4P+RGvVBCEWPkeh5C9M9povuEa7/g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b1-20020a170902d50100b001d727386683si99335plg.103.2024.02.08.10.07.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:07:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58510-ouuuleilei=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=AfsCf+hv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58510-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58510-ouuuleilei=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 26E6A28398B for ; Thu, 8 Feb 2024 18:06:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 434BA85C6F; Thu, 8 Feb 2024 18:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AfsCf+hv" 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 71CB8128833; Thu, 8 Feb 2024 18:04:41 +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=1707415481; cv=none; b=DfVtkaixQaDa376Kx0opBnP67T7vJm6rV6HpUY8lPdfhQ+66lb0m5NIpguKweNYUiqUYbhol75fVBX+tSHsPAWyDS7r4nYmqCVjByLSml77tHmnuHlqQGjVGZUIaug09okOIQNMrgIFDDMjcd5jm+ZaCMRa7ZGdpjBkjAyKQCtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415481; c=relaxed/simple; bh=NvTXRnuON6qPQNYuNjtmkLBaOdT6vLsUQt2KlMjwaRg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hlalu6oY95u57LnyPAVQQI+KUD6pPjhcGV1cXSPXtCyIQAO0h5Dlr90L5uEo/nern3R9bSxtwsHLQFgZAtQ5ceKp/iB02/S4vr4ABMQhXf9M+0Nt+TwSxPdHqrV7S5mJZ1VAcvAMVpQ21Vf0GZ9lDk8MVGXUj3Rz26/ZCoAFB+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AfsCf+hv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F90FC43399; Thu, 8 Feb 2024 18:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415480; bh=NvTXRnuON6qPQNYuNjtmkLBaOdT6vLsUQt2KlMjwaRg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AfsCf+hvzcWGGLz8s8ueraM6xG333BQf/2BM1uSkw3s2DmRiP758Un8yRR76tvNaO w71OU7ffxu4lw41dLeeHBMWf1pzT/kUQUgDeKyoh3A2dAfU1ucqfxx2qXU9fOrIBkR OfhwynHiDhDgUjRAW6d4dmj8rpotTmGZJurv/p1QJ6wQUBSrN7k5qOprNFoc3V9uly synif8g6FoxJ4TEQ8EgVm4cPsnjaJGVUNv8Hcjn8fZMvEfWbekKqwLn86fTTKITxZa BOfan8bj8G+SJ9+hyDak8Hs1Yq5uJAtVaLI8zBt3oSfS/LA+ZdAB2ECHjeb/2KBoEr UmElN3vqcGwRg== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:53 +0100 Subject: [PATCH net 5/7] mptcp: check addrs list in userspace_pm_get_local_id Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-5-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, Geliang Tang X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1624; i=matttbe@kernel.org; h=from:subject:message-id; bh=8aCCu0yid68+GRgZ0xl8ByhW49kl62JqasxySjE1hiQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxRehMiBc0n4f5gHnwPOyMOq49tP8zHm2lFVkT cE0jZcZVGWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXoQAKCRD2t4JPQmmg cxntEADURwJIyiZOlgRgmGk5605OerW8KhB2LAduQSzURfaFwUvTMpY0gAlP1jNEPHikGDBNPiF uOL+nPGidIDA/aoBUA18uSMVjP3lW6Fo/f5eAwPyMnPQzp8zVGkvOWDf7mi5Z5W+3dufYQfggYk U9Buxrb/uZ5Qq1Mnlu1Q0WwFrHTUjfUWZRMvOw5K/8fY2kN7qg1JxHDLpspfHM+qqdhsyi+73nF VITEEcn0tF2QxUxwP72FP/RhxO3e/dXoz7nmwmqLO4BUzO7smxueGgWJtYJNROjKC+g739r5VQX zAtfaGgm+MwHw4ZTMhRDJ/TqHGjJ5qxVQD+LkjfXj4aTY61N9onisctTHJ+HvhgIMaPW8bJ/GM3 5ymw4/GaknE8KN9ZmHjDvECOyFjfCoRYr8R2KnG4sN7TjMbMmrbfPLaXlocEwxjqUh9pLKkbLkQ l9lOr96uMF9YAU3HhgrpYZDjQLPGQ1R4F6Pi8U6IxQm7nzrFpcFgUFb705muBu4J1Lfe1vICjEX Y04hObPoIAElQd8fHfgLLRwyOqrCvvOsMWEpUaRLs17bVgYOR7Og5NFPurVFn4zB77d4qImkjYy a4b7uGx1pV7rx5xwie7qk+buNeYwnnQ1P1C+F5/xyGdnDOOQtyxS8ttuea2UY08zLE/Y90Zo7dd SqFfspoFmeCNIJQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790355041493843918 X-GMAIL-MSGID: 1790355041493843918 From: Geliang Tang Before adding a new entry in mptcp_userspace_pm_get_local_id(), it's better to check whether this address is already in userspace pm local address list. If it's in the list, no need to add a new entry, just return it's address ID and use this address. Fixes: 8b20137012d9 ("mptcp: read attributes of addr entries managed by userspace PMs") Cc: stable@vger.kernel.org Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_userspace.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index efecbe3cf415..4f3901d5b8ef 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -130,10 +130,21 @@ int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) { - struct mptcp_pm_addr_entry new_entry; + struct mptcp_pm_addr_entry *entry = NULL, *e, new_entry; __be16 msk_sport = ((struct inet_sock *) inet_sk((struct sock *)msk))->inet_sport; + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { + if (mptcp_addresses_equal(&e->addr, skc, false)) { + entry = e; + break; + } + } + spin_unlock_bh(&msk->pm.lock); + if (entry) + return entry->addr.id; + memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry)); new_entry.addr = *skc; new_entry.addr.id = 0; From patchwork Thu Feb 8 18:03:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 198522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp352257dyd; Thu, 8 Feb 2024 10:07:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IES8bBcn7aqS3jz7U6EjYpGq37sEASSSHgRL9NyZkjPXusRmA95VJc4KK7InywlaoXZPlIV X-Received: by 2002:a05:6808:1b07:b0:3bf:e5b6:c85d with SMTP id bx7-20020a0568081b0700b003bfe5b6c85dmr138144oib.30.1707415628608; Thu, 08 Feb 2024 10:07:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415628; cv=pass; d=google.com; s=arc-20160816; b=Jz52e2PeOjmRsosbWhlxsLtpHMBubwO1zD+kR/c6eZ50O8BwA5y8w/5m3Z+s7tmf9A izC8l248PQFq/8veJwwH5TfaLMj0WpP2hz1DmKscF9DRRy0/x1P9gUVwzL3L0wsIYrzV Qut7uCXbUZDK7QddOe6PPL7mfeoCIw+aiMxHt4siRF4Gwexd8sl5MNWuZqJAktEoIAJe 19Iwguw+ViRZ5gNOqbojq7N8hLcUPAlABHewgjFzSyYy7aw70y3fBCtyWD8NENoLNBpM 0LQ0+d0RTiqsO4I3Zw3gNVCo/G5x9nXBVa6bEdbTIFcxVH1ARefBCa4SuuylpKhIwT9b SlSg== 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=SF8v/dEhcYGnwy4p+IZpCrnvHyaMiwIBBxanfhNER98=; b=07BvwbRGEMs9OWC/QXxx2CvhrZE3TCAzmigNCXXOLZEgyFlvLbYQNETSuPhY3JsVbU Iu9DpqbBHEFRkaVe1rT2wK3iLGFq7ftxXDNj5PUtWDnSqJXpzwez8nO4CoinjJ/XmgvB PJQMAzG6m6FboxbOxQN4/d1+w4NH5YDk2hk6Kv/Ntf4pTeid/nzWPVinj1yrH2E/yUuV YnUnLiQOrERSSGmsMn8xTokXzjOsHLi2yAoypk20jSWFJQh24X+5l85dtEtamSzEhGUq MFyfELWUtfHoxtuGc6+bZTt/3DZu8kbLYRDaX5pMexVySQzOgwdjQqWvyMsEFevUJRd9 HzGw==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58511-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVHHdughunCoK4EKzIalCyKuiuCBAJo1ETa6J1BfKeQAYynA9mLbJS7rzi3hiUI84bkPpUPOyBLW/amx9nUJyUPRBFytA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bh5-20020a056130064500b007d64adba08fsi704902uab.134.2024.02.08.10.07.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:07:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58511-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58511-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 36EFE1C24289 for ; Thu, 8 Feb 2024 18:06:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2480E129A96; Thu, 8 Feb 2024 18:04:48 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790355050224870906 X-GMAIL-MSGID: 1790355050224870906 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; } From patchwork Thu Feb 8 18:03:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 198523 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp352520dyd; Thu, 8 Feb 2024 10:07:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUO8b6F05XZ+WikUQ34YO8r/ccl1o3h6vF/bKX+0av/ScAUhlIvbzydeIOgx8bffJD1Y1kcUNNpF7pMhazsYYX/RxjkBQ== X-Google-Smtp-Source: AGHT+IHovvyDzN539k84FgA3O21GQreXdcSFUYjkKaL5hKBY98SfJzXlAHjWrutaMv8xRGR3VaMD X-Received: by 2002:a05:6602:2984:b0:7c3:f75f:736b with SMTP id o4-20020a056602298400b007c3f75f736bmr451195ior.11.1707415649594; Thu, 08 Feb 2024 10:07:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707415649; cv=pass; d=google.com; s=arc-20160816; b=VtvhtmbsgHi5EvhzAX9meO7hmH6e0S4oa26X7gLC1eeegLcZLJMZTJti9NUfR+Nc4R uYRUQeGiSU/ZwzIYOvPk0OjtiRqYm92mWoIbD8n4u1A5bn7S4H0HMNHfNFfcfXU48Qsb Y8xfzO54tEaKzYmEATikAT3P2JoQTggu5/LsUvF1NHXpCGqe/xzAfI24aIUIUZBTBBKm KR6aunZZaEqL46OiX148uCUHWs2QtUFdw1l9fKN2486AwULxjP4tPgTgUKRQbN80zLLv YRIeSktcSF97vtJtEiYs61YL2AQaxOg2/J6Yc/ekI5u0WU0/mNdhJyg4xMdNEIUJWOM7 U1UA== 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=oa0F3gwx6bMEQtg5LoitNy5lorYXOkLZkc04sq4HEy8=; fh=AR2czFTAvlw1hPZEAhAjchZJYxelvvOIxRShpR0NGcs=; b=JKrOQziLrmsaTHU7JrbYKXVFp0uDTvuExrL2YBIOLnmoZC70a1IYyLJ+UmpAm4nA2Q pN+S0T8yZcqTxAH0iiwf/m5QnF+xkZLpneddoEHS+DjDovc4HzyFuYUx16oLdN/OufQW kLOpSTEMD9mAMOIkbFKk42AkFeO0oofDekNK0rBtJJDMYeb0x4gyGX3Dn7Roo6MJk8bT LUnW4/D14uARUOKaK480ejXcifKWQTeP27scJ485heY3hcoIondYW/pI22yE3vsB7cD3 0c0u3fwHKjA/JEjQUhctBsESVR0DmZEdnw4vExxa0Klw1y4vz39OOb10OWCG0pz+BaG4 v+wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UhoL6Cm5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58512-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58512-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCU6vNNY/R+AZKSPXHmahuv8FJ08e9aUMqaDrxBYfp+lCraAnaqUo4/sWbMQL1Rq4a/Rhn/2yr1pycGDOO7NSJsop030KQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k63-20020a638442000000b005d92a3f1196si123715pgd.592.2024.02.08.10.07.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:07:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58512-ouuuleilei=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=UhoL6Cm5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-58512-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58512-ouuuleilei=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 91B82283A80 for ; Thu, 8 Feb 2024 18:07:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 799A212AACD; Thu, 8 Feb 2024 18:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UhoL6Cm5" 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 CEBE786132; Thu, 8 Feb 2024 18:04:48 +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=1707415488; cv=none; b=rlViRyWj5x4O55c8+0TDcmSj2TOrZ0P0zyEa6d4DE8nEYvIECxznF7HJOhjftTSMXXsTc/xc9MoDijmW0A9UDc5cSwJ1XKakPrDgeg5Rk2yPDQXYNAyk7iLEB9cVidohTLgPYA5qoRmldENQDT4fG3U5i02fg7c1PORGpCvb8nY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707415488; c=relaxed/simple; bh=3Uhrwe4sRvrwINsS64MrEMTgrGNb4S7Ahy2QqbR4f0o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W0ubRPsFx7QfgAfmamB0kvVaf2NThr8WbPoPSpoqD9azJhozzIeXKi4agGORm1rMoJscsOJ8lhm4LPNFJ0BA669b9F/GJ9kMEVYJhd04zR+iRWyWop4e2/DhlFjZeojrYAtM5D15gVcEl1TyKou0bgnZfqctX/X5/+Q49sLIdbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UhoL6Cm5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E80DC43399; Thu, 8 Feb 2024 18:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707415488; bh=3Uhrwe4sRvrwINsS64MrEMTgrGNb4S7Ahy2QqbR4f0o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UhoL6Cm5ieWcXeo8f3wJo/Me6dy0QuAxDjlVGWEoAH+fs64ZU02V+5+Fj0k2eAkwF BYSNB5k4bywcbzwIOnDhqk9Dv0/aNzw36wtrHkEdVttsCDu7HMqdPa6xSHxGoO/yZI LcDj3OOmkJUUckY79T4UUKhJC9pP9LLhQ1/kLOJX6E/FitqpQH7Ee7C/YWMAEAjTwX k1ZpeRL25RN3fDrn8VEKpiHY8OmF3340jlfEc27+W0DVG0VJfkcyK5PNGOeKrHNPVy b/ns23XurVR8BA/HL0bUJWFwHIUnuP8aqeg8GacwiQl+22sOYjSGsL3tOx2GuLDDAs 5cMd3bn2pkR6g== From: "Matthieu Baerts (NGI0)" Date: Thu, 08 Feb 2024 19:03:55 +0100 Subject: [PATCH net 7/7] MAINTAINERS: update Geliang's email address Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240208-upstream-net-20240202-locking-cleanup-misc-v1-7-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)" X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1962; i=matttbe@kernel.org; h=from:subject:message-id; bh=tZVKtIFKLYUt/oUS595FbNi1gycPQG00LtyiN6EKU6k=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlxReiRCw+6cpvej3wyzo48ma+ikX1bsTWfnN8K mGQLRB5xOGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZcUXogAKCRD2t4JPQmmg c4UJEADeoCILa8kvid/d8rgzep3cR6jKmDzEGODmFgosVbyMKYZVrdxDdyQqfw8CwbHtgpwhO8X 9YmoWCOvs3f3/7Mf8cQYS4isCSuSt9MoyB2/MZjHX3JDuWOIqE7E4F4cNVQdskcT6ztSugCbMoE 7iQK9iSFMJAwJAF6U7qd3COGYLJY8xzo1eYOXJYnnteDSLcifXuu775elASlE+aLI7Ppwk0srtb ADZuDQZh3v2yekBgm6PYi6raHNl0qdDwSaWCVebqnztwKien9kGD5MX9OxqCT4DilvVsiFNLfbA +zVLMKA3yKIw8OJ2XMZuJ7Ni+kjE5rpskdWNbOSASkl+QMaV2GAu0aewpprA6XX0JdBxrfFXGzI XyzQRN0PlTx0J9dU8KR2ebwJDHeLgf3lqVXKIyjS19K4kBsPVK1v2JMApy3ikyDuw68ntbD367+ u8HAEIrDTiSraolcW8GRaImki2/LhP/PNgl2W9ttgucddtoYcjesrXYpW3akNMqp9ACtcFfy1N+ Locb/FRi5jBFEqoWEvHxXi7VqDftm6r+JsxScZFFDpuW8pGr/esA28xh4YDh9Th5fHDW/Qwwirh 6e99w8h3kG7VpeBBnaWUTbWaIJvqY9LO8oiOzUaxnGtO9m/3AlDLhYFLjxAIufEimViK1jvPrKp JLKpCrzKGpkkGoA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790355072111061439 X-GMAIL-MSGID: 1790355072111061439 From: Geliang Tang Update my email-address in MAINTAINERS and .mailmap entries to my kernel.org account. Suggested-by: Mat Martineau Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- .mailmap | 9 +++++---- MAINTAINERS | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.mailmap b/.mailmap index 04998f7bda81..327e7eddd146 100644 --- a/.mailmap +++ b/.mailmap @@ -191,10 +191,11 @@ Gao Xiang Gao Xiang Gao Xiang Gao Xiang -Geliang Tang -Geliang Tang -Geliang Tang -Geliang Tang +Geliang Tang +Geliang Tang +Geliang Tang +Geliang Tang +Geliang Tang Georgi Djakov Gerald Schaefer Gerald Schaefer diff --git a/MAINTAINERS b/MAINTAINERS index 42bdf99ed979..d7b5c622575a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15324,7 +15324,7 @@ K: \bmdo_ NETWORKING [MPTCP] M: Matthieu Baerts M: Mat Martineau -R: Geliang Tang +R: Geliang Tang L: netdev@vger.kernel.org L: mptcp@lists.linux.dev S: Maintained