Skip to content

Commit 4190999

Browse files
committed
mptcp: pm: Defer freeing of MPTCP userspace path manager entries
JIRA: https://issues.redhat.com/browse/RHEL-115576 Upstream Status: net-next.git commit 13b4ece commit 13b4ece Author: Mat Martineau <martineau@kernel.org> Date: Mon Apr 21 19:07:13 2025 +0200 mptcp: pm: Defer freeing of MPTCP userspace path manager entries When path manager entries are deleted from the local address list, they are first unlinked from the address list using list_del_rcu(). The entries must not be freed until after the RCU grace period, but the existing code immediately frees the entry. Use kfree_rcu_mightsleep() and adjust sk_omem_alloc in open code instead of using the sock_kfree_s() helper. This code path is only called in a netlink handler, so the "might sleep" function is preferable to adding a rarely-used rcu_head member to struct mptcp_pm_addr_entry. Fixes: 88d0973 ("mptcp: drop free_list for deleting entries") Cc: stable@vger.kernel.org Signed-off-by: Mat Martineau <martineau@kernel.org> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20250421-net-mptcp-pm-defer-freeing-v1-1-e731dc6e86b9@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
1 parent 8d93d59 commit 4190999

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/mptcp/pm_userspace.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
338338

339339
release_sock(sk);
340340

341-
sock_kfree_s(sk, match, sizeof(*match));
341+
kfree_rcu_mightsleep(match);
342+
/* Adjust sk_omem_alloc like sock_kfree_s() does, to match
343+
* with allocation of this memory by sock_kmemdup()
344+
*/
345+
atomic_sub(sizeof(*match), &sk->sk_omem_alloc);
342346

343347
err = 0;
344348
out:

0 commit comments

Comments
 (0)