From patchwork Tue Feb 7 13:04:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 53873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836241wrn; Tue, 7 Feb 2023 05:05:55 -0800 (PST) X-Google-Smtp-Source: AK7set9cKieMz+b9ALw9CKue++Nrz0CDiY9Weax+sG7egi9LVg5wXcEge6c6J9sKjJB/GARPKg6X X-Received: by 2002:a50:99da:0:b0:4aa:a72e:bf2b with SMTP id n26-20020a5099da000000b004aaa72ebf2bmr3221602edb.2.1675775155026; Tue, 07 Feb 2023 05:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775155; cv=none; d=google.com; s=arc-20160816; b=D6RtPuY6XzRChfsEG7iQwnFz0Kzf95QQ9YmbvsAM8W2fhfO4iopaOx+KWX7TWDvJCr Y5uLCOQCJTls3oOdacHNW3lnTozxbjIMtYMYcCWGe4uGePJQIELTJj8DVIBWuHyEqUpC QZ6AqR5kSGfpICVWvN2RoCtgOSX5KJTgSVDBu0GT5PVGupwqnGtBWyEBJajoVk7vP2B4 ZPvVnmBcxAUhZViPOdMPa8pceVnmdjCLXWzldkvHEvbtOpUjkLPHm6A3gfWFU4kA1poh IDeRUS4FUkEW+d5OsNK6OqovNToGqHBnVSzRnpZrlcRHaMvIIgx+QpTHAQNSIN4U5Bsn wUxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=7LOpSixpkQdgVar2A+zecF275+TNibOzBkrBgKo8zNk=; b=bcEDvmi5Jzt81nDtXWr/V4i2cooSQcPMGTZynnxBQ0P6hGQcsBckWKtPZbKyw4lR83 n3D2OkBf4Hou936IKjzxQ9e5wxdSF3ojU3GJqLR0TRzfOR2TIq84xifyHjyLtKFsUwfK XsIJBKSmZH7Uz4l7NICwX2t8pkjoc3dXZmqYbU1AYJMPEYyW5TYBt4GpoQRr6b1ejUkG KAabQ0KS7/mJMkXxZa0sZOJNBuAlBKnD/H5YjuMpGRnH5I8rk1pfACD9UEWNrZnIqgX0 8rntn1HdjT5aawZqxcDgJycYC/yFuB1vRex+jS5xHE1y7+YHCU1uOVdcE6VQzW0dD9tD misw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=Mi8N6Iq2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 10-20020a170906008a00b008814f25d095si18633348ejc.71.2023.02.07.05.05.31; Tue, 07 Feb 2023 05:05:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=Mi8N6Iq2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbjBGNFL (ORCPT + 99 others); Tue, 7 Feb 2023 08:05:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232128AbjBGNE5 (ORCPT ); Tue, 7 Feb 2023 08:04:57 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4DE33A58F for ; Tue, 7 Feb 2023 05:04:47 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id k13so6077348wrh.8 for ; Tue, 07 Feb 2023 05:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7LOpSixpkQdgVar2A+zecF275+TNibOzBkrBgKo8zNk=; b=Mi8N6Iq2DI8Ul1mH9lMJJRrndmrDMvovgwpackgY4PdmKqJoW0+QLwR3POasUEYrZA uOBTki03AnF5sJ2JCFsG4wFchwFa4Bd2mNSYWCbOodWOdlcZpdcNNIPqFDbX66064UtG UOa76jSMsBZYPs68Cn6Kz+XjInIbVpYcLOeejoV5MuzC9ctkqBHU947UBVFsOQnSU+MT mNkNYB2JZftpHBEv8WGMJohb0WMUblsv4czx8XmeJio0VNwgcufa7AxfspF6MyVfwF6x td5fm0tjAQl1VcJFc1i/eVGmW0oMwUYatCJeQNrdya+9k8PidB8Mu+A2tKmuBwfnUKv2 N3cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7LOpSixpkQdgVar2A+zecF275+TNibOzBkrBgKo8zNk=; b=IHMzI9Y6Dvnj97qVVJgsRo5GZnmQXWH943p5GIk+NTpaHZcnoGKq/w+li9AfzSJpNI +uV28dZC1WltwTjnv8aKbddpGKfuVRuHr3ogEL4/K9MEEoKWlltmUfx4fK3VEONfLSAP 55JPqzKev6iMslRyT3uXbr3+olcZGygS0BrEiH79tdKS8jk2K8BETJcgUu7O5TZ4gDrO EKAb4yO+Z1FFCRezlU5CTBP59EAHomxD466EzUUrrspV8RNhgIZk9PIUscHr0rMT5NtH 4PdGGhJo4m6ofk2imAk3RG0K7zQjeiuhBEcx7mZP25DoxZEHiRT9PLaHYgnF9uxpf4Yg qAHw== X-Gm-Message-State: AO0yUKVim9NzpmlvSHYd9VGIsJU0mV6/qDES32l1Na/RA7ladW3wQ/4+ b7B6UqSU8ZtVbA/qyqDnDi0wew== X-Received: by 2002:a5d:494f:0:b0:2bf:df72:fe03 with SMTP id r15-20020a5d494f000000b002bfdf72fe03mr3138556wrs.70.1675775086305; Tue, 07 Feb 2023 05:04:46 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:45 -0800 (PST) From: Matthieu Baerts Date: Tue, 07 Feb 2023 14:04:16 +0100 Subject: [PATCH net 4/6] mptcp: be careful on subflow status propagation on errors MIME-Version: 1.0 Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-4-2031b495c7cc@tessares.net> References: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> In-Reply-To: <20230207-upstream-net-20230207-various-fix-6-2-v1-0-2031b495c7cc@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Davide Caratti , Mat Martineau , Benjamin Hesmans , Geliang Tang , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2148; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=XAts6+yHbdNSvA+xupWdCh0k36YlOwYaclLeEeUJtYk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxotj/IXQmKVqdQ2qxY/yMJkzCN9cpHlAfkz KxpMx1ZmEmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg c3snD/4hsygAbCvAnR+5LM/7q6FyHNQQJ4NENc9Srbahyd77zaYHqqgOZMeIeXIiPIHvFSnN2t2 prsfQQHP9L7XH48Vdah4QsdCxUE5ElsFUcTUIPo8A8we1vlWCF0KgT6Oh4EITgYms+VV7mMOi+7 /zJTG9Fcb6kj9PPKqhTpuLdri/ZqVzsdcX4EiisPtcflwF7o2t/H5fj1zj7d6AFsr3xXA/B5+Ip 41X0RJXwFcNmwz5Wznk05fz6vDmgXij66vFOEAOyLvRVkBd/on11Up+IVZuDF+KM0/FZJyJtzgj Vprpo50N9RFYudzFDg/X0rXbCYtL08ysOjNKr9HBMZ0SCUJAVHhatFlRxHHC34o3OCcVom7deQN nL65VC5VxHCSoclkPHKbjGgvqTqxtoMZQfWWPWvBp6PIrU0DerZXv6e20cVlMBKVrljytPhTRa3 Rr69eY8aVp4HFOEySXCNcSCDugNItDqMAY/uAHluBWzKK996oAQpEMiRF/pAP8GHSR+veU/vx3w 97Ft05WIwrTWByKEkQBlmDhPz4bSwWKV7T0WQV2qsZytyQ/Mbya7Lvugzvp/v3U9w5cA9KxWbfw uUghkOHb8CmK3SYg2YlUQcYGkUXJfjD5/LhSxFrw6GXT5TseAU8B8CB8CwMKbG1YTRUhEzHmpGk /Jql0l/SAPHwc0w== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177608715493224?= X-GMAIL-MSGID: =?utf-8?q?1757177608715493224?= From: Paolo Abeni Currently the subflow error report callback unconditionally propagates the fallback subflow status to the owning msk. If the msk is already orphaned, the above prevents the code from correctly tracking the msk moving to the TCP_CLOSE state and doing the appropriate cleanup. All the above causes increasing memory usage over time and sporadic self-tests failures. There is a great deal of infrastructure trying to propagate correctly the fallback subflow status to the owning mptcp socket, e.g. via mptcp_subflow_eof() and subflow_sched_work_if_closed(): in the error propagation path we need only to cope with unorphaned sockets. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/339 Fixes: 15cc10453398 ("mptcp: deliver ssk errors to msk") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/subflow.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index a3e5026bee5b..32904c76c6a1 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1399,6 +1399,7 @@ void __mptcp_error_report(struct sock *sk) mptcp_for_each_subflow(msk, subflow) { struct sock *ssk = mptcp_subflow_tcp_sock(subflow); int err = sock_error(ssk); + int ssk_state; if (!err) continue; @@ -1409,7 +1410,14 @@ void __mptcp_error_report(struct sock *sk) if (sk->sk_state != TCP_SYN_SENT && !__mptcp_check_fallback(msk)) continue; - inet_sk_state_store(sk, inet_sk_state_load(ssk)); + /* We need to propagate only transition to CLOSE state. + * Orphaned socket will see such state change via + * subflow_sched_work_if_closed() and that path will properly + * destroy the msk as needed. + */ + ssk_state = inet_sk_state_load(ssk); + if (ssk_state == TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) + inet_sk_state_store(sk, ssk_state); sk->sk_err = -err; /* This barrier is coupled with smp_rmb() in mptcp_poll() */