Message ID | 20230207-upstream-net-20230207-various-fix-6-2-v1-2-2031b495c7cc@tessares.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2836171wrn; Tue, 7 Feb 2023 05:05:48 -0800 (PST) X-Google-Smtp-Source: AK7set+OK9wUjLi8tps9Q4q8km7HgQ8/K65EI9qu6/vjQ+IHGj0yCmSNEB17sV8qKSQXc6kB/6zM X-Received: by 2002:a50:9f09:0:b0:49a:f52f:eed0 with SMTP id b9-20020a509f09000000b0049af52feed0mr3782827edf.13.1675775148696; Tue, 07 Feb 2023 05:05:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675775148; cv=none; d=google.com; s=arc-20160816; b=IeZBUsZAFUXnAlLa2ulTDnZ+VUt+bNand7Fy+Xw/VedJ/6g7/qHTnTlDFZIv1ZvZuu KneNGhi/z0LmxdPqcTBBVHI55UJXgRJEjlRNJKGB9BJq8oHeKpSIfJGn3T66xEnxELFU fmvAzYof6LxB2nSeeB3/DWbaiZfJa2qQobyBr18vXPhw4tgdjX23wFoKLLsjJsMO513Q HFgngVx8+Sefr1YNQ1IVdb0/O24Kr3ncL1M7F5adWPN4E1W4CZC0qZm3IiXpweRB6Gzl nnNt1Q+Un6+Pb44UJidEDJfWDxsXnMP/pJXs7bRaxYEkcG4fSL2kFLDejbYXj2T+NfT/ VC9A== 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=beGgM2LbSkA8IGAfTfFvAxgcywRr6/D7z4MyBTSCBrQ=; b=XazWiTg0tSm7etQs4g+LXSvn0QmaK9OSMRkh0iRWAKO9aW0HJPClTyguPmnC+pMn2g QpAQ20TY2px9uGHSeOWdsgo+5b5Swp55ibUWimqBsF3AM+hgt2J4UqThK1CIwDdKEHON iDckRIuW3gbeFMelEqSYpiaYCKZ27+2IZVzuOyAqDGvh8pDj1xsq5Y7ZZP7KFWr1v8Sm fUGY1HMXjbpNz9jRNKh+lWO4w0gERSUy1KAfKIeJYh6q06pXP62E6imuwQDBpsX/Ht4P ooTAXck353qxP+qQMlUI3hbFBgWpmcPrbDF2u5ebAuQMIBadsskR27AOz/Nsv6KJ67o/ Q4Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=SEx05lls; 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 er22-20020a056402449600b004a21cd9fef7si15276712edb.323.2023.02.07.05.05.25; Tue, 07 Feb 2023 05:05:48 -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=SEx05lls; 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 S232152AbjBGNFD (ORCPT <rfc822;kmanaouilinux@gmail.com> + 99 others); Tue, 7 Feb 2023 08:05:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbjBGNEy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Feb 2023 08:04:54 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 774023A584 for <linux-kernel@vger.kernel.org>; Tue, 7 Feb 2023 05:04:45 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id m14so13447322wrg.13 for <linux-kernel@vger.kernel.org>; Tue, 07 Feb 2023 05:04:45 -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=beGgM2LbSkA8IGAfTfFvAxgcywRr6/D7z4MyBTSCBrQ=; b=SEx05llstpytJjDvzeR65GSYxlxUj4nkxDXeYbz8g1KVIb0Cb3MBtIJKUJTdBiSGxK nqg0ItCQ7Y10GTLXSkh12lZ+pKIWyLIlQv/E46zBlTonmoKx2mWJYGMAuPKguy5a5s38 ZQHKK6D/KF5JrMs/GPFEYrGMjnpaaPp6NQEz/OFGb7kqUnpJ0ZHyAfb32uxjObStvn6m AvLhx1z7UZJVeRMJ6b9cTBP631IM6ofU27EJO1XmaI6VT3fbl57PgjuIwMKP3QGJv9DM jgAz++ZmB77D0h97Ncpwa2l56NdiiCnUQE9m07syabj0j+tTI9faAHNa78v1uHl7Odw9 KWTw== 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=beGgM2LbSkA8IGAfTfFvAxgcywRr6/D7z4MyBTSCBrQ=; b=u/Vdrq5uLfHswBR2HwZLHQOGDA2OFuE/muOqZJ7C6lTZ3HKCs04j7MUPeGs8OqOim5 Lg2tAhXCLiwzytSWaaPZu8UjI+3jXAsHahJfKulYOIHWMLcNpo1UAABkAoiRnSU0RXzn 2XTpOHCkb+DeThGlcREXj85zv4ETdX5GPEpveV8inu9Fu+SseRMp3KXIOYRjf8q7IzXo arUysqmcDKRIpOX5RpiQfej1Km4jnmH4oE+hQmtb9oVIQNrBLshamWyQaZwHzYpYkPF5 L/Im83PMRv/aJtzQMYhZ3WlaIHJhyzunk9AsUK3me0bf58id9W7h4qhq283MLgPn41sq 10zw== X-Gm-Message-State: AO0yUKWPKiVsHQK0Eg5k9u7gzsNfD+i22suplhkh8TsMvZoZBv4BhSDN Urz+4a9vLaUlDV2F5kVzqtdgtQ== X-Received: by 2002:a5d:6046:0:b0:2be:5ca0:a7f9 with SMTP id j6-20020a5d6046000000b002be5ca0a7f9mr2642129wrt.33.1675775083981; Tue, 07 Feb 2023 05:04: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 n9-20020a5d5989000000b002bc7fcf08ddsm11645394wri.103.2023.02.07.05.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 05:04:43 -0800 (PST) From: Matthieu Baerts <matthieu.baerts@tessares.net> Date: Tue, 07 Feb 2023 14:04:14 +0100 Subject: [PATCH net 2/6] mptcp: fix locking for setsockopt corner-case MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230207-upstream-net-20230207-various-fix-6-2-v1-2-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" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Davide Caratti <dcaratti@redhat.com>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Benjamin Hesmans <benjamin.hesmans@tessares.net>, Geliang Tang <geliangtang@gmail.com>, Shuah Khan <shuah@kernel.org> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Matthieu Baerts <matthieu.baerts@tessares.net>, stable@vger.kernel.org X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1507; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=tU92Z5FtU+rxP2x5Q9J2r5aQ+mvHt8iWMbRSULE+GL8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBj4kxo3Fz3M6U+ZqFEqliFhKp6GfvWCWFMRgKtp KfknMVgtAiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY+JMaAAKCRD2t4JPQmmg c7XfD/43VLBXwdb+RbXPVii16WQ7mY2RSpjNlzgqZ3sBZup/f8WZGkVzNABwdXWm9QMzPNHwEnU kBeYf+UtjhvF+f3lkdU0PZ756cNxJQkbS7VxrzFt5dpy9doA/i8xTeV7TNLnA5NaVR6BGSbXit6 UZzXqoPZRWErMWFN3jcTkiKsbGX2Z+CUSRdo0jh8YLXpZtLt3Slxi5x4Xr3xNv6cFKpUCzDGEAX vPi8JFtfMzVzfQx3R1PK2kGGXE7qmzVJZVrQNwRba7s32pGuYOn4w1quZ9oALgBbNWw1YtxH+5y ZK8JwgaGyxrVOyrREUKORoLrTVkzc8oDze9MGSxQ+Fynn2k+uy9PcEK5blZwGWIRP/ChPU8XZ2P jANo1DCq5XrEqkTP2Qo3b3kwmoFggzZO5H6M9VBCWgjpl+OOF/zYTVZ+bi3RiD1yUWSlKDV4F27 mtE3FPGWfLBedr2gZnIBxjWDZBvaTQL51YgyuPKYMKW8y8lxu+LDG1ExexmXgoqLefI/63OeMdz kRa9NAD2ineJZd5cChSQRpvDIlTcHKyDVUMciS14uuZwA76y37D5NgG8F37JBHZx+HUrymsYqDj NCXByJtLbR0eu8vqlsd7DOGznFk5E8C8sRiVAcGnqjuObFdNHmv7kekqWhcoHGW30OFm78J9Scz CJvs9L9o6bHugmA== 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757177602199154181?= X-GMAIL-MSGID: =?utf-8?q?1757177602199154181?= |
Series |
mptcp: fixes for v6.2
|
|
Commit Message
Matthieu Baerts
Feb. 7, 2023, 1:04 p.m. UTC
From: Paolo Abeni <pabeni@redhat.com> We need to call the __mptcp_nmpc_socket(), and later subflow socket access under the msk socket lock, or e.g. a racing connect() could change the socket status under the hood, with unexpected results. Fixes: 54635bd04701 ("mptcp: add TCP_FASTOPEN_CONNECT socket option") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- net/mptcp/sockopt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index d4b1e6ec1b36..7f2c3727ab23 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -760,14 +760,21 @@ static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname, static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int optname, sockptr_t optval, unsigned int optlen) { + struct sock *sk = (struct sock *)msk; struct socket *sock; + int ret = -EINVAL; /* Limit to first subflow, before the connection establishment */ + lock_sock(sk); sock = __mptcp_nmpc_socket(msk); if (!sock) - return -EINVAL; + goto unlock; - return tcp_setsockopt(sock->sk, level, optname, optval, optlen); + ret = tcp_setsockopt(sock->sk, level, optname, optval, optlen); + +unlock: + release_sock(sk); + return ret; } static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,