summaryrefslogtreecommitdiff
path: root/net/mptcp/diag.c
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2024-02-15 21:25:31 +0300
committerDavid S. Miller <davem@davemloft.net>2024-02-18 13:25:00 +0300
commita7cfe776637004a4c938fde78be4bd608c32c3ef (patch)
treebed69851fb9a72067edc4a9d769c40e1e6384a8b /net/mptcp/diag.c
parentb8adb69a7d29c2d33eb327bca66476fb6066516b (diff)
downloadlinux-a7cfe776637004a4c938fde78be4bd608c32c3ef.tar.xz
mptcp: fix data races on local_id
The local address id is accessed lockless by the NL PM, add all the required ONCE annotation. There is a caveat: the local id can be initialized late in the subflow life-cycle, and its validity is controlled by the local_id_valid flag. Remove such flag and encode the validity in the local_id field itself with negative value before initialization. That allows accessing the field consistently with a single read operation. Fixes: 0ee4261a3681 ("mptcp: implement mptcp_pm_remove_subflow") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mptcp/diag.c')
-rw-r--r--net/mptcp/diag.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/mptcp/diag.c b/net/mptcp/diag.c
index e57c5f47f035..6ff6f14674aa 100644
--- a/net/mptcp/diag.c
+++ b/net/mptcp/diag.c
@@ -65,7 +65,7 @@ static int subflow_get_info(struct sock *sk, struct sk_buff *skb)
sf->map_data_len) ||
nla_put_u32(skb, MPTCP_SUBFLOW_ATTR_FLAGS, flags) ||
nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_REM, sf->remote_id) ||
- nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_LOC, sf->local_id)) {
+ nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_LOC, subflow_get_local_id(sf))) {
err = -EMSGSIZE;
goto nla_failure;
}