Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'mptcp-pm-a-few-more-fixes'

Matthieu Baerts says:

====================
mptcp: pm: a few more fixes

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.
====================

Link: https://patch.msgid.link/20241112-net-mptcp-misc-6-12-pm-v1-0-b835580cefa8@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+17 -1
+2 -1
net/mptcp/pm_netlink.c
··· 524 524 { 525 525 struct mptcp_pm_addr_entry *entry; 526 526 527 - list_for_each_entry(entry, &pernet->local_addr_list, list) { 527 + list_for_each_entry_rcu(entry, &pernet->local_addr_list, list, 528 + lockdep_is_held(&pernet->lock)) { 528 529 if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) 529 530 return entry; 530 531 }
+15
net/mptcp/pm_userspace.c
··· 308 308 309 309 lock_sock(sk); 310 310 311 + spin_lock_bh(&msk->pm.lock); 311 312 match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val); 312 313 if (!match) { 313 314 GENL_SET_ERR_MSG(info, "address with specified id not found"); 315 + spin_unlock_bh(&msk->pm.lock); 314 316 release_sock(sk); 315 317 goto out; 316 318 } 317 319 318 320 list_move(&match->list, &free_list); 321 + spin_unlock_bh(&msk->pm.lock); 319 322 320 323 mptcp_pm_remove_addrs(msk, &free_list); 321 324 ··· 563 560 struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; 564 561 struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; 565 562 struct net *net = sock_net(skb->sk); 563 + struct mptcp_pm_addr_entry *entry; 566 564 struct mptcp_sock *msk; 567 565 int ret = -EINVAL; 568 566 struct sock *sk; ··· 604 600 605 601 if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP) 606 602 bkup = 1; 603 + 604 + spin_lock_bh(&msk->pm.lock); 605 + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { 606 + if (mptcp_addresses_equal(&entry->addr, &loc.addr, false)) { 607 + if (bkup) 608 + entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP; 609 + else 610 + entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP; 611 + } 612 + } 613 + spin_unlock_bh(&msk->pm.lock); 607 614 608 615 lock_sock(sk); 609 616 ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup);