* [PATCH net 0/3] mptcp: pm: a few more fixes
@ 2024-11-12 19:18 Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 1/3] mptcp: update local address flags when setting it Matthieu Baerts (NGI0)
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-11-12 19:18 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Kishen Maloor
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), stable, Geliang Tang
Three small fixes related to the MPTCP path-manager:
- Patch 1: correctly reflect the backup flag to the corresponding local
address entry of the userspace path-manager. A fix for v5.19.
- Patch 2: hold the PM lock when deleting an entry from the local
addresses of the userspace path-manager to avoid messing up with this
list. A fix for v5.19.
- Patch 3: use _rcu variant to iterate the in-kernel path-manager's
local addresses list, when under rcu_read_lock(). A fix for v5.17.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Geliang Tang (2):
mptcp: update local address flags when setting it
mptcp: hold pm lock when deleting entry
Matthieu Baerts (NGI0) (1):
mptcp: pm: use _rcu variant under rcu_read_lock
net/mptcp/pm_netlink.c | 3 ++-
net/mptcp/pm_userspace.c | 15 +++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
---
base-commit: 20bbe5b802494444791beaf2c6b9597fcc67ff49
change-id: 20241112-net-mptcp-misc-6-12-pm-97ea0ec1d979
Best regards,
--
Matthieu Baerts (NGI0) <matttbe@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/3] mptcp: update local address flags when setting it
2024-11-12 19:18 [PATCH net 0/3] mptcp: pm: a few more fixes Matthieu Baerts (NGI0)
@ 2024-11-12 19:18 ` Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 2/3] mptcp: hold pm lock when deleting entry Matthieu Baerts (NGI0)
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-11-12 19:18 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Kishen Maloor
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), stable, Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Just like in-kernel pm, when userspace pm does set_flags, it needs to send
out MP_PRIO signal, and also modify the flags of the corresponding address
entry in the local address list. This patch implements the missing logic.
Traverse all address entries on userspace_pm_local_addr_list to find the
local address entry, if bkup is true, set the flags of this entry with
FLAG_BACKUP, otherwise, clear FLAG_BACKUP.
Fixes: 892f396c8e68 ("mptcp: netlink: issue MP_PRIO signals from userspace PMs")
Cc: stable@vger.kernel.org
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_userspace.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 56dfea9862b7b24dd0eaa8bbedcf22a7f6829ccf..3f888bfe1462ee3c75a3fb6eefe29cb712471410 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -560,6 +560,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
struct net *net = sock_net(skb->sk);
+ struct mptcp_pm_addr_entry *entry;
struct mptcp_sock *msk;
int ret = -EINVAL;
struct sock *sk;
@@ -601,6 +602,17 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP)
bkup = 1;
+ spin_lock_bh(&msk->pm.lock);
+ list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
+ if (mptcp_addresses_equal(&entry->addr, &loc.addr, false)) {
+ if (bkup)
+ entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
+ else
+ entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP;
+ }
+ }
+ spin_unlock_bh(&msk->pm.lock);
+
lock_sock(sk);
ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup);
release_sock(sk);
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 2/3] mptcp: hold pm lock when deleting entry
2024-11-12 19:18 [PATCH net 0/3] mptcp: pm: a few more fixes Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 1/3] mptcp: update local address flags when setting it Matthieu Baerts (NGI0)
@ 2024-11-12 19:18 ` Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 3/3] mptcp: pm: use _rcu variant under rcu_read_lock Matthieu Baerts (NGI0)
2024-11-14 3:10 ` [PATCH net 0/3] mptcp: pm: a few more fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-11-12 19:18 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Kishen Maloor
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), stable, Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
When traversing userspace_pm_local_addr_list and deleting an entry from
it in mptcp_pm_nl_remove_doit(), msk->pm.lock should be held.
This patch holds this lock before mptcp_userspace_pm_lookup_addr_by_id()
and releases it after list_move() in mptcp_pm_nl_remove_doit().
Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
Cc: stable@vger.kernel.org
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_userspace.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 3f888bfe1462ee3c75a3fb6eefe29cb712471410..e35178f5205faac4a9199df1ffca79085e4b7c68 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -308,14 +308,17 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
lock_sock(sk);
+ spin_lock_bh(&msk->pm.lock);
match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val);
if (!match) {
GENL_SET_ERR_MSG(info, "address with specified id not found");
+ spin_unlock_bh(&msk->pm.lock);
release_sock(sk);
goto out;
}
list_move(&match->list, &free_list);
+ spin_unlock_bh(&msk->pm.lock);
mptcp_pm_remove_addrs(msk, &free_list);
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 3/3] mptcp: pm: use _rcu variant under rcu_read_lock
2024-11-12 19:18 [PATCH net 0/3] mptcp: pm: a few more fixes Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 1/3] mptcp: update local address flags when setting it Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 2/3] mptcp: hold pm lock when deleting entry Matthieu Baerts (NGI0)
@ 2024-11-12 19:18 ` Matthieu Baerts (NGI0)
2024-11-14 3:10 ` [PATCH net 0/3] mptcp: pm: a few more fixes patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Matthieu Baerts (NGI0) @ 2024-11-12 19:18 UTC (permalink / raw)
To: mptcp, Mat Martineau, Geliang Tang, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Kishen Maloor
Cc: netdev, linux-kernel, Matthieu Baerts (NGI0), stable
In mptcp_pm_create_subflow_or_signal_addr(), rcu_read_(un)lock() are
used as expected to iterate over the list of local addresses, but
list_for_each_entry() was used instead of list_for_each_entry_rcu() in
__lookup_addr(). It is important to use this variant which adds the
required READ_ONCE() (and diagnostic checks if enabled).
Because __lookup_addr() is also used in mptcp_pm_nl_set_flags() where it
is called under the pernet->lock and not rcu_read_lock(), an extra
condition is then passed to help the diagnostic checks making sure
either the associated spin lock or the RCU lock is held.
Fixes: 86e39e04482b ("mptcp: keep track of local endpoint still available for each msk")
Cc: stable@vger.kernel.org
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/pm_netlink.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index db586a5b3866f66a24431d7f2cab566f89102885..45a2b5f05d38b0e7f334578f5ee6923a8ff8f7b2 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -524,7 +524,8 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info)
{
struct mptcp_pm_addr_entry *entry;
- list_for_each_entry(entry, &pernet->local_addr_list, list) {
+ list_for_each_entry_rcu(entry, &pernet->local_addr_list, list,
+ lockdep_is_held(&pernet->lock)) {
if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port))
return entry;
}
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/3] mptcp: pm: a few more fixes
2024-11-12 19:18 [PATCH net 0/3] mptcp: pm: a few more fixes Matthieu Baerts (NGI0)
` (2 preceding siblings ...)
2024-11-12 19:18 ` [PATCH net 3/3] mptcp: pm: use _rcu variant under rcu_read_lock Matthieu Baerts (NGI0)
@ 2024-11-14 3:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-14 3:10 UTC (permalink / raw)
To: Matthieu Baerts
Cc: mptcp, martineau, geliang, davem, edumazet, kuba, pabeni, horms,
kishen.maloor, netdev, linux-kernel, stable
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 12 Nov 2024 20:18:32 +0100 you wrote:
> Three small fixes related to the MPTCP path-manager:
>
> - Patch 1: correctly reflect the backup flag to the corresponding local
> address entry of the userspace path-manager. A fix for v5.19.
>
> - Patch 2: hold the PM lock when deleting an entry from the local
> addresses of the userspace path-manager to avoid messing up with this
> list. A fix for v5.19.
>
> [...]
Here is the summary with links:
- [net,1/3] mptcp: update local address flags when setting it
https://git.kernel.org/netdev/net/c/e0266319413d
- [net,2/3] mptcp: hold pm lock when deleting entry
https://git.kernel.org/netdev/net/c/f642c5c4d528
- [net,3/3] mptcp: pm: use _rcu variant under rcu_read_lock
https://git.kernel.org/netdev/net/c/db3eab8110bc
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
end of thread, other threads:[~2024-11-14 3:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12 19:18 [PATCH net 0/3] mptcp: pm: a few more fixes Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 1/3] mptcp: update local address flags when setting it Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 2/3] mptcp: hold pm lock when deleting entry Matthieu Baerts (NGI0)
2024-11-12 19:18 ` [PATCH net 3/3] mptcp: pm: use _rcu variant under rcu_read_lock Matthieu Baerts (NGI0)
2024-11-14 3:10 ` [PATCH net 0/3] mptcp: pm: a few more fixes patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®