Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp785097rdb; Fri, 2 Feb 2024 04:10:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpv6R4c8rAFp6hCIy2O3jQicvar6aAB7fwgu7MoymNvAbjtXLdkWPSLzWHVSx/aUbqtzLf X-Received: by 2002:a05:6a21:998b:b0:19e:3373:d726 with SMTP id ve11-20020a056a21998b00b0019e3373d726mr3287458pzb.2.1706875837798; Fri, 02 Feb 2024 04:10:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706875837; cv=pass; d=google.com; s=arc-20160816; b=OrnYBjMS9ClXrJEfrJXH41MtdmsJ0B4Q0Oqem//6oI7mP7ASycmkStwazGcl5BDIx/ 2nE9Dvy6ACWsCptspef4yDyRde1MWI3WQa0XRUWKqXRwzLt+3M/s6O56dtXu1Ico37m2 jbRVfkpJ58utTE2vfUiE01413v0HqZ9/UWyEcroxKuZzTgwLjih/zyCMeZ1G6LpDvYVy hStlJVc06sFPhsOdmrOgciKfzTp4IcXfBBVtKEbuNFJuNOiinJTjCnEW+/ZCnZiFPnvv niHSp0hn16FVBFLYu+TlJ0ddrJO7E+fBVbkJLUIuX5khe+UWJYH7HiS9GSqCmBxMcvmf EBTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=hmABi22q85Co2MEcMOXWeo2FUPNIq8TRNz7fj/UcLdw=; fh=uCX4j+Wrexk5xv3y/Jlt8hlfh30Kk+3faVeXGCZ3Ams=; b=EtGlBRdbJVg0ozOPOtozqyGO4Xd5pW7IcQdZQTtMYRGU+cQ+I0W8/nyDrr9JxSrCYD Lkk65uEUpcQGzIPORhvn9L88COXdOPDtj4QOLfT7+XIAf5IZpgj8RPsY6k+VTvkU1kKR /NHP/qw96ILDG5ICBWq8k0f4bm5ZamJW+xiaU8lALsTIohpLST+C6cGcL81U23y640WW KwpDjyoXZcuTgGGYpk8FVXU14L8PqwYqneIsP7vaSQyLazzj13bhV+Ghn4AWhVoGwKlN Q7vvlyq5BONKfrmo7Cs+Vuh5ij1cM3WxDoJl38Tv+TGqNcT/K6JyoW7QUHboN0COmele UpGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eZC0VIPY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49779-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49779-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCU6qrZz0uKTH4oDDk7sbsolaUITcFiwp2J853LOUg2mABcg9HVSK9w/iQdg1C03dGn2luizIoygOAwGEsxr6PhxjmLf8qPAJ41YFLSWRw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j19-20020a634a53000000b005dbe215856dsi1499575pgl.765.2024.02.02.04.10.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 04:10:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49779-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eZC0VIPY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49779-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49779-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 62F14B2E02A for ; Fri, 2 Feb 2024 11:44:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85A0C1468E7; Fri, 2 Feb 2024 11:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eZC0VIPY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6461145B31; Fri, 2 Feb 2024 11:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706874030; cv=none; b=uBezmYQnZO77RR3lCMa//KeJ4BsAaNEP1h47s+BUTwI3siTAsYjcWnBuxYq9CmMkNdmqYofkQiJe67mYFX9XyWUI8O/h/t771KSE9Fy/3ZXF+CjqVM1JGXo3uzHGoTgDatFGoJjXWarDnQgAYD7f+jJ9RGCDBUuE6S9aYSsLFd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706874030; c=relaxed/simple; bh=Jxc4BXAT6dxBPjnLFX0FeEQI0zrczQYYN04opb4NwR8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=brHJ6fykaoHM2pcv3j9NSRBxRtv2kknwlQ2cdGFLC0jjc0N2x3qr1qMjd7rYkFveXB92kFgqBhPA3c3WB6VBKI1jfb80VhQvyE6+In7XaF4Ad3TX+NvqctsN8YSaBTI2MdjXx19iyRC0kHrQqdiH8x1lJkBPVEagdWnylw6Gj00= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eZC0VIPY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EDDEC43390; Fri, 2 Feb 2024 11:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706874030; bh=Jxc4BXAT6dxBPjnLFX0FeEQI0zrczQYYN04opb4NwR8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eZC0VIPYmTttoPG1KCdP4MgZADpjHYBHdO1WmQLiDiUKpA0zC4WHTtfgjebCDwvKQ xikGyFVOqC7uU5JhR1Y49wTfWSlfOcIgAUJtycROLcm16vcxj1+lpzxegRkmmiK3DX PiKclq9lcZSox/ugQAVpb8AOkcmEIGAqfYofh2TCCJ2KAXvCePgHunx4SvK3VhH6xH wawNV0gILpWY+UqGlBvdstd+2csVmiyNCM0YIzp43v47Jq8M/zGb74ei/EYu2LZNUS sBP8G9oN82AkS4nwrvb/zGVrmWcpRL3I7ZUXfuIOv4jI5/ta2Na0CfUsXjejyLYTKi /qO6ZlZu2VBdQ== From: "Matthieu Baerts (NGI0)" Date: Fri, 02 Feb 2024 12:40:11 +0100 Subject: [PATCH net-next 5/5] mptcp: annotate lockless accesses around read-mostly fields Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240202-upstream-net-next-20240202-mptcp-annotate-lockless-access-v1-5-031d6680afdc@kernel.org> References: <20240202-upstream-net-next-20240202-mptcp-annotate-lockless-access-v1-0-031d6680afdc@kernel.org> In-Reply-To: <20240202-upstream-net-next-20240202-mptcp-annotate-lockless-access-v1-0-031d6680afdc@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2205; i=matttbe@kernel.org; h=from:subject:message-id; bh=mcjDNT7BXUOg/gwV+eNe8UHcg0uqImaUFo1VPMNJ1B8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlvNSff8n+XmNCRtXgslij21RTQ7ZYYjUF0CJma R3m/ECc3fmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZbzUnwAKCRD2t4JPQmmg c1LmEADl/BohaAL8uYm11SJ5Smbiq5+ZyWk01aKz/XPWg7ewbVlsU/R/RBjdM/O+rR1SbjbH6rG BrMYDgz4uiVDoh3h5B1ZEBm8g/EEkNzMc39hlXM4foIrHMyzi/0cPK5rElMzEV21Quq5r75c1RF nKLWmxprNunbJpLP0B30NwHEqXbYkatUJlHXRhpOEt4NZtcdvo60lMr1sMvrV7V+J4UsK61rMEH +TprDzAk+dcVmQUFUWQDpvsiX6Skm9LsDlsb2rXgFaAkB+gzlygsJdJnVydi70VMQ6SkSq56bgj m5R+sTKA22TuUvkDD+ycEscoPCUU0+qtwfdheP1ckZuD+6GZsHo3P2LbUbN+HSN50w13Va9D9QJ mb2SFl9x45Ep0FMmhohUaO49TQH4fnkdyVWTr5noJnMSKXqve1tWxT59lezdeir583uDhQFmBjL PW/z1wVxk0TbpGEDTRMoSOn6AkFPZ1a6ib6lRiisQl/MgeK4mVA04OUuH47RK2+Kf9DJkApPvCF gf5BCWV4npKtKkiM2hSv2eT/xCcAK7iaW5uEx9gL4daulhummlWTUqKnvTXP2PJPHgkK9UwIzLm zTa2yjXfu+JicdMuy9fLpTxzIhS0VFItjUmwwev6s3cD9a/3M+rfr5WvigXCVC4/4yCy7E8xDBx qYDLFPju75tNCUA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni The following MPTCP socket fields: - can_ack - fully_established - rcv_data_fin - snd_data_fin_enable - rcv_fastclose - use_64bit_ack are accessed without any lock, add the appropriate annotation. The schema is safe as each field can change its value at most once in the whole mptcp socket life cycle. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 14 +++++++------- net/mptcp/sockopt.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 4478ddd3b5fa..ad39f54b3a81 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3149,16 +3149,16 @@ static int mptcp_disconnect(struct sock *sk, int flags) msk->cb_flags = 0; msk->push_pending = 0; msk->recovery = false; - msk->can_ack = false; - msk->fully_established = false; - msk->rcv_data_fin = false; - msk->snd_data_fin_enable = false; - msk->rcv_fastclose = false; - msk->use_64bit_ack = false; - msk->bytes_consumed = 0; + WRITE_ONCE(msk->can_ack, false); + WRITE_ONCE(msk->fully_established, false); + WRITE_ONCE(msk->rcv_data_fin, false); + WRITE_ONCE(msk->snd_data_fin_enable, false); + WRITE_ONCE(msk->rcv_fastclose, false); + WRITE_ONCE(msk->use_64bit_ack, false); WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk))); mptcp_pm_data_reset(msk); mptcp_ca_reset(sk); + msk->bytes_consumed = 0; msk->bytes_acked = 0; msk->bytes_received = 0; msk->bytes_sent = 0; diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index c40f1428e602..da37e4541a5d 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -942,7 +942,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) mptcp_data_unlock(sk); slow = lock_sock_fast(sk); - info->mptcpi_csum_enabled = msk->csum_enabled; + info->mptcpi_csum_enabled = READ_ONCE(msk->csum_enabled); info->mptcpi_token = msk->token; info->mptcpi_write_seq = msk->write_seq; info->mptcpi_retransmits = inet_csk(sk)->icsk_retransmits; -- 2.43.0