All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-next 1/2] mptcp: pm: fix use-after-free in mptcp_userspace_pm_delete_local_addr
@ 2026-05-09  7:56 Tao Cui
  2026-05-09  7:56 ` [PATCH mptcp-next 2/2] mptcp: pm: fix extra_subflows u8 underflow in userspace PM Tao Cui
  2026-05-14  3:07 ` [PATCH mptcp-next 1/2] mptcp: pm: fix use-after-free in mptcp_userspace_pm_delete_local_addr Geliang Tang
  0 siblings, 2 replies; 6+ messages in thread
From: Tao Cui @ 2026-05-09  7:56 UTC (permalink / raw)
  To: matttbe, martineau, geliang, davem, edumazet, kuba, pabeni
  Cc: horms, mptcp, Tao Cui

mptcp_userspace_pm_delete_local_addr() calls list_del_rcu() followed
immediately by sock_kfree_s(), which frees the entry synchronously
without waiting for an RCU grace period.  A concurrent RCU read-side
lookup (e.g. via mptcp_userspace_pm_get_local_id) could still be
accessing the freed entry.

Fix it by replacing sock_kfree_s() with kfree_rcu_mightsleep() and
adjusting sk_omem_alloc manually, matching the pattern already used
in mptcp_pm_nl_remove_doit() in the same file.

Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
 net/mptcp/pm_userspace.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 8cbc1920afb4..586e19e9b913 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -109,7 +109,11 @@ static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk,
 	 * be used multiple times (e.g. fullmesh mode).
 	 */
 	list_del_rcu(&entry->list);
-	sock_kfree_s(sk, entry, sizeof(*entry));
+	kfree_rcu_mightsleep(entry);
+	/* Adjust sk_omem_alloc like sock_kfree_s() does, to match
+	 * with allocation of this memory by sock_kmemdup()
+	 */
+	atomic_sub(sizeof(*entry), &sk->sk_omem_alloc);
 	msk->pm.local_addr_used--;
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-15  2:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-09  7:56 [PATCH mptcp-next 1/2] mptcp: pm: fix use-after-free in mptcp_userspace_pm_delete_local_addr Tao Cui
2026-05-09  7:56 ` [PATCH mptcp-next 2/2] mptcp: pm: fix extra_subflows u8 underflow in userspace PM Tao Cui
2026-05-09 12:04   ` MPTCP CI
2026-05-14  3:17   ` Geliang Tang
2026-05-14  3:07 ` [PATCH mptcp-next 1/2] mptcp: pm: fix use-after-free in mptcp_userspace_pm_delete_local_addr Geliang Tang
2026-05-15  2:46   ` Matthieu Baerts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.