From patchwork Thu Mar 9 14:49:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342275wrd; Thu, 9 Mar 2023 07:09:01 -0800 (PST) X-Google-Smtp-Source: AK7set8Qj5SjisCVpebdJMQ68qifYXdbIT0347bGJa3HXxlauzH3Q6qtfAnWtLqJnnhrDDXJdk7N X-Received: by 2002:a5d:8150:0:b0:74d:1ccb:e5a5 with SMTP id f16-20020a5d8150000000b0074d1ccbe5a5mr13889252ioo.6.1678374541420; Thu, 09 Mar 2023 07:09:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374541; cv=none; d=google.com; s=arc-20160816; b=I0aUoRkCfqsycUEXI51G1Sf5227QCWbu92XRYAn3FphMimZ39JB1m+XlvRh6NhClke kKykRasdCEc7H/gmWwAIleIa1ijczwSzeA4gnUbbzYMq4sEiTV0iUI1jUmHOOydoexrS FBuK6PIaWdUcv9OSsOMfMFaXCUjHY/zxuqFG91w0XXhxhXYTHwcE4ZfjSV936XPagRN/ mf08TQVG9IUtyVA1zUW8Gm7XmMeA1dn0vTkQUrGKqJ8xnqkvrZi6827eLCjdByBLogm2 ytbLPX62fbBNEkcBWFGZlILe9C6tl2T3mWzntv/4a2P8HCuLOem3iSdCdk2WXtaS6UcK SdjQ== 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=Yrosoov8wMW4bQ0IPE1nmhR+l/Rp0kl9JcSqtQe1jpE=; b=fJ3dDZEX6MazZT8Lxtftt4r30BwTx/miAJ8h/uJSF3nGasN450kHjRLKJyPvRfGWof +KV2mLRZb+idD6UQjqx6q4CHntzyPgm9XGv+k3m/a7MUy3fOxM0J5E5BKLkTqLOH5iXD u8NYimnr+fTpvVMR5T9Rkzf20UU5Ww8W271nVJR07Duigrv5xX1bDnXgAw9ZPffjBMBa ayL9oNBRpPLCNBqupB7vThsZBw6OA4vQbWQK0c3JtF7KiKneZVBvtgwesR8anax4tWgv BOnbEoqLOeEAfiESO9jwBMtYsWz4pbcxJtRKxX72kyDl3XlZZ4mKC/3ulhmcPf8FghkC 7G8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=76O9ecj6; 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=REJECT sp=REJECT 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 s15-20020a5e980f000000b00743eda98b9fsi18712548ioj.40.2023.03.09.07.08.46; Thu, 09 Mar 2023 07:09:01 -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=76O9ecj6; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbjCIOxC (ORCPT + 99 others); Thu, 9 Mar 2023 09:53:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjCIOw0 (ORCPT ); Thu, 9 Mar 2023 09:52:26 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A1CB2B2A2 for ; Thu, 9 Mar 2023 06:50:31 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-176b90e14a9so2513899fac.9 for ; Thu, 09 Mar 2023 06:50:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373427; 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=Yrosoov8wMW4bQ0IPE1nmhR+l/Rp0kl9JcSqtQe1jpE=; b=76O9ecj625aE035fR+jJca0HDYqsNoDQVIobeO4uYZKvNAy2QgeMNl8bYcvhqNILq4 KaUmQ1TBTkHrALfRRzpIlPVR897HxDLP+c4ZUMAG0+krNEo9aO35Fc/SDyMNFYbgcmjR dyyiweHsCh5H+XQBoj9eyoAp1WBdALG9g2x8W1PfGSQUHRq1AzP4TbqUc7Hxz11aJep8 R68ROACrf9mCnVCZ4EUjBc6ZYI//dy2CiaYlhrAjoXEelqFlklz/obHl0RXBMox38Gk+ dk6iRleuEAyI2ocfY1JU50FMoplFBfBhu3LSV9FcyyyVzWIOQ87t+mSNBttpVkMJQwOv iwzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373427; 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=Yrosoov8wMW4bQ0IPE1nmhR+l/Rp0kl9JcSqtQe1jpE=; b=6dqdb5UahXXSJ8CrK6TrZuZdcskNliaAgJ0UphWSe6YQdMz/6fCAyBMUljg1t9XEaS Bi5Vk8AAjRZJwGUZ4piCyjX3wl0BM9DLdx7QoqMVFu3d8gH9mzFc/b4AIpGvzDKGJYto FhT/qdjPICCwk5yGg8+oA7VwpxQD1ovrGwgcZOeZ3T88CARHRgOjcys9h2bH4zpvr7wX mwtQf+70QbRvQN7TXDU3xh1thxsZ9p1OAgkanUFENnOSfppM4OyKP5f9xAr1cbJxg9Ge iIwInIwKqJEa2nowStnSo111CCgvegOtSzHOcmyKzDlXmSCD6WdbSPAl8H5jkmh4Suke ACHg== X-Gm-Message-State: AO0yUKX29WvtkHAiDpqKn4vVAE+8ndfDP8dfGqwUPl0CqOAizKOCMVoi dcXnxFgi3vFwzuLylzhDxp1vmQ== X-Received: by 2002:a05:6870:65a2:b0:176:271d:2e22 with SMTP id fp34-20020a05687065a200b00176271d2e22mr2852112oab.19.1678373427133; Thu, 09 Mar 2023 06:50:27 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:50:26 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:49:57 +0100 Subject: [PATCH net v2 1/8] mptcp: fix possible deadlock in subflow_error_report MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-1-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , Christoph Paasch , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1773; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=hldf995oDj7E8lQxC4BW/Zq3Mra/hurDbKe3yAogNH0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhTQvT//R9yYrZy+DQCBgpgC83QuOSWPCRI UqPZe1dcRiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg c3YXEACUmPPmO+kb+DzJ09sg4PSISe1YOWwSv/mfrMCBc61sXOCGf7ZOllBXYfuF0aEqMJv+EkS 7D7ElqKu505tvkp5UWykx+9kUtKboXrxB1gkoJeDuXaRxs/f5Ed/u7u+AFwtR8JV1OUHpB889g5 K2IuPvpPRLBySAx0/I625uSqqty+rN7R84G7w5DCT3yThX6ViQJn9Lby1w4rcVVA9S35+vDgL6U iAFXIjTYVbspATWOY42glSHljqgPe/zBTTbvcwuxnof+RAGcVZnVz3kqztMduVOsN83A+Z0w7qF zP23RmPdN579J9ZtLex3LgkRy31y02XZxyx4OziSNYlsgGeWu5eebTQ5FuoWhLuvDCx1i08hUyw QxSKb5DL/VBkQF4kIuz9JdybvOvQvTk1rvvIqL9hu5EagFfRPDjNsbwZgReKw2F4LNtLRlwjCmq xzRMKvZuTDstc9vn3800vHJWeS4dXlgLvBUtwjJMaQpv/mgWKgxomaEoCp2hTpP+fz0TeZaZ7dM 8lHSQQSVa1Re/N7vVfzLwO6SlS7ytLcw1Z4kHtCn3RxMvws201IwAIlAqN7/sv/0sxov4Wl3SPa sD/Lbs6h4ZCBuJUg2B9J+1sSnbnBRsPnUeFp6aA/ebjRDtD5TjWVUdHP+4a5a8+6rBh+XlXCJeB /4wzJXDSTjabKIA== 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?1759903263225382917?= X-GMAIL-MSGID: =?utf-8?q?1759903263225382917?= From: Paolo Abeni Christoph reported a possible deadlock while the TCP stack destroys an unaccepted subflow due to an incoming reset: the MPTCP socket error path tries to acquire the msk-level socket lock while TCP still owns the listener socket accept queue spinlock, and the reverse dependency already exists in the TCP stack. Note that the above is actually a lockdep false positive, as the chain involves two separate sockets. A different per-socket lockdep key will address the issue, but such a change will be quite invasive. Instead, we can simply stop earlier the socket error handling for orphaned or unaccepted subflows, breaking the critical lockdep chain. Error handling in such a scenario is a no-op. Reported-and-tested-by: Christoph Paasch Fixes: 15cc10453398 ("mptcp: deliver ssk errors to msk") Cc: stable@vger.kernel.org Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/355 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/subflow.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 4ae1a7304cf0..5070dc33675d 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1432,6 +1432,13 @@ static void subflow_error_report(struct sock *ssk) { struct sock *sk = mptcp_subflow_ctx(ssk)->conn; + /* bail early if this is a no-op, so that we avoid introducing a + * problematic lockdep dependency between TCP accept queue lock + * and msk socket spinlock + */ + if (!sk->sk_socket) + return; + mptcp_data_lock(sk); if (!sock_owned_by_user(sk)) __mptcp_error_report(sk); From patchwork Thu Mar 9 14:49:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp339271wrd; Thu, 9 Mar 2023 07:04:55 -0800 (PST) X-Google-Smtp-Source: AK7set9hXaW3lxiq7TAIObskjyh8Bax60DxVPvxOdLaRZTtYFJnZVT1axiXeeZ5nB/qXHQhD/f0B X-Received: by 2002:a05:6e02:1a8e:b0:31f:9b6e:2f51 with SMTP id k14-20020a056e021a8e00b0031f9b6e2f51mr12123203ilv.5.1678374295010; Thu, 09 Mar 2023 07:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374294; cv=none; d=google.com; s=arc-20160816; b=PJCKHPjWK2OlHrO2zThCJx0J3u9/u2mpqsKakMAfdj6yLWcfwuH2llNnmYyURHCT0I GltIs5nzpPygDNATwR3mLQlsVectJ0kJChmX4C1n6saHEFp0aqC1wegC5SHbrFlBb+H1 odKpYlgGEMmWMtgYFQB8C48bO1b0+qi8xi4sbLe105VwWqvsFoQrEb8nveP5lN99Vv+m c86mw68aHb3GwgtYyGYULtDFL7qFITNYBWVMw4dI+pym5yKbTD5VJMwRs6JtGUGpYuVX clLsXsgec/t4RJfadP0OM6PgmyT7DincqlGNYNVi+Rrx5Pq5wwH1gg1cnmyr3cHCXd7B VQAw== 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=Axm/mEYsFxl88X8LxAlaC741Co4mFhokJO1H5zDTC1A=; b=xl9OEmojaSHH+fvbT5f4vEGekjANJbO/Jo8Kd0XTLiBsrwD+QGYb04DtiKZ9wet4Q/ /dbEo0JcGP9jr5nChQHx9V/EhpAgAUfOJ7boWo1yBlpB3WZK7hu2tR1lY+IivcZyojcF eZl/ChqVwUVP1xzRCqXQ3kTpeta2Gy2/1BDAukPDC3lfUN6JOKineEb9pNJ2v4Ypbjcw uvIBc5UGBod1cKrS2DHg9WLzTcKYHfhf4Oy5D803OzBBOv9/kGQB/92lYAAts26LAUPI 7cLXfGBmHvdAjEI97mbSv7Y6bHiylXhpTxLDBMFw4NU3yOoHP7XI30UVTQ7m8NpJkqJA qJgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="zo+zvy/e"; 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=REJECT sp=REJECT 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 e16-20020a02a510000000b003e97c378d44si18441182jam.99.2023.03.09.07.04.23; Thu, 09 Mar 2023 07:04:54 -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="zo+zvy/e"; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232174AbjCIOxJ (ORCPT + 99 others); Thu, 9 Mar 2023 09:53:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbjCIOw3 (ORCPT ); Thu, 9 Mar 2023 09:52:29 -0500 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A119E6802 for ; Thu, 9 Mar 2023 06:50:36 -0800 (PST) Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-1767a208b30so2560089fac.2 for ; Thu, 09 Mar 2023 06:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373435; 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=Axm/mEYsFxl88X8LxAlaC741Co4mFhokJO1H5zDTC1A=; b=zo+zvy/eR8rvYN8U6vA3WCW/8G9ZTGoFt5OdaQAB9KYAZ9u/MvpCyv5YYaqs24IMCu X21Y02MemMy4MF+VLA+cQaMZ7eS2QiVudFZCuOS6vGvril8CAIvEYNsPP6deN0vX7V6r RSciDtkWMHtNYqErgjAZfxhHBKvzBtj/nnBpy/1DTfCQNdTIz9YyU3BEr15KXsyi01VG FE4HqlZQ92gfKYN3DQCN9jbVBiKhCEz9yl1Hw+fVDISOnZoqirwSXf92ftkDUVRxD/NU NUcg9/fN7G47/LrDZqmwZQ7Z18HEye8KasvSS9sGi9k9dU9KxAjgmDZXkdZ/yB3AXOaX PFfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373435; 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=Axm/mEYsFxl88X8LxAlaC741Co4mFhokJO1H5zDTC1A=; b=SxiNVYebA+i/7ubu+jCQKaP5eKPIPlUldVkHcU+pBlbBjNZIdUZOEmIXxABm3B5/wd J8jC12IG6ohfDV2CUP9hL68mkehg04dCjq+vSrz1lgpOb5Yb4KrLm/gvQabfBpJl653w gqa3oaxPPS8roz5QVCDHHcrtECdhMCEFq7H8qBtB5Y4x/hbkk5SYcCROO7nXC9Qkf3Yu qrxsIdXLTqbADGWQ72UKavpiObW0lm7L99x9hyvtsf8g7dyq7Gsf2/SZL83Hw3Rxaq/x mLIAMWnp781w1Ku0sJsTqsTD1U4f1Ogsxsom+LxvYfkIrSCigHz6Z0vzfR+BmDHV/yHb bd/Q== X-Gm-Message-State: AO0yUKU7rXs6hgftn3yWr1gPNaG4mpYYZM9OM6Z7u48UE9IpyaeuHmxM eQkWM2zrtulTY0twqcD5rJkGKQ== X-Received: by 2002:a05:6870:82a9:b0:16e:223b:1922 with SMTP id q41-20020a05687082a900b0016e223b1922mr12985082oae.15.1678373435231; Thu, 09 Mar 2023 06:50:35 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:50:34 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:49:58 +0100 Subject: [PATCH net v2 2/8] mptcp: refactor passive socket initialization MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-2-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org, Christoph Paasch X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5101; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=ver9M0p/LeGtx9UIbzbhioiM0gxqrJ/KIvxjL/g/J6o=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhsDZDaZWYi9As+hGXqc0WzNSDKUQxICz2p zrcih1ESUyJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg c26aEAC81nEv5iyWLUuzRiz/oUj3dHjVdWTC1E8hH1V2CTPFJD/UDFToSGq2AVanRXd0A5srCnd HyQWhITDG79fuYoT2qFjqm+xC5UT1Arm0fM+jjYbjBJZMumtv39X86LSo/sDRKCg0zR4THjVpgV pp1zotcEPYVM/1XT34wmldimJPe4NxhoDLwtU/aq9qeJoW20b83bGv8Kdo4IkyCb89vRTxBQwct /ikV4zkt+RFEHRo1B2Ym2yNm4iSv/t/FVnGn6hjxTN8OkPLYFOAuZ2+XIDU5pdgrh8i6hBsI+Ea BJSyN8iB7VN5AhtfJ0g5GaJiJe0Pc2T2BV/iKwlXoqy1qme7PZk6wkH+BQLeBDzVWOe8LSP5gtQ pDpZky1PGmrYp1L06F/VYf+TMOdRr0Cr/vavBjLHGpsdjTyS9DABle+va1pn0ktKSHvoK7a6kZk Vod9KzV47JlJOGtmwo2NIq7xXBjXwbFgtP31kpsRSsLghUI6VukVURRYi88FQWHOU90m1x1pLez Fpfc8v35Nmm4+nUwqdAVq1MTeHf3ZHMKoHFvVo6ZW2EPmdzF4lIMmzGVhBFLiEzwBF67QmJr+PJ 8ZwRGeas1QOJ5KIhpwo6upYn0YZDsw3Q7FTTiqPslTnGh84ST1OP1qTh2BTjlhhZc6Gv7u88hTj HlCBtB80Et7RP5w== 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?1759903004544779613?= X-GMAIL-MSGID: =?utf-8?q?1759903004544779613?= From: Paolo Abeni After commit 30e51b923e43 ("mptcp: fix unreleased socket in accept queue") unaccepted msk sockets go throu complete shutdown, we don't need anymore to delay inserting the first subflow into the subflow lists. The reference counting deserve some extra care, as __mptcp_close() is unaware of the request socket linkage to the first subflow. Please note that this is more a refactoring than a fix but because this modification is needed to include other corrections, see the following commits. Then a Fixes tag has been added here to help the stable team. Fixes: 30e51b923e43 ("mptcp: fix unreleased socket in accept queue") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Tested-by: Christoph Paasch Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 17 ----------------- net/mptcp/subflow.c | 27 +++++++++++++++++++++------ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 3ad9c46202fc..447641d34c2c 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -825,7 +825,6 @@ static bool __mptcp_finish_join(struct mptcp_sock *msk, struct sock *ssk) if (sk->sk_socket && !ssk->sk_socket) mptcp_sock_graft(ssk, sk->sk_socket); - mptcp_propagate_sndbuf((struct sock *)msk, ssk); mptcp_sockopt_sync_locked(msk, ssk); return true; } @@ -3708,22 +3707,6 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, lock_sock(newsk); - /* PM/worker can now acquire the first subflow socket - * lock without racing with listener queue cleanup, - * we can notify it, if needed. - * - * Even if remote has reset the initial subflow by now - * the refcnt is still at least one. - */ - subflow = mptcp_subflow_ctx(msk->first); - list_add(&subflow->node, &msk->conn_list); - sock_hold(msk->first); - if (mptcp_is_fully_established(newsk)) - mptcp_pm_fully_established(msk, msk->first, GFP_KERNEL); - - mptcp_rcv_space_init(msk, msk->first); - mptcp_propagate_sndbuf(newsk, msk->first); - /* set ssk->sk_socket of accept()ed flows to mptcp socket. * This is needed so NOSPACE flag can be set from tcp stack. */ diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 5070dc33675d..a631a5e6fc7b 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -397,6 +397,12 @@ void mptcp_subflow_reset(struct sock *ssk) struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); struct sock *sk = subflow->conn; + /* mptcp_mp_fail_no_response() can reach here on an already closed + * socket + */ + if (ssk->sk_state == TCP_CLOSE) + return; + /* must hold: tcp_done() could drop last reference on parent */ sock_hold(sk); @@ -750,6 +756,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, struct mptcp_options_received mp_opt; bool fallback, fallback_is_fatal; struct sock *new_msk = NULL; + struct mptcp_sock *owner; struct sock *child; pr_debug("listener=%p, req=%p, conn=%p", listener, req, listener->conn); @@ -824,6 +831,8 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, ctx->setsockopt_seq = listener->setsockopt_seq; if (ctx->mp_capable) { + owner = mptcp_sk(new_msk); + /* this can't race with mptcp_close(), as the msk is * not yet exposted to user-space */ @@ -832,14 +841,14 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, /* record the newly created socket as the first msk * subflow, but don't link it yet into conn_list */ - WRITE_ONCE(mptcp_sk(new_msk)->first, child); + WRITE_ONCE(owner->first, child); /* new mpc subflow takes ownership of the newly * created mptcp socket */ mptcp_sk(new_msk)->setsockopt_seq = ctx->setsockopt_seq; - mptcp_pm_new_connection(mptcp_sk(new_msk), child, 1); - mptcp_token_accept(subflow_req, mptcp_sk(new_msk)); + mptcp_pm_new_connection(owner, child, 1); + mptcp_token_accept(subflow_req, owner); ctx->conn = new_msk; new_msk = NULL; @@ -847,15 +856,21 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, * uses the correct data */ mptcp_copy_inaddrs(ctx->conn, child); + mptcp_propagate_sndbuf(ctx->conn, child); + + mptcp_rcv_space_init(owner, child); + list_add(&ctx->node, &owner->conn_list); + sock_hold(child); /* with OoO packets we can reach here without ingress * mpc option */ - if (mp_opt.suboptions & OPTION_MPTCP_MPC_ACK) + if (mp_opt.suboptions & OPTION_MPTCP_MPC_ACK) { mptcp_subflow_fully_established(ctx, &mp_opt); + mptcp_pm_fully_established(owner, child, GFP_ATOMIC); + ctx->pm_notified = 1; + } } else if (ctx->mp_join) { - struct mptcp_sock *owner; - owner = subflow_req->msk; if (!owner) { subflow_add_reset_reason(skb, MPTCP_RST_EPROHIBIT); From patchwork Thu Mar 9 14:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp341211wrd; Thu, 9 Mar 2023 07:07:30 -0800 (PST) X-Google-Smtp-Source: AK7set9iuMixSvCt4UBFSpEyyyWT11aSYAcVt9x5QH0vNRtKyoJ2CS8eLVjjWH0m8Do1Xyp955Bt X-Received: by 2002:a6b:dd07:0:b0:74c:c120:10db with SMTP id f7-20020a6bdd07000000b0074cc12010dbmr12039246ioc.4.1678374450063; Thu, 09 Mar 2023 07:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374450; cv=none; d=google.com; s=arc-20160816; b=D80x84zEk69Kpi8S4KJ+vh5gjh6D/wxBLHiV5LZw7YmqDLpGpN4P9pxtLlowYF5bgl bjksEKbNQIxImOd1bfeb57IoS1T/5F6+hVFIKMcuSmyzKkDjcpaBtFcsaETs66Cm3yE4 vUR1GXp2m3LmaTPhtuSBqVBqznbrenlz9HrraCVo3Ag9PaJ6jEMXOCUN9M+UiV56PUcE 9U/mf8i0p94F2tkZuSKkAf834ovmEaG9+f3rJBrXyB9+/EyXtKgroVbm5OqU0TINuZKO t028J7i2WsgtpSfD+14U9dHWK82UsKDTJBV90Q5lZ1U+4pBGpgmnRtcGbEZdxYCslwOx BugQ== 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=KCav8n7jkp43mQRU7lpslVP05Xar/ItVmiODndOYZMw=; b=vavIIWwyY+PSCEQfmcl2sXEEoV9mws8UbSAUc1qqIRfX6VkoGIxURiaTYn/uEI3jvN YSLsayeQxDEktbQ5eUzRc4z9AnUVWPs+rO0z3R0Bi2v/uRbcN9ZDVvFqPsfB/hqPU2VM KOroGc91oSApC5AtvM8iFpsFMlYy/VAtsVm0GKvatYJwkV4r4BX7jqNeBROQ+Quw5lIS Hy7qf8jfhA6eMqivN+7Zs9DgSewZi0TUSK8wiQvemuL2sPCAAnYCfRkCLtD+RgHxnVLr +KGJByjn+rBO8in6eCBTGwbPq+aryBrk9JGUex6AcmohMY9Il7Jqmp+e/bAeC7lT3vwt PZnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=WSI3vNjz; 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=REJECT sp=REJECT 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 m8-20020a5e8d08000000b007161e18e5fesi19133689ioj.94.2023.03.09.07.07.14; Thu, 09 Mar 2023 07:07:30 -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=WSI3vNjz; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231938AbjCIOxW (ORCPT + 99 others); Thu, 9 Mar 2023 09:53:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbjCIOwj (ORCPT ); Thu, 9 Mar 2023 09:52:39 -0500 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD2E5DBB56 for ; Thu, 9 Mar 2023 06:50:44 -0800 (PST) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1763e201bb4so2565328fac.1 for ; Thu, 09 Mar 2023 06:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373444; 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=KCav8n7jkp43mQRU7lpslVP05Xar/ItVmiODndOYZMw=; b=WSI3vNjzQG2b936rSfurigaEkD4Ad1gTjcobR8M6aclMPpBQjEFlZLjUyIyTT90moP b2zL4AT5jsljFAiU7mdJEK1XzGTgRhS9i28I4ioSqiB077DJqZA79om209/MIGV6Ayzd GIUCGnswiObcgVIzbFyqv5Jj18/dyff13TNiwHlD8ddxv0/lNoCtLtfzTCDI1qg+Dz+E pFL6QTXAujPVrRcdE9SP6MHp5YCuXiCfI4JzVcYNvEfdB24QiS7L2Jwhs0SUldK9m+dg JKC6QzXCmIACzfEZ2W5g1hWYt++aIuUlhOB55r7GlOUCHLugJr1K9VOqFlj/Yg57rG4I LQVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373444; 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=KCav8n7jkp43mQRU7lpslVP05Xar/ItVmiODndOYZMw=; b=s73C4r9ATTFs77ohU84lD/BzS9wrr3b93bBaihIqxR7MvodJkOgyjQB+2wArNKPqEG pNtvaLqUPV302FCKhwKuZEkuavhSGkp8tStgVfiwQNiO/acanSJjOS8QYtksBKEeW+C7 fJxR9iHlbhJQWAdPhmKRcYGQTVUlLD6FyhnzsqtkTH5LUdOXyT0qfSGVZNLSUkeD5mgK 0peAO2UwO5C0Pik9hqQ6QS19oLkJ/nXbxqRx0AGsZctrS5kWHQEQe7K+J/4dwD5XZvJe ikWqvk1C3xeu9z6PIXSAIx0REFgd5aFrv5aHK79RcvFEws+1rC7o7tka/7rjBaQOgZJP GoVQ== X-Gm-Message-State: AO0yUKXavGANwmsdlbZWuEGkascaiZcs/B3l+hNSqbhXcvgE13nX56Cz FYjSYdd8mbFddzc5xjvsboky+g== X-Received: by 2002:a05:6870:c14c:b0:16e:86ec:581c with SMTP id g12-20020a056870c14c00b0016e86ec581cmr13811494oad.58.1678373443360; Thu, 09 Mar 2023 06:50:43 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:50:43 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:49:59 +0100 Subject: [PATCH net v2 3/8] mptcp: use the workqueue to destroy unaccepted sockets MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-3-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org, Christoph Paasch X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=9213; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=Ox33y+imkgkIsAvT8c5rK/ze9qxNE1B+VCk2y577suc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhCbRLd+ujCCwY2vTvOgHq4M/4hLhfRy7Ig IBvurLGtMSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg c8s3D/wN0eZt/4ktj1E1sDswK0h7c0Vquk7Yvp+BwZehetzoB9Fl75HkscxSX/+ip/mtW5r3OKC B0XYYD0bEtAdtTu6DEC5Rf6d04sGV5JmSOVKR9+duBU/fivOX38YAz7dvKfh37EolO16HiXlkgv ZDRNncToBI7BBa/0tJWt5/nEUX4CSNBGxsz1951YObv+0RJtJWu8BtIzsXoGdvJSuoDatq/lbV7 Wx2uql8GbY5wtj3YEfyhjACi6FuOFsN/sZa0ueaufjCYwDsj7kHE1rTag7iN7ajo70HevHxBf6I w/HIZ0RRucqwqosg/wD43s4nBGV1bnwLi1Oevdzl3/eAgzpDCbx3ZFXJrsnDdRTDNvzIqsLFaZk nTyTDD4+Sq7rL31hyahW5QNS+9XtndH8qcSYekFoKLh3YuH381BP8+wQt7OeuEb6uaBGtkCf1qo c3K1SGJV2NysT8VSOjtNs5ZNwpusd+QM49upV2+9Gwf7/6jx4ISrTYu/ttMA0y8s5R69S8M6Uvv iV4rz/3QGfEMcRs0PK+kL7ugHtThPZkyqN1gDWgU1VAwjaDOfmcXQVh1suwOAOjvK9SvlCa1uyy MEtoOYt16pIXQ4NA+AS3oosoS6iHwlz41GFk60ZZX/XEH6wH7K4sEQCtJLcNQwgzaZMfteJqay7 u1YXaivLkEw0PBA== 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?1759903167297425371?= X-GMAIL-MSGID: =?utf-8?q?1759903167297425371?= From: Paolo Abeni Christoph reported a UaF at token lookup time after having refactored the passive socket initialization part: BUG: KASAN: use-after-free in __token_bucket_busy+0x253/0x260 Read of size 4 at addr ffff88810698d5b0 by task syz-executor653/3198 CPU: 1 PID: 3198 Comm: syz-executor653 Not tainted 6.2.0-rc59af4eaa31c1f6c00c8f1e448ed99a45c66340dd5 #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack_lvl+0x6e/0x91 print_report+0x16a/0x46f kasan_report+0xad/0x130 __token_bucket_busy+0x253/0x260 mptcp_token_new_connect+0x13d/0x490 mptcp_connect+0x4ed/0x860 __inet_stream_connect+0x80e/0xd90 tcp_sendmsg_fastopen+0x3ce/0x710 mptcp_sendmsg+0xff1/0x1a20 inet_sendmsg+0x11d/0x140 __sys_sendto+0x405/0x490 __x64_sys_sendto+0xdc/0x1b0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc We need to properly clean-up all the paired MPTCP-level resources and be sure to release the msk last, even when the unaccepted subflow is destroyed by the TCP internals via inet_child_forget(). We can re-use the existing MPTCP_WORK_CLOSE_SUBFLOW infra, explicitly checking that for the critical scenario: the closed subflow is the MPC one, the msk is not accepted and eventually going through full cleanup. With such change, __mptcp_destroy_sock() is always called on msk sockets, even on accepted ones. We don't need anymore to transiently drop one sk reference at msk clone time. Please note this commit depends on the parent one: mptcp: refactor passive socket initialization Fixes: 58b09919626b ("mptcp: create msk early") Cc: stable@vger.kernel.org Reported-and-tested-by: Christoph Paasch Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/347 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 40 ++++++++++++++++++++++++++++++---------- net/mptcp/protocol.h | 5 ++++- net/mptcp/subflow.c | 17 ++++++++++++----- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 447641d34c2c..2a2093d61835 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2342,7 +2342,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, goto out; } - sock_orphan(ssk); subflow->disposable = 1; /* if ssk hit tcp_done(), tcp_cleanup_ulp() cleared the related ops @@ -2350,7 +2349,20 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, * reference owned by msk; */ if (!inet_csk(ssk)->icsk_ulp_ops) { + WARN_ON_ONCE(!sock_flag(ssk, SOCK_DEAD)); kfree_rcu(subflow, rcu); + } else if (msk->in_accept_queue && msk->first == ssk) { + /* if the first subflow moved to a close state, e.g. due to + * incoming reset and we reach here before inet_child_forget() + * the TCP stack could later try to close it via + * inet_csk_listen_stop(), or deliver it to the user space via + * accept(). + * We can't delete the subflow - or risk a double free - nor let + * the msk survive - or will be leaked in the non accept scenario: + * fallback and let TCP cope with the subflow cleanup. + */ + WARN_ON_ONCE(sock_flag(ssk, SOCK_DEAD)); + mptcp_subflow_drop_ctx(ssk); } else { /* otherwise tcp will dispose of the ssk and subflow ctx */ if (ssk->sk_state == TCP_LISTEN) { @@ -2398,9 +2410,10 @@ static unsigned int mptcp_sync_mss(struct sock *sk, u32 pmtu) return 0; } -static void __mptcp_close_subflow(struct mptcp_sock *msk) +static void __mptcp_close_subflow(struct sock *sk) { struct mptcp_subflow_context *subflow, *tmp; + struct mptcp_sock *msk = mptcp_sk(sk); might_sleep(); @@ -2414,7 +2427,15 @@ static void __mptcp_close_subflow(struct mptcp_sock *msk) if (!skb_queue_empty_lockless(&ssk->sk_receive_queue)) continue; - mptcp_close_ssk((struct sock *)msk, ssk, subflow); + mptcp_close_ssk(sk, ssk, subflow); + } + + /* if the MPC subflow has been closed before the msk is accepted, + * msk will never be accept-ed, close it now + */ + if (!msk->first && msk->in_accept_queue) { + sock_set_flag(sk, SOCK_DEAD); + inet_sk_state_store(sk, TCP_CLOSE); } } @@ -2623,6 +2644,9 @@ static void mptcp_worker(struct work_struct *work) __mptcp_check_send_data_fin(sk); mptcp_check_data_fin(sk); + if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) + __mptcp_close_subflow(sk); + /* There is no point in keeping around an orphaned sk timedout or * closed, but we need the msk around to reply to incoming DATA_FIN, * even if it is orphaned and in FIN_WAIT2 state @@ -2638,9 +2662,6 @@ static void mptcp_worker(struct work_struct *work) } } - if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) - __mptcp_close_subflow(msk); - if (test_and_clear_bit(MPTCP_WORK_RTX, &msk->flags)) __mptcp_retrans(sk); @@ -3078,6 +3099,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->local_key = subflow_req->local_key; msk->token = subflow_req->token; msk->subflow = NULL; + msk->in_accept_queue = 1; WRITE_ONCE(msk->fully_established, false); if (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD) WRITE_ONCE(msk->csum_enabled, true); @@ -3095,8 +3117,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, security_inet_csk_clone(nsk, req); bh_unlock_sock(nsk); - /* keep a single reference */ - __sock_put(nsk); + /* note: the newly allocated socket refcount is 2 now */ return nsk; } @@ -3152,8 +3173,6 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err, goto out; } - /* acquire the 2nd reference for the owning socket */ - sock_hold(new_mptcp_sock); newsk = new_mptcp_sock; MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEPASSIVEACK); } else { @@ -3704,6 +3723,7 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, struct sock *newsk = newsock->sk; set_bit(SOCK_CUSTOM_SOCKOPT, &newsock->flags); + msk->in_accept_queue = 0; lock_sock(newsk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 61fd8eabfca2..3a2db1b862dd 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -295,7 +295,8 @@ struct mptcp_sock { u8 recvmsg_inq:1, cork:1, nodelay:1, - fastopening:1; + fastopening:1, + in_accept_queue:1; int connect_flags; struct work_struct work; struct sk_buff *ooo_last_skb; @@ -666,6 +667,8 @@ void mptcp_subflow_set_active(struct mptcp_subflow_context *subflow); bool mptcp_subflow_active(struct mptcp_subflow_context *subflow); +void mptcp_subflow_drop_ctx(struct sock *ssk); + static inline void mptcp_subflow_tcp_fallback(struct sock *sk, struct mptcp_subflow_context *ctx) { diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index a631a5e6fc7b..932a3e0eb22d 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -699,9 +699,10 @@ static bool subflow_hmac_valid(const struct request_sock *req, static void mptcp_force_close(struct sock *sk) { - /* the msk is not yet exposed to user-space */ + /* the msk is not yet exposed to user-space, and refcount is 2 */ inet_sk_state_store(sk, TCP_CLOSE); sk_common_release(sk); + sock_put(sk); } static void subflow_ulp_fallback(struct sock *sk, @@ -717,7 +718,7 @@ static void subflow_ulp_fallback(struct sock *sk, mptcp_subflow_ops_undo_override(sk); } -static void subflow_drop_ctx(struct sock *ssk) +void mptcp_subflow_drop_ctx(struct sock *ssk) { struct mptcp_subflow_context *ctx = mptcp_subflow_ctx(ssk); @@ -823,7 +824,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, if (new_msk) mptcp_copy_inaddrs(new_msk, child); - subflow_drop_ctx(child); + mptcp_subflow_drop_ctx(child); goto out; } @@ -914,7 +915,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, return child; dispose_child: - subflow_drop_ctx(child); + mptcp_subflow_drop_ctx(child); tcp_rsk(req)->drop_req = true; inet_csk_prepare_for_destroy_sock(child); tcp_done(child); @@ -1866,7 +1867,6 @@ void mptcp_subflow_queue_clean(struct sock *listener_sk, struct sock *listener_s struct sock *sk = (struct sock *)msk; bool do_cancel_work; - sock_hold(sk); lock_sock_nested(sk, SINGLE_DEPTH_NESTING); next = msk->dl_next; msk->first = NULL; @@ -1954,6 +1954,13 @@ static void subflow_ulp_release(struct sock *ssk) * when the subflow is still unaccepted */ release = ctx->disposable || list_empty(&ctx->node); + + /* inet_child_forget() does not call sk_state_change(), + * explicitly trigger the socket close machinery + */ + if (!release && !test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, + &mptcp_sk(sk)->flags)) + mptcp_schedule_work(sk); sock_put(sk); } From patchwork Thu Mar 9 14:50:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66920 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp342248wrd; Thu, 9 Mar 2023 07:08:58 -0800 (PST) X-Google-Smtp-Source: AK7set9c2JFmKVxdPI+hiBS24GvrJJpnaewEQRrJ4jiwjWlTguwGriYcMjXOSfJ5ncIBd/IXGYWz X-Received: by 2002:a05:6e02:1a03:b0:31f:ba63:382 with SMTP id s3-20020a056e021a0300b0031fba630382mr12433139ild.30.1678374537975; Thu, 09 Mar 2023 07:08:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374537; cv=none; d=google.com; s=arc-20160816; b=Th7Z82syyTTR6M7mRwpknasBKSP5oBjI0btXsV3D5fxXjW43SakbwhDU0ApjkUs39S +FdF/11om40aA7dfXtupDQTS70xcYAW5x6y0KSLZwlVns4maBd6p0HtC74sKhgnwm9Uu W13RLQzXFXy1MZjTQ0rNTk9nXiKR6R17dWIwd0GURop9h60HoR6YFooIWYCpoMv4C7Q2 mctzNosaTsA1AzZmGiPnmG0gcccKqjVkLSioro0HbjMzdk04+grnOJwK9nNcpRSH0Oyr 71rz44/NTr7fWJE1fd7Rojg/ZhFWUr5Uh0jrL1OPodfein9pW5uepQxw16PR45AyO4pn SEbg== 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=DxqskVtJzbIDGhzu4xtaacI8mLtuQFfHH0D65SJmQ6Q=; b=N0PqHI9ix03uNCKm/4/YnrZQBmH5NBFVGssFrbb1Zye8J6x+OfUGTnnRTWjgELUnst u8tEdk/j5haMnmIVJtHjqykLyM2NMyne4d6qPbxvDz1/T91r7ToewNL2ovSw2hqHfvMN f8A4TqoLhC2uFyLvT8Ulj/8xcGRlECWEkp6ucoDJafHgiu+GCXhc/HDi0hbHP7EsGfqr dbBlTqgxZU7UCwJi4WKWwaKiYOi1Oin7QVBXCVEyY5B+IlOCzuuvN9qrGUh332YD9vVa dM/qxltjX5Q/Mi/yfMN5s3qpPu8kE4Yjok+wOo01ty8pO515ka9f583Z0Wlq9jidctkS GwmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=pArBNs6h; 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=REJECT sp=REJECT 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 j26-20020a02cc7a000000b003a7cd893e91si18983520jaq.135.2023.03.09.07.08.43; Thu, 09 Mar 2023 07:08:57 -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=pArBNs6h; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231902AbjCIOxq (ORCPT + 99 others); Thu, 9 Mar 2023 09:53:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232047AbjCIOwo (ORCPT ); Thu, 9 Mar 2023 09:52:44 -0500 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A84CEBAD1 for ; Thu, 9 Mar 2023 06:50:54 -0800 (PST) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-17638494edbso2509193fac.10 for ; Thu, 09 Mar 2023 06:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373453; 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=DxqskVtJzbIDGhzu4xtaacI8mLtuQFfHH0D65SJmQ6Q=; b=pArBNs6h4QTYazYH+8c9+6JnBPZgnyIhg1ZSIqF04ep0j9xmjSIoSjc36Qycsn5EpL 2ttfrlU7mmksQomKTjSLcyRClbUvjmXgHETuIazaTfi/JQDPl1JxPSYrXaWNYMkOzW4B eFAoSt41BqwV9Mbyz7Y+nDtpGL+lQxTOkAr8tJtMqy8NfOaBA4uKMx+An4ijxzYBDs6C tg4EC7scAn/SzfY/9oEVCIAwDG7Nwun39g3dJ7/zS2RUDLE6yRwKBorfyFBG9l8zvT9r 2O/y45kQzGOX4YCUdtAPgMz2hfN9r9g/XXr1Zrub1YcsC9Ii3SBrVa1TT8tu+Omfqnsq uT2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373453; 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=DxqskVtJzbIDGhzu4xtaacI8mLtuQFfHH0D65SJmQ6Q=; b=Ij1f1n318h78H+8pDT0J3gsj0FDZ3MBYtHyvmE1g7IKSpjejXz0KKhq5Qj+NUrMV/p qgnjLqs8HS0OP/Z5vWlVu9p5R6uLETX7B1TQaA1CZO4WYubSsaKwF69mEkePTJ9CZacs i22nBeBGtpQ1OeC/NLBpRf702QajFkU7Hgrj/SnV2Skt/S2aR5MdM8C7jBn5Y/01XH7g NHKFjtTM2m6wM0dTWxs/6+WSqBOVCTMG/NafExE9b33noPxAokaeZfIcuIoyDuIdlueJ WW9JPr9DzALRxUC4ccP9vu5Iitjj4vWFLVs1+p9kaNlaMVuoiCSJwXvo0h1XAPDl6oTp gMOw== X-Gm-Message-State: AO0yUKXtuzEsWrZLgESHF8Mn/L6UxAhzBH23P0PtzgUki8j1XjQdlX6X n5J32JtJtkk/AatMZSblJKdlow== X-Received: by 2002:a05:6870:5703:b0:172:7220:a9eb with SMTP id k3-20020a056870570300b001727220a9ebmr12734986oap.8.1678373451935; Thu, 09 Mar 2023 06:50:51 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:50:51 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:50:00 +0100 Subject: [PATCH net v2 4/8] mptcp: fix UaF in listener shutdown MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-4-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org, Christoph Paasch X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=6328; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=TJIewReJ/yOGpWt8keCbB5zXjaxYZOxSV1Zl9q3p0x0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhBXsVeZCD4caj3mT+fPvYXxeBAkoAALrYI VKKDez3LnaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg c434D/4ikPybhwE5pZT5G2x9W5cfhIZMvjQZCPWoFP/zVpZzEwfsvhO9MrQJWFYQp7MvVYoAQTb eaRCqSZ+A2wTz5lTrEncsw8gy9/HpkActlxZd+FDGQtzC62dOaSjfDrlorYTwRfSRlPNxTotccl mYqyZ4lypkVi33xZ4HjoJCEfrG9s7l6UYMB7tD8LW4Dpq2MmIxhO/YfWwTa+ZMhv8beOQLP2JdR wIk+4h/h6DP8amWByt6W0YwCjf9Uv5T2s1NdpQiB5oD/5KJVSeB0jWZeTi9Tx5aeuYP7YC1NrLK xL10fq7FUkBuYaxK/IrZCUx4Dtu02utlbIqdW9ikCiQ4PYqsyFsXqMxTEFklkg+MqqEnldZA6K0 5JtD+pvuxHnGxmZc0R8Dw5CXS/2k1fYWcRNcIabqA5LNnq/UNJctAYX6RUTkWMEXXANT6QzSMXc sbGfPwtdihdqt9qkJtCC1Y2BUlxPOwpvPM9p4EF0Y3roAfCMFTmC+wm5MqzXPYqL+ls19+/UsIs ziaYhAG2T4VNHjUVMRQSFHZtSaD+kMuBbFI06CQxvXmkD2XA6TamC7G5D1EMcZx/mOqz7x9oxFt YmJRKONECgBspQvh4DkBigKPENXh76Jc1jWQre0P1rK9udR/M17ZvDDbSr3o9N8a6h8LNnKfhqn 3bFby3ULhxVe1oQ== 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?1759903259523497889?= X-GMAIL-MSGID: =?utf-8?q?1759903259523497889?= From: Paolo Abeni As reported by Christoph after having refactored the passive socket initialization, the mptcp listener shutdown path is prone to an UaF issue. BUG: KASAN: use-after-free in _raw_spin_lock_bh+0x73/0xe0 Write of size 4 at addr ffff88810cb23098 by task syz-executor731/1266 CPU: 1 PID: 1266 Comm: syz-executor731 Not tainted 6.2.0-rc59af4eaa31c1f6c00c8f1e448ed99a45c66340dd5 #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack_lvl+0x6e/0x91 print_report+0x16a/0x46f kasan_report+0xad/0x130 kasan_check_range+0x14a/0x1a0 _raw_spin_lock_bh+0x73/0xe0 subflow_error_report+0x6d/0x110 sk_error_report+0x3b/0x190 tcp_disconnect+0x138c/0x1aa0 inet_child_forget+0x6f/0x2e0 inet_csk_listen_stop+0x209/0x1060 __mptcp_close_ssk+0x52d/0x610 mptcp_destroy_common+0x165/0x640 mptcp_destroy+0x13/0x80 __mptcp_destroy_sock+0xe7/0x270 __mptcp_close+0x70e/0x9b0 mptcp_close+0x2b/0x150 inet_release+0xe9/0x1f0 __sock_release+0xd2/0x280 sock_close+0x15/0x20 __fput+0x252/0xa20 task_work_run+0x169/0x250 exit_to_user_mode_prepare+0x113/0x120 syscall_exit_to_user_mode+0x1d/0x40 do_syscall_64+0x48/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc The msk grace period can legitly expire in between the last reference count dropped in mptcp_subflow_queue_clean() and the later eventual access in inet_csk_listen_stop() After the previous patch we don't need anymore special-casing msk listener socket cleanup: the mptcp worker will process each of the unaccepted msk sockets. Just drop the now unnecessary code. Please note this commit depends on the two parent ones: mptcp: refactor passive socket initialization mptcp: use the workqueue to destroy unaccepted sockets Fixes: 6aeed9045071 ("mptcp: fix race on unaccepted mptcp sockets") Cc: stable@vger.kernel.org Reported-and-tested-by: Christoph Paasch Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/346 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 7 ++--- net/mptcp/protocol.h | 1 - net/mptcp/subflow.c | 72 ---------------------------------------------------- 3 files changed, 2 insertions(+), 78 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2a2093d61835..60b23b2716c4 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2365,12 +2365,9 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, mptcp_subflow_drop_ctx(ssk); } else { /* otherwise tcp will dispose of the ssk and subflow ctx */ - if (ssk->sk_state == TCP_LISTEN) { - tcp_set_state(ssk, TCP_CLOSE); - mptcp_subflow_queue_clean(sk, ssk); - inet_csk_listen_stop(ssk); + if (ssk->sk_state == TCP_LISTEN) mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CLOSED); - } + __tcp_close(ssk, 0); /* close acquired an extra ref */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3a2db1b862dd..339a6f072989 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -629,7 +629,6 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk, struct mptcp_subflow_context *subflow); void __mptcp_subflow_send_ack(struct sock *ssk); void mptcp_subflow_reset(struct sock *ssk); -void mptcp_subflow_queue_clean(struct sock *sk, struct sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 932a3e0eb22d..9c57575df84c 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1826,78 +1826,6 @@ static void subflow_state_change(struct sock *sk) } } -void mptcp_subflow_queue_clean(struct sock *listener_sk, struct sock *listener_ssk) -{ - struct request_sock_queue *queue = &inet_csk(listener_ssk)->icsk_accept_queue; - struct mptcp_sock *msk, *next, *head = NULL; - struct request_sock *req; - - /* build a list of all unaccepted mptcp sockets */ - spin_lock_bh(&queue->rskq_lock); - for (req = queue->rskq_accept_head; req; req = req->dl_next) { - struct mptcp_subflow_context *subflow; - struct sock *ssk = req->sk; - struct mptcp_sock *msk; - - if (!sk_is_mptcp(ssk)) - continue; - - subflow = mptcp_subflow_ctx(ssk); - if (!subflow || !subflow->conn) - continue; - - /* skip if already in list */ - msk = mptcp_sk(subflow->conn); - if (msk->dl_next || msk == head) - continue; - - msk->dl_next = head; - head = msk; - } - spin_unlock_bh(&queue->rskq_lock); - if (!head) - return; - - /* can't acquire the msk socket lock under the subflow one, - * or will cause ABBA deadlock - */ - release_sock(listener_ssk); - - for (msk = head; msk; msk = next) { - struct sock *sk = (struct sock *)msk; - bool do_cancel_work; - - lock_sock_nested(sk, SINGLE_DEPTH_NESTING); - next = msk->dl_next; - msk->first = NULL; - msk->dl_next = NULL; - - do_cancel_work = __mptcp_close(sk, 0); - release_sock(sk); - if (do_cancel_work) { - /* lockdep will report a false positive ABBA deadlock - * between cancel_work_sync and the listener socket. - * The involved locks belong to different sockets WRT - * the existing AB chain. - * Using a per socket key is problematic as key - * deregistration requires process context and must be - * performed at socket disposal time, in atomic - * context. - * Just tell lockdep to consider the listener socket - * released here. - */ - mutex_release(&listener_sk->sk_lock.dep_map, _RET_IP_); - mptcp_cancel_work(sk); - mutex_acquire(&listener_sk->sk_lock.dep_map, - SINGLE_DEPTH_NESTING, 0, _RET_IP_); - } - sock_put(sk); - } - - /* we are still under the listener msk socket lock */ - lock_sock_nested(listener_ssk, SINGLE_DEPTH_NESTING); -} - static int subflow_ulp_init(struct sock *sk) { struct inet_connection_sock *icsk = inet_csk(sk); From patchwork Thu Mar 9 14:50:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp335078wrd; Thu, 9 Mar 2023 06:59:45 -0800 (PST) X-Google-Smtp-Source: AK7set9vyXptmkbhF/c2j3VexZa+dT1HvgoBlj4n0k0vzoc3z+SXZcEMTcsEvJPkMcolC5NXJR7g X-Received: by 2002:a17:90a:16:b0:233:fdfd:711c with SMTP id 22-20020a17090a001600b00233fdfd711cmr22402566pja.33.1678373985299; Thu, 09 Mar 2023 06:59:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678373985; cv=none; d=google.com; s=arc-20160816; b=O7UhnI+zik9RAollO/hW8/nyKLqRkNKq1fQ4juCVyDr2KGD77w059VS/Murmf58Eeq Kn7bqJaa3YBCHzmOX8sFrxI9Z7PLtxF3J534IbEVh7xp44+M6L/KC+Z3A4MBhsh84pyZ 7F+Q4CSl61u3bH1VJfMy46MbpXaVLgR4m527faE1os8yidsp8P7zdIIdtrNUsmqNovHe Z0QPKUExLSvX26PotiOFFld8O6q4whX9cSnm7xB2ltLXzojn9du0mANBUe6DbnvVMuPR EslMfL4EUE0jIQcLFtdfz6rw8/pH3VdMnogosXHWu0UjJdADzflpY2FlbVhmPf99CY3j hc/g== 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=jgeAurw5MQ6tabjrQfM6Jio39u1LTtRrLhUhKbdYExw=; b=q+iRm8R/2UDl8g5hWj2NI7nEPTpBes2qgURq+1qH4wYTiekh5apxGojW8FK6FvaP80 thRkUF4Lj9PRP+yftQrocDGQ4I7Gn17rGppPP5k8UAsCDWdTMEz48woJ8fw4+T47IsFb E4zAEewKl6lWkFQCOGGRmo6tEBlI/c/g5fDXKTzzXClSkGRvCwDWeKIUXmUvhBA3rd3L MCs2d5lwX3Kcsrg+j/VoPCexG1JwepznZwxNn3SGkPphoTgHSx1i4XBSAM4HSV486lIt 5tTemT+YPjdDMQtY+EcWUkCIqOJXSbwq32XyVc39NC9CCVY7uyGVbA0jG7LhDRnAzAvH +NEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=Cg0nkh6N; 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=REJECT sp=REJECT 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 hk13-20020a17090b224d00b00230d1e278aasi74313pjb.41.2023.03.09.06.59.30; Thu, 09 Mar 2023 06:59:45 -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=Cg0nkh6N; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231981AbjCIOxw (ORCPT + 99 others); Thu, 9 Mar 2023 09:53:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbjCIOw4 (ORCPT ); Thu, 9 Mar 2023 09:52:56 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33674F0FC9 for ; Thu, 9 Mar 2023 06:51:04 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1755e639b65so2555065fac.3 for ; Thu, 09 Mar 2023 06:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373464; 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=jgeAurw5MQ6tabjrQfM6Jio39u1LTtRrLhUhKbdYExw=; b=Cg0nkh6N2mnjRz9oTVqPcSePKZ79I3DFoF4oYbVoCbQoneyBkvdhLSvDYAoWoj+ygm QUWczEK5ebPtwC2CpLRzNAM5BpXz6MDMkQ22ipB8a8cufp2P7GPp/SfzWbDp2hhgQ9lN O7hSOmFAtCpo1po6Am5b53KS2MU/Sno8zilT1TY1kTUwjC48l6kLME6HZ4NHy/WUU+YJ wyf/LHSilpyCnkBaY9L7hX0gWhCauTZyubwK1AJ2gDAHBLAjTWWr5PzytSQTzanr79CO eHrF/38A6oN4JvMCOZQjt2A+88k3w0gSQWZ65EECf5s+TxC3mubzRg+sAgOaSh9tMbZ4 DAgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373464; 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=jgeAurw5MQ6tabjrQfM6Jio39u1LTtRrLhUhKbdYExw=; b=T2R/2hrFxRqLXzFsYebSeeQ1wijlmcTPYqSA8FxPL6PEfH434HHQazg/gZb98EZli/ 6b39UAtdeZq7EW7IjQPW8A98LOqmB4W+nw2ITNSB3m/YZy+6uk1MMUHrpjbOUXd9L0bM 2HWRwX9e0Puxi9dah3IPqFTwQDhARQ99oKlhNaHo6y19HMG8GAE/GzP3GCBCo1iYrr8h lgrid8diNOcBzvFiLHYelOr3e0sDvN445PutLgMASRkRVxhPwMSzGebDP+ChCObYDc9S J1RlfBrg2DkfKZFGF/a+zNTcv/LmESV0Lg3oC/0M8ArqjpWFTLWFL0PFATmgAiErcCxg Vpvg== X-Gm-Message-State: AO0yUKWLvw1mjB6pevYTsQqSqjs/3dACUZCJE5wcCrL5grltVgchX/F6 wONR3YEIQ8A4X95AfJcOlVI8nQ== X-Received: by 2002:a05:6870:8090:b0:163:97bd:814d with SMTP id q16-20020a056870809000b0016397bd814dmr15161728oab.27.1678373461384; Thu, 09 Mar 2023 06:51:01 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:51:01 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:50:01 +0100 Subject: [PATCH net v2 5/8] selftests: mptcp: userspace pm: fix printed values MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-5-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org, Geliang Tang X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1019; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=mevXKVwguJYVDj5NKWsKg6dJCzPlEP7cAxuF4rctlYE=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhuwuqoRrEHcNzQiGfZqVb0x2N6M0XyYmps ACVicEN6GaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg c1d5D/9ElMBnE7hj2nLsVC/JHhBeGhtZgtA8SuE7YnP5mypX/lRaQU2u2LxrS41LX7WB2sC+r98 sZXYmpxByWVZuYaKxRLYah2t/cT4Payeo3YALz8YusFmFvTH+XjD83L3RF74Tdar2HLxZO/ltbh IOwUYL+Q5kK9SzgMGcs3iqHDgLIPxXua3VIaoISTBGFb/IVG5NrnePIjX9DHC540aFJhEzbTNmP u13iD4qiUk35/Hl0CmOiENKHCFKPXsX3sB+/FhMg7F4U1COL+lpZlI4kIJFn8V+jYWj2+uZQewy YcNYyj5nX2I2dN09nvqKFRavFdu4HQ/s5+l2dD2Z08Lo+FQhJs3YTBVYSENI+c/yv6+UHF5Gtl0 ujVKYf0QMQHl3biQesi7hQ3TKNH6ul7jflAKDBkhhMVsRnXnp/rCWTGKgKYc5MqWR4ZahAiasQA ERDILknXE8YWKXj0aoUoeYZusBm35XIeVHAQASkKUZi6XqC23I6RxHXQsWTyVfMf39Q8mvfxVct iVL4ZVpecMjlw9jYEEo60rbPeoPq7ns2KjXaF3mW/5sfp2434uVL8LoWAbKnGGVB2kiGZSij2Up WTCwCJJxWfc8wsY/2XNMT70Fll1AlS3UzIq1WzqXG+BFHQFwlJ88cGBzhLTNtUQkINroO0QvNSL Qi1YMRHJjDLp0Uw== 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?1759902679527012875?= X-GMAIL-MSGID: =?utf-8?q?1759902679527012875?= In case of errors, the printed message had the expected and the seen value inverted. This patch simply correct the order: first the expected value, then the one that has been seen. Fixes: 10d4273411be ("selftests: mptcp: userspace: print error details if any") Cc: stable@vger.kernel.org Acked-by: Geliang Tang Signed-off-by: Matthieu Baerts --- tools/testing/selftests/net/mptcp/userspace_pm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 66c5be25c13d..48e52f995a98 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -240,7 +240,7 @@ check_expected_one() fi stdbuf -o0 -e0 printf "\tExpected value for '%s': '%s', got '%s'.\n" \ - "${var}" "${!var}" "${!exp}" + "${var}" "${!exp}" "${!var}" return 1 } From patchwork Thu Mar 9 14:50:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp340118wrd; Thu, 9 Mar 2023 07:06:04 -0800 (PST) X-Google-Smtp-Source: AK7set84Bojeo6xOKEKza0HIgymiUI7OXuHZAAMolZT9HlCcqvmMDvb/yOfKbb/kt6BmmIzJkISr X-Received: by 2002:a05:6e02:1bea:b0:316:faae:ed1b with SMTP id y10-20020a056e021bea00b00316faaeed1bmr20195896ilv.16.1678374363790; Thu, 09 Mar 2023 07:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374363; cv=none; d=google.com; s=arc-20160816; b=CuvgOMCWaMaZaZ6XWRAgNR0o8tf+h0a4hKnQWwwQ5/7FudA3hg+qa3u8eQK7+D5cWm mgpIOxG6qv3U1Th9z9d1s8S0rGN0JGq8KGt5k1hJWXVHftOMwK5vdNugHPtaC/jKkeMj 1mgxhg2dOC5vko5ggnVuggFY91YVFMvtz0m2aTXVAJT8jvPQpmENYPtxcWGu8IcuqdZs T4LBJ7wz/ojMgDEJba2pKfqWJr0Avh/woMMytn+hKk3IVddw2/zemS4DH5ftCWZbtQhc LhKDXTrnaFIF9+kQMu8024sglh8JOl303hb8aFQ1gZG5JdySCEPVOke5gGTQhG0+tvDu WFpQ== 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=7aVI4e2OdlOYVuMUfrd7oCECSdqBtHFzJOKgjTLxG8Y=; b=Qh/4VCe3M4MXVX3jxRx24cjuzvJB5q6iB3/j91J7BCTwwd/FMG+3wTc9argWV6tZgj 9fSmUtXlLQQSj3s2yiXmQ7zY97K3puMxIkhk7UTELXGE9PnB01wSvFkB/9t68DvQ8o+j gHkvX9cDTz+PUber55XptWOTZUMWJb55boBREnlYTtUtHwv/sOpphNmk/21iFzhVQFWB VzIyQmcbaF85VNUAtCgC8Uvw4FvkyHqRyKudAJdypCN/OPdlRS5AXwut+247qavLyj8R FRtpSXO70dWBDNwJ3EleTRW3T7LMSuk2YNfDHj0vNBS8TCixbM3V4ZBxSOeMZhxRP8Qu uwWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=tGsVthpr; 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=REJECT sp=REJECT 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 y12-20020a92090c000000b00316dc3afddcsi17872503ilg.50.2023.03.09.07.05.48; Thu, 09 Mar 2023 07:06:03 -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=tGsVthpr; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbjCIOyS (ORCPT + 99 others); Thu, 9 Mar 2023 09:54:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232161AbjCIOxF (ORCPT ); Thu, 9 Mar 2023 09:53:05 -0500 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01150F31F2 for ; Thu, 9 Mar 2023 06:51:12 -0800 (PST) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1767a208b30so2562159fac.2 for ; Thu, 09 Mar 2023 06:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373472; 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=7aVI4e2OdlOYVuMUfrd7oCECSdqBtHFzJOKgjTLxG8Y=; b=tGsVthprhw/reHeu0kXsKQ3G4aAujKF/o6r1dMxPdSzLo1GiCnsDQ0KP9zqhy4akt+ ukd3KSdcnCj5w52bz0EPCD3kMAKw5C3kJrMv5cwpujHZdeqj0rbb1f4oTlWaPgoie+Fi oqPWTGV7PEU+54huXmLOmPhHK9oZpLdrMFhz5v/1emVPZghgLVbJwEnmNuyF1WtChcS0 kfeqgsjC7b22IuH3T+k+40V+QXjkkeG0yKo+dMARhKjOqsRoGsUwOZwVSXLT1dk7xng0 HWI4UHtO28QAfPRmmLK0F28oPs0iOV1/3ETbHznFLB/PNBCR1vSv0sR6kYQmnLM54Ji0 j0qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373472; 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=7aVI4e2OdlOYVuMUfrd7oCECSdqBtHFzJOKgjTLxG8Y=; b=AkKiCuCo9qWjGd16bx+tXVaXLhtlXfwQKA5vjCjk5LOE21UwyLtZQ0ZwZYiJlGJ4Zj A2/LDGJa3uzeidsUhgDsWP3BYoifgiwpD0Zl3rWgqJcnZCHhABpzI4e/pU8f3SocH4we RTLYgZ4FO25aD/UjUW533d+X/FDFBpEWCvYxRIBk2bU1SPLQ7NLVqU/f4L8sIUd2SsaX OBUkDd7M/jTOAbP2KsO6BIBVEchsNIAe4FzIhqjzDc9VocSEEtOj5ZBQyeblTj39ImjT QQ34adAxihK33bKj7K79pzv1Eje5o4g7bIs3LQZyXg1RycmKRzo8NCJdFNYzpHKukkju bt1w== X-Gm-Message-State: AO0yUKVY97HEkgSxlWot55yoHArN4NbkQrJ43gcnq6PaGKUhalDpEZa7 0p1RZSHMpmldw+Gt+6hV9lY1ZQ== X-Received: by 2002:a05:6870:ac1e:b0:172:a40f:5ff7 with SMTP id kw30-20020a056870ac1e00b00172a40f5ff7mr13766983oab.15.1678373470400; Thu, 09 Mar 2023 06:51:10 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:51:10 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:50:02 +0100 Subject: [PATCH net v2 6/8] mptcp: add ro_after_init for tcp{,v6}_prot_override MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-6-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , Geliang Tang , stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1660; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=jwqxBRvOjpFpJeOhBbQNAMdCMsCRiyb+3+BlXnlrYos=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhvNkzCHxVtYQT3XvqIPehwKS4POj6L7ylM Oq6BtJKQB2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg c/zGEACqL6+KKaSjgkuLXw9CX+Naqdq9ZO96zwpEXD95zrKUK4O8JaHHSLNyzKq2NksdN2iRwhZ 7oj2fI8FvM8nguDeHJiGuVFewPfMJBtz+DW4sqf/+Sq4TUlZCMNwIpizXW153YGZL9JE5B5xqYs FFWqRTBMSRlVyubNDj6heuregejJ2Vwvf6voTRb83e67ueY9fGG8BPhVxl224aZcEK0Q7ToDRVp Utrkr7QFId9CYkRdXst2qrWcM/QsLbJJ21IwgXQuepgOB2tMtbYkAjpWfRieUuhTPCDrqw078+L hVg8gr6iFvBWecQUE6bQpqM20Tfpq2OxyYpHTzPBy2+Z3ZBsNeNlru/VBXHOyDbRk24z3XqWYXz MueoJdJ4o1rFgpLYgrYGsnTDX228EOkG0vKs8ZAaXSFZ5IPGX7shVBsH/IZ84fdhAMtivP/WAXI 6bkTzSB8sH0D9c/kQWd0CFwHPHBg/c75C9Jz+uGEUXjUJebvqaXEMgkA/lI9IGsCc+b9cn/55qw /HXEUy7bjKFRJKFuVtetgL8+hn9tANC0g4uF8DfInATFIch2IUGR6zgkMq5hiHOuT3um7qRkvm1 Q0WbH6u3/OdBAO8L+hMiKx+ALYG2iNcXBinxP4k47I8XBgux36FUMdargEBkINqaglBHHLeBSkC q1JUskp+9rIuAyQ== 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=ham 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?1759903077047373402?= X-GMAIL-MSGID: =?utf-8?q?1759903077047373402?= From: Geliang Tang Add __ro_after_init labels for the variables tcp_prot_override and tcpv6_prot_override, just like other variables adjacent to them, to indicate that they are initialised from the init hooks and no writes occur afterwards. Fixes: b19bc2945b40 ("mptcp: implement delegated actions") Cc: stable@vger.kernel.org Fixes: 51fa7f8ebf0e ("mptcp: mark ops structures as ro_after_init") Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/subflow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 9c57575df84c..2aadc8733369 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -628,7 +628,7 @@ static struct request_sock_ops mptcp_subflow_v6_request_sock_ops __ro_after_init static struct tcp_request_sock_ops subflow_request_sock_ipv6_ops __ro_after_init; static struct inet_connection_sock_af_ops subflow_v6_specific __ro_after_init; static struct inet_connection_sock_af_ops subflow_v6m_specific __ro_after_init; -static struct proto tcpv6_prot_override; +static struct proto tcpv6_prot_override __ro_after_init; static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb) { @@ -926,7 +926,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, } static struct inet_connection_sock_af_ops subflow_specific __ro_after_init; -static struct proto tcp_prot_override; +static struct proto tcp_prot_override __ro_after_init; enum mapping_status { MAPPING_OK, From patchwork Thu Mar 9 14:50:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp337887wrd; Thu, 9 Mar 2023 07:03:12 -0800 (PST) X-Google-Smtp-Source: AK7set+VfXtsXHyppHpzFIqzO/nPZ0wKbmTJCXii2dmB7PowrouruVRkRCy7LFb73x9j3auR5cAR X-Received: by 2002:a05:7500:6593:b0:f8:196e:9c55 with SMTP id iq19-20020a057500659300b000f8196e9c55mr369094gab.6.1678374192477; Thu, 09 Mar 2023 07:03:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374192; cv=none; d=google.com; s=arc-20160816; b=FZ0xGp3fAFnMRQKCIWMCd53Zhk0iNOZftyaUR9+N+bHjkqxk79LOiCWoJnucfr7BlO uZybraxEYzvZ2VWUTdJESsdr2pIZ4PyKkq602RGMm7+60BJH324hHP7M+xDir213MLty 5KDE2NZjYQiTiXvq9+2QG4P3KvfRRuGiWgj0+qU+ziit7JrDpG66ntWh7VUF3RaXBPB+ yT1gBq1KjZeg05RQ5lTlCiAg8XxTylXt6EatX+pRFKRQYaL7whxNqmRUvzNNJe4iMBTX 8J30jqqwuydjJ/Fvnv05U6tbQusqSFzlmSpDtdaiBhCvfIayJlwhcyjXu3Z1cJ1Utejn yEBA== 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=jzm/x7TOjLOgi7CwKs4YCZ1LBGnvx2xB9lo0ysTnYvA=; b=Z3UZcmwfGLOCHqSLkpKohvi5LnEBiSzvHeo/dWoXWR+e90+AuBS/+A9fFwat1NMuyX /RHNRmTUWZMDwQvkN2on/JuD6NGQy+XCq3LL0qiRyLk+B8cO5xGF1sUdISOAq+5DZwkg 1sl5KrnP7m5R0jmjviKNGdDbTcVIVpJQHQyoxfKTA5VwCizXcTT2yEdMyRP0vefA2mwo k9ff6GWD6rK4jPqWCUDZFlt2kJxGlXs1ZJcG0VhbiRi8HE68relHL/5wMSMX634AqoVC xfgldBIA4SCPwiLCTjNlXFy3JiK2fJ1XTxfByexLT7gwp0RXSrN/dC+djVycGnT6nJQ6 d39w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=H4PVIGDT; 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=REJECT sp=REJECT 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 m20-20020ab07094000000b00689c56aa914si5911999ual.195.2023.03.09.07.02.45; Thu, 09 Mar 2023 07:03:12 -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=H4PVIGDT; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231842AbjCIOyn (ORCPT + 99 others); Thu, 9 Mar 2023 09:54:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231769AbjCIOxo (ORCPT ); Thu, 9 Mar 2023 09:53:44 -0500 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20339F2FB4 for ; Thu, 9 Mar 2023 06:51:20 -0800 (PST) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-17711f56136so2499746fac.12 for ; Thu, 09 Mar 2023 06:51:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373479; 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=jzm/x7TOjLOgi7CwKs4YCZ1LBGnvx2xB9lo0ysTnYvA=; b=H4PVIGDTl6WnZIPkjc+EFidMIA/6sgQ8MLWYqnDcXuN8hA6Qfw54b0x9GKQmCs98R6 OVI2quuA1TxFEl6utPmQQ41Xik06vszzJ4jDmqkCQyWducURrSp6FHKyJ+d8aCBeDD7e WFnRNbfgRhHTpDKtFmaeMOF64z4wjvyfYKXFuvMBHnT+X//VITbr8y0e65CEvs1u4cbV Vae9aasikEPye6Moacpey80/g3Z1PmWsL4kjOjmt54pD5HewSgVMFDphEBt26OCG71Bp 5lKP4wnu6U6vj/ghMghMU0qvCuhwhRh+rJX3TRGGntswCK7rdtsFc8r1QaxMgzmMGe2m CPbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373479; 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=jzm/x7TOjLOgi7CwKs4YCZ1LBGnvx2xB9lo0ysTnYvA=; b=5ocvlnLsIoD7NlyXxf4eA5fdbkDdSOz/I1ugGDpHACx/r3+Wt6Nwwk6fHovtkDJEXb Xhx1cZZusp85cKm/6Kg0lh6WNgWl+lAKU7oLg/dH6SxSluWxDhXgzpwpV7zZ+glGRJI4 YDnnWjVVv3qTbfExHIf7YZz+MsT7EfsBwTrOKYV99mO6Gen7UciBGnUw+9p3VmZ7OLGi lcZHKlhXwbiwtm32S2ATlbxIcvqnzu4InHkdZUy6cVhPIsv1Co9rWwOMC6xKjogd0Hbs EBsurd7Zq3tEpGdtJGZ9rXvdUD23iixSBQhmKOvjwRw87prpKMblR4fElOdVXuXTaooZ dp0Q== X-Gm-Message-State: AO0yUKUUkT8VYABi6iAEgVY+L3TDwBKsTxV/MYR2i7jGdT7nekIz4QX6 omOf6OnFwJp6IQoYApG8qRrNJw== X-Received: by 2002:a05:6871:285:b0:172:45ff:6293 with SMTP id i5-20020a056871028500b0017245ff6293mr13952175oae.26.1678373478812; Thu, 09 Mar 2023 06:51:18 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:51:18 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:50:03 +0100 Subject: [PATCH net v2 7/8] mptcp: avoid setting TCP_CLOSE state twice MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-7-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal 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=963; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=YhQrvwLHpqWFuACAI0OELxustQ1PVT1SBUl80EUsJ68=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhVzi8yguOmSTvdyb8Fy2uvF6oIcbmQZxef 8MjZTpDu0OJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg cxQSEAC4h1EXetyTEuncZ+ZrvfqSoNohT6csTHKoNAOLWuSclc59xfJaNgQIAwPM7xwuUWM7W2U exMVLsI/GsR40waIDVGGUMRg5xCaLmv7KbImOzKLMLkKmRrWMxh91KMu40MCX28+AciHyVE0wfy hechXKwj8Y7kKHbbXUci4IzgwKQB0yHzMbBokX5cgdUdtsnLR2S5PPA3Vf8Aab9YuKYoUZG+aEz hxvIRyHAhH3sxN5tFr7+ulbbV6dCHORkjvVEpl2D4WYfNcmDnDzOdSFE4TgylW9TSed+5rSn+na SVZFWh1RG35f2lY4WMBxUC2RcEdtvchCEtyAh/ap2a083hgL+1mbzpcWBh5osPhXDXbhmWlcrIp BJaNNIANTekYvltIiNBs3hKyb0uefUG004sa7HZ0hSB+GZ8eEOp+NAYciFhicjK2sGRIb0Pp4ZE XG9laaTdW56tm/lh1jYVKY6clGMg7AfRcOpfZmfaa44esDWF1F4/4oCp2608iWNZEjo3a5I6yfk LvaforUNuJR5142U+zVtKkwc8X3xKzYwUn+JfNHCgem/AZn8JoMN0+yk6MkYWQ0sX6Vx6Z8sloO qb0+x87j//OOxFenXNscRCMYVBH0iGpDvu5pu7UQdpIxGtNNOAjwCyu0oq77pTlmOhBNWKJy42M WHNWz+uJ35COdTw== 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?1759902897358411856?= X-GMAIL-MSGID: =?utf-8?q?1759902897358411856?= tcp_set_state() is called from tcp_done() already. There is then no need to first set the state to TCP_CLOSE, then call tcp_done(). Fixes: d582484726c4 ("mptcp: fix fallback for MP_JOIN subflows") Cc: stable@vger.kernel.org Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/362 Acked-by: Paolo Abeni Signed-off-by: Matthieu Baerts --- net/mptcp/subflow.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 2aadc8733369..a0041360ee9d 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -406,7 +406,6 @@ void mptcp_subflow_reset(struct sock *ssk) /* must hold: tcp_done() could drop last reference on parent */ sock_hold(sk); - tcp_set_state(ssk, TCP_CLOSE); tcp_send_active_reset(ssk, GFP_ATOMIC); tcp_done(ssk); if (!test_and_set_bit(MPTCP_WORK_CLOSE_SUBFLOW, &mptcp_sk(sk)->flags) && From patchwork Thu Mar 9 14:50:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 66917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp341950wrd; Thu, 9 Mar 2023 07:08:29 -0800 (PST) X-Google-Smtp-Source: AK7set/FHeMAMZqUQpqS5Y7vkWn7cJp4tGa2bGedsjgwEXizee/o+8HSKivo3j3o7CUC0exWApe6 X-Received: by 2002:a05:6e02:12cf:b0:311:1168:b9b5 with SMTP id i15-20020a056e0212cf00b003111168b9b5mr3966494ilm.23.1678374509273; Thu, 09 Mar 2023 07:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678374509; cv=none; d=google.com; s=arc-20160816; b=FOGqS2tp8NHuWwVHO0ch/1kLwCGcvN//jsMYbs7GkrQJz5WuhHrNiQ4rZTN1AXhE6K S1ci74PLuHImkl66uqw88MOKcXYiZKyec2he5IVlktSYvXgRQLAlmBjVORyaeb2XjGNK Y0cdEi1XfkBnfE6LUUSR9Jaw3rml5V9usi6/L9TKLg+zFCKk8vFoVcgTJAw8/PRQRhLh JIleFqr8Ty1Glc5thmCO2GZdT/DIuEYCoE59Bq8Y4ocFOEdQd0ugKrWTqUh3+LMc37Ws G/mr8Q1+JNoU7GxP/nLMdaDtasqASYpP8XofMIYIVtAMb7L1lCuIx1L76RDP/buAPZvi TIBA== 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=Hmy3PkPHQ2u3OS0v9qWvPRQmIDrYZcauNq0B9Zz8Ptw=; b=a89kZWhOMt09+Rc1/4fReSqueQMU5zQBuNkttIZLWCbAi3AgVY1+CR2Ga+PtnyKZFE ifQAvhbJLGR2lEVqhQrFgt8hZPuALBC6xH8p3v1/4Qb9WgwzT27+BdV3lfTq/eHPLOn3 hxamguWz5UziYaozPLoR0xuf5DorZzqXWJ4Owg6KUb9ilL87botNVxV7k7TWFTQQM24u Ilo4yqI6hPZS9uNsOa2OgX0PYFeAHnRpYK5bt0GYqz9RSosNUYHiRoI9K36J4/lxk5hz 4iM0ksPTl+I4PhsW4e7m/DKmyA28pvUmx9SEOPclaaR/ep4fEgvPBozTBcguEHyiPo5v lhvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b="75S4M1/a"; 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=REJECT sp=REJECT 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 k14-20020a92b70e000000b00316af4585b9si17369140ili.10.2023.03.09.07.08.12; Thu, 09 Mar 2023 07:08:29 -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="75S4M1/a"; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbjCIOzL (ORCPT + 99 others); Thu, 9 Mar 2023 09:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjCIOyF (ORCPT ); Thu, 9 Mar 2023 09:54:05 -0500 Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A22F4B4E for ; Thu, 9 Mar 2023 06:51:29 -0800 (PST) Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-176e43eb199so2534306fac.7 for ; Thu, 09 Mar 2023 06:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1678373488; 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=Hmy3PkPHQ2u3OS0v9qWvPRQmIDrYZcauNq0B9Zz8Ptw=; b=75S4M1/anGft2wOuhmMfIB2P5gXujxapU5TSo4ZG6/cMhcGqvW3htpmJHpBs8faCf8 W4TXN3jKZ7vKY46xq/Ohqw0jSxPPZTD8w70DIs3L4p0fhlcZj4v4LYNBKkFBU1mIlYiA CB/CwRmr8041sLXRxpxhIV2l3YdAExY4pOTQYpZA/k6zymLu3myyjK/Jml2Zj+caFWoG jUX6HUTKv6LRJGCEQRlwJX5jIoaWxoM34y6OEmrbyr7CupjCRi/R7n+YQhC3wtERhr1c 1+gUKRo+U4UjkGLTZMeT6WtWFAr1CC+l9MgiwsDtNvO1MRp4AKnYAywf0JMcmZrhf/IU rogw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678373488; 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=Hmy3PkPHQ2u3OS0v9qWvPRQmIDrYZcauNq0B9Zz8Ptw=; b=NhWMaJ7I0JH31D2PfBmZx4kyoWZAzqRrFRDXbZKRwIY3kwKI3KF/bOzwP64vf7VzCw u4GxMBHhCjLPnD6/WeiYb/kGNhjVV83VOT9Uiv9UbpCT2PuDodsGj9XvXEQljqLJSNp8 /hKC8bYmbIGMyHoRrRmhIrCPWmAHRYE9S9OaThW1LqdhNaijqVpsyDpuRkB0nyFaTebQ 04vGpXltC9YiV8lKexw0+MCn7dq325fzf7vmSEacUagiAQPZ6MtvTS6WWhrjPTgIJrP2 pY9ZWSxnj+n6ARINUeHUxzu1gRhXrSReOsKTWzPJMCAJeQrF4V/07mEyRs4A+4/trK+F hWTw== X-Gm-Message-State: AO0yUKUAP8C1x3VlNyeb7Nni2TPWHAMOOS+IDZpBaKsJsfZeyvSL/eW+ 1esG5L5Amzi7j864CL3XGMhfXw== X-Received: by 2002:a05:6870:63a7:b0:163:58e8:77e5 with SMTP id t39-20020a05687063a700b0016358e877e5mr13797510oap.52.1678373487398; Thu, 09 Mar 2023 06:51:27 -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 ax39-20020a05687c022700b0016b0369f08fsm7351116oac.15.2023.03.09.06.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 06:51:27 -0800 (PST) From: Matthieu Baerts Date: Thu, 09 Mar 2023 15:50:04 +0100 Subject: [PATCH net v2 8/8] mptcp: fix lockdep false positive in mptcp_pm_nl_create_listen_socket() MIME-Version: 1.0 Message-Id: <20230227-upstream-net-20230227-mptcp-fixes-v2-8-47c2e95eada9@tessares.net> References: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> In-Reply-To: <20230227-upstream-net-20230227-mptcp-fixes-v2-0-47c2e95eada9@tessares.net> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau , Jiang Biao , Menglong Dong , Mengen Sun , Shuah Khan , Florian Westphal Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts , stable@vger.kernel.org, Christoph Paasch X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2460; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=hqAM0Pg1CL8N6FLTp05rrsEa/m98vr/X4KK/h6eveNg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkCfIhlczjyma02ViYKD6MJ5M1VuWVHNyx+4BGF d/hvmQ7fwqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZAnyIQAKCRD2t4JPQmmg c31kEACurErU6ZCLhi48hHRrQ9GNdmdYCPgJTdZYIMLZ7iV3AAq4Z2knWKWnK7+hx2YiFszPJ/P hYvLL71GwNTWFGKHmnhR+aGBx1ZREpAS65kS8/p5vnBRiTwFI1q7LnFDDNa80czfsBCFpR0XXgf 2fZjQRKIl/Dhw7FBdCZ2wezTqAPmGmQdRQxRtzofrlhdK2wpqerqMeqRPKLiggC3ftK7nsdcpG+ uWC/9v4WamN0SsjGPdmbgnS5i8L+Fdcr03Ynfa+5YYRYcpaMjsCFMryP+J4+ku7OnUaKV8+W4/P G2odQbe8ZsjFUiWPwp5Af1f9Zjd4A1oNYxl+IiL1pm7oTFICdecr1YvLlG7/HmodFaU4JRsGj/y XiiJps3ZdQqQneTAeEKdI459qkvYklb+7HpOUR3y8Gsj3zQzvC76nR/W8iuvDa1BeKVWAWoSMp5 Yy+IbUKK5ZMf7WFtnXoPBIkLfHjmi9XXRgA/o4o1/ADAE9aGzCs4aMxv6oxYHfzb33AT2cHb0SJ N7xXmEJujU/9pTGfCGukRGZxFehB5IPqNiRB+rqAB57yXmq7svmCpxp2uzHGAtgVRfNvjGRkIxT MusvZ77L+pYpvPpoTrOHS5RVypXW/W5l9cuyUFA+nPnYepl2BcEd5HQvPc1+U/TG85cWI/2t8SZ Y0EKjBYvBQ+BYkw== 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?1759903229514226453?= X-GMAIL-MSGID: =?utf-8?q?1759903229514226453?= From: Paolo Abeni Christoph reports a lockdep splat in the mptcp_subflow_create_socket() error path, when such function is invoked by mptcp_pm_nl_create_listen_socket(). Such code path acquires two separates, nested socket lock, with the internal lock operation lacking the "nested" annotation. Adding that in sock_release() for mptcp's sake only could be confusing. Instead just add a new lockclass to the in-kernel msk socket, re-initializing the lockdep infra after the socket creation. Fixes: ad2171009d96 ("mptcp: fix locking for in-kernel listener creation") Cc: stable@vger.kernel.org Reported-by: Christoph Paasch Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/354 Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Tested-by: Christoph Paasch Signed-off-by: Matthieu Baerts --- net/mptcp/pm_netlink.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 56628b52d100..5c8dea49626c 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -997,9 +997,13 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet, return ret; } +static struct lock_class_key mptcp_slock_keys[2]; +static struct lock_class_key mptcp_keys[2]; + static int mptcp_pm_nl_create_listen_socket(struct sock *sk, struct mptcp_pm_addr_entry *entry) { + bool is_ipv6 = sk->sk_family == AF_INET6; int addrlen = sizeof(struct sockaddr_in); struct sockaddr_storage addr; struct socket *ssock; @@ -1016,6 +1020,18 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, if (!newsk) return -EINVAL; + /* The subflow socket lock is acquired in a nested to the msk one + * in several places, even by the TCP stack, and this msk is a kernel + * socket: lockdep complains. Instead of propagating the _nested + * modifiers in several places, re-init the lock class for the msk + * socket to an mptcp specific one. + */ + sock_lock_init_class_and_name(newsk, + is_ipv6 ? "mlock-AF_INET6" : "mlock-AF_INET", + &mptcp_slock_keys[is_ipv6], + is_ipv6 ? "msk_lock-AF_INET6" : "msk_lock-AF_INET", + &mptcp_keys[is_ipv6]); + lock_sock(newsk); ssock = __mptcp_nmpc_socket(mptcp_sk(newsk)); release_sock(newsk);