* [PATCH net 1/3] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags()
2022-01-21 0:35 [PATCH net 0/3] mptcp: A few fixes Mat Martineau
@ 2022-01-21 0:35 ` Mat Martineau
2022-01-21 0:35 ` [PATCH net 2/3] mptcp: fix removing ids bitmap setting Mat Martineau
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mat Martineau @ 2022-01-21 0:35 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, davem, kuba, matthieu.baerts, geliang.tang, mptcp,
Mat Martineau
From: Paolo Abeni <pabeni@redhat.com>
The MPTCP endpoint list is under RCU protection, guarded by the
pernet spinlock. mptcp_nl_cmd_set_flags() traverses the list
without acquiring the spin-lock nor under the RCU critical section.
This change addresses the issue performing the lookup and the endpoint
update under the pernet spinlock.
Fixes: 0f9f696a502e ("mptcp: add set_flags command in PM netlink")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
net/mptcp/pm_netlink.c | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 75af1f701e1d..f17a09f7fbf9 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -478,6 +478,20 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id)
return NULL;
}
+static struct mptcp_pm_addr_entry *
+__lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info,
+ bool lookup_by_id)
+{
+ struct mptcp_pm_addr_entry *entry;
+
+ list_for_each_entry(entry, &pernet->local_addr_list, list) {
+ if ((!lookup_by_id && addresses_equal(&entry->addr, info, true)) ||
+ (lookup_by_id && entry->addr.id == info->id))
+ return entry;
+ }
+ return NULL;
+}
+
static int
lookup_id_by_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *addr)
{
@@ -1763,18 +1777,21 @@ static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info)
return -EOPNOTSUPP;
}
- list_for_each_entry(entry, &pernet->local_addr_list, list) {
- if ((!lookup_by_id && addresses_equal(&entry->addr, &addr.addr, true)) ||
- (lookup_by_id && entry->addr.id == addr.addr.id)) {
- mptcp_nl_addr_backup(net, &entry->addr, bkup);
-
- if (bkup)
- entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
- else
- entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP;
- }
+ spin_lock_bh(&pernet->lock);
+ entry = __lookup_addr(pernet, &addr.addr, lookup_by_id);
+ if (!entry) {
+ spin_unlock_bh(&pernet->lock);
+ return -EINVAL;
}
+ if (bkup)
+ entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
+ else
+ entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP;
+ addr = *entry;
+ spin_unlock_bh(&pernet->lock);
+
+ mptcp_nl_addr_backup(net, &addr.addr, bkup);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/3] mptcp: fix removing ids bitmap setting
2022-01-21 0:35 [PATCH net 0/3] mptcp: A few fixes Mat Martineau
2022-01-21 0:35 ` [PATCH net 1/3] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags() Mat Martineau
@ 2022-01-21 0:35 ` Mat Martineau
2022-01-21 0:35 ` [PATCH net 3/3] selftests: mptcp: fix ipv6 routing setup Mat Martineau
2022-01-21 6:00 ` [PATCH net 0/3] mptcp: A few fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Mat Martineau @ 2022-01-21 0:35 UTC (permalink / raw)
To: netdev
Cc: Geliang Tang, davem, kuba, matthieu.baerts, mptcp, Paolo Abeni,
Mat Martineau
From: Geliang Tang <geliang.tang@suse.com>
In mptcp_pm_nl_rm_addr_or_subflow(), the bit of rm_list->ids[i] in the
id_avail_bitmap should be set, not rm_list->ids[1]. This patch fixed it.
Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk")
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
net/mptcp/pm_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index f17a09f7fbf9..782b1d452269 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -791,7 +791,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
removed = true;
__MPTCP_INC_STATS(sock_net(sk), rm_type);
}
- __set_bit(rm_list->ids[1], msk->pm.id_avail_bitmap);
+ __set_bit(rm_list->ids[i], msk->pm.id_avail_bitmap);
if (!removed)
continue;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 3/3] selftests: mptcp: fix ipv6 routing setup
2022-01-21 0:35 [PATCH net 0/3] mptcp: A few fixes Mat Martineau
2022-01-21 0:35 ` [PATCH net 1/3] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags() Mat Martineau
2022-01-21 0:35 ` [PATCH net 2/3] mptcp: fix removing ids bitmap setting Mat Martineau
@ 2022-01-21 0:35 ` Mat Martineau
2022-01-21 6:00 ` [PATCH net 0/3] mptcp: A few fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Mat Martineau @ 2022-01-21 0:35 UTC (permalink / raw)
To: netdev
Cc: Paolo Abeni, davem, kuba, matthieu.baerts, mptcp, Geliang Tang,
Mat Martineau
From: Paolo Abeni <pabeni@redhat.com>
MPJ ipv6 selftests currently lack per link route to the server
net. Additionally, ipv6 subflows endpoints are created without any
interface specified. The end-result is that in ipv6 self-tests
subflows are created all on the same link, leading to expected delays
and sporadic self-tests failures.
Fix the issue by adding the missing setup bits.
Fixes: 523514ed0a99 ("selftests: mptcp: add ADD_ADDR IPv6 test cases")
Reported-and-tested-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
tools/testing/selftests/net/mptcp/mptcp_join.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 27d0eb9afdca..b8bdbec0cf69 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -75,6 +75,7 @@ init()
# let $ns2 reach any $ns1 address from any interface
ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
+ ip -net "$ns2" route add default via dead:beef:$i::1 dev ns2eth$i metric 10$i
done
}
@@ -1476,7 +1477,7 @@ ipv6_tests()
reset
ip netns exec $ns1 ./pm_nl_ctl limits 0 1
ip netns exec $ns2 ./pm_nl_ctl limits 0 1
- ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow
+ ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 dev ns2eth3 flags subflow
run_tests $ns1 $ns2 dead:beef:1::1 0 0 0 slow
chk_join_nr "single subflow IPv6" 1 1 1
@@ -1511,7 +1512,7 @@ ipv6_tests()
ip netns exec $ns1 ./pm_nl_ctl limits 0 2
ip netns exec $ns1 ./pm_nl_ctl add dead:beef:2::1 flags signal
ip netns exec $ns2 ./pm_nl_ctl limits 1 2
- ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 flags subflow
+ ip netns exec $ns2 ./pm_nl_ctl add dead:beef:3::2 dev ns2eth3 flags subflow
run_tests $ns1 $ns2 dead:beef:1::1 0 -1 -1 slow
chk_join_nr "remove subflow and signal IPv6" 2 2 2
chk_add_nr 1 1
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/3] mptcp: A few fixes
2022-01-21 0:35 [PATCH net 0/3] mptcp: A few fixes Mat Martineau
` (2 preceding siblings ...)
2022-01-21 0:35 ` [PATCH net 3/3] selftests: mptcp: fix ipv6 routing setup Mat Martineau
@ 2022-01-21 6:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-21 6:00 UTC (permalink / raw)
To: Mat Martineau; +Cc: netdev, davem, kuba, matthieu.baerts, mptcp
Hello:
This series was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 20 Jan 2022 16:35:26 -0800 you wrote:
> Here are some fixes from the mptcp tree:
>
> Patch 1 fixes a RCU locking issue when processing a netlink command that
> updates endpoint flags in the in-kernel MPTCP path manager.
>
> Patch 2 fixes a typo affecting available endpoint id tracking.
>
> [...]
Here is the summary with links:
- [net,1/3] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags()
https://git.kernel.org/netdev/net/c/8e9eacad7ec7
- [net,2/3] mptcp: fix removing ids bitmap setting
https://git.kernel.org/netdev/net/c/a4c0214fbee9
- [net,3/3] selftests: mptcp: fix ipv6 routing setup
https://git.kernel.org/netdev/net/c/9846921dba49
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread