* [PATCH v2 net] mptcp: fix race in mptcp_pm_nl_flush_addrs_doit()
@ 2026-01-23 3:03 Eric Dumazet
2026-01-23 21:43 ` Mat Martineau
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2026-01-23 3:03 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Matthieu Baerts, Mat Martineau, Geliang Tang,
Florian Westphal, netdev, mptcp, eric.dumazet, Eric Dumazet,
syzbot+5498a510ff9de39d37da, Eulgyu Kim, Geliang Tang
syzbot and Eulgyu Kim reported crashes in mptcp_pm_nl_get_local_id()
and/or mptcp_pm_nl_is_backup()
Root cause is list_splice_init() in mptcp_pm_nl_flush_addrs_doit()
which is not RCU ready.
list_splice_init_rcu() can not be called here while holding pernet->lock
spinlock.
Many thanks to Eulgyu Kim for providing a repro and testing our patches.
Fixes: 141694df6573 ("mptcp: remove address when netlink flushes addrs")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot+5498a510ff9de39d37da@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/6970a46d.a00a0220.3ad28e.5cf0.GAE@google.com/T/
Reported-by: Eulgyu Kim <eulgyukim@snu.ac.kr>
Cc: Geliang Tang <geliang@kernel.org>
---
v2: Make sure the list was not empty, return early otherwise.
v1: https://lore.kernel.org/netdev/20260122131306.2119853-1-edumazet@google.com/
net/mptcp/pm_kernel.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index 57570a44e4185370f531047fe97ce9f9fbd1480b..af23be6658ded4860133bb9495c7738014815d28 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -1294,16 +1294,28 @@ static void __reset_counters(struct pm_nl_pernet *pernet)
int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info)
{
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
- LIST_HEAD(free_list);
+ struct list_head free_list;
spin_lock_bh(&pernet->lock);
- list_splice_init(&pernet->endp_list, &free_list);
+
+ free_list = pernet->endp_list;
+ INIT_LIST_HEAD_RCU(&pernet->endp_list);
+
__reset_counters(pernet);
pernet->next_id = 1;
bitmap_zero(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
spin_unlock_bh(&pernet->lock);
- mptcp_nl_flush_addrs_list(sock_net(skb->sk), &free_list);
+
+ if (free_list.next == &pernet->endp_list)
+ return 0;
+
synchronize_rcu();
+
+ /* Adjust the pointers to free_list instead of pernet->endp_list */
+ free_list.prev->next = &free_list;
+ free_list.next->prev = &free_list;
+
+ mptcp_nl_flush_addrs_list(sock_net(skb->sk), &free_list);
__flush_addrs(&free_list);
return 0;
}
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net] mptcp: fix race in mptcp_pm_nl_flush_addrs_doit()
2026-01-23 3:03 [PATCH v2 net] mptcp: fix race in mptcp_pm_nl_flush_addrs_doit() Eric Dumazet
@ 2026-01-23 21:43 ` Mat Martineau
2026-01-24 11:17 ` Matthieu Baerts
0 siblings, 1 reply; 3+ messages in thread
From: Mat Martineau @ 2026-01-23 21:43 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Matthieu Baerts, Geliang Tang, Florian Westphal, netdev, mptcp,
eric.dumazet, syzbot+5498a510ff9de39d37da, Eulgyu Kim,
Geliang Tang
On Fri, 23 Jan 2026, Eric Dumazet wrote:
> syzbot and Eulgyu Kim reported crashes in mptcp_pm_nl_get_local_id()
> and/or mptcp_pm_nl_is_backup()
>
> Root cause is list_splice_init() in mptcp_pm_nl_flush_addrs_doit()
> which is not RCU ready.
>
> list_splice_init_rcu() can not be called here while holding pernet->lock
> spinlock.
>
> Many thanks to Eulgyu Kim for providing a repro and testing our patches.
>
> Fixes: 141694df6573 ("mptcp: remove address when netlink flushes addrs")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: syzbot+5498a510ff9de39d37da@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/all/6970a46d.a00a0220.3ad28e.5cf0.GAE@google.com/T/
> Reported-by: Eulgyu Kim <eulgyukim@snu.ac.kr>
> Cc: Geliang Tang <geliang@kernel.org>
> ---
> v2: Make sure the list was not empty, return early otherwise.
Thanks Eric, the v2 code changes LGTM. The netdev tooling wasn't able to
apply the patch
(https://patchwork.kernel.org/project/netdevbpf/patch/20260123030327.3041148-1-edumazet@google.com/),
so Matthieu is planning to send a basically-identical v3 that 'git am' and
the netdev CI will be happy with.
Reviewed-by: Mat Martineau <martineau@kernel.org>
> v1: https://lore.kernel.org/netdev/20260122131306.2119853-1-edumazet@google.com/
>
> net/mptcp/pm_kernel.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
> index 57570a44e4185370f531047fe97ce9f9fbd1480b..af23be6658ded4860133bb9495c7738014815d28 100644
> --- a/net/mptcp/pm_kernel.c
> +++ b/net/mptcp/pm_kernel.c
> @@ -1294,16 +1294,28 @@ static void __reset_counters(struct pm_nl_pernet *pernet)
> int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info)
> {
> struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
> - LIST_HEAD(free_list);
> + struct list_head free_list;
>
> spin_lock_bh(&pernet->lock);
> - list_splice_init(&pernet->endp_list, &free_list);
> +
> + free_list = pernet->endp_list;
> + INIT_LIST_HEAD_RCU(&pernet->endp_list);
> +
> __reset_counters(pernet);
> pernet->next_id = 1;
> bitmap_zero(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
> spin_unlock_bh(&pernet->lock);
> - mptcp_nl_flush_addrs_list(sock_net(skb->sk), &free_list);
> +
> + if (free_list.next == &pernet->endp_list)
> + return 0;
> +
> synchronize_rcu();
> +
> + /* Adjust the pointers to free_list instead of pernet->endp_list */
> + free_list.prev->next = &free_list;
> + free_list.next->prev = &free_list;
> +
> + mptcp_nl_flush_addrs_list(sock_net(skb->sk), &free_list);
> __flush_addrs(&free_list);
> return 0;
> }
> --
> 2.52.0.457.g6b5491de43-goog
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net] mptcp: fix race in mptcp_pm_nl_flush_addrs_doit()
2026-01-23 21:43 ` Mat Martineau
@ 2026-01-24 11:17 ` Matthieu Baerts
0 siblings, 0 replies; 3+ messages in thread
From: Matthieu Baerts @ 2026-01-24 11:17 UTC (permalink / raw)
To: Mat Martineau, Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
Geliang Tang, Florian Westphal, netdev, mptcp, eric.dumazet,
syzbot+5498a510ff9de39d37da, Eulgyu Kim, Geliang Tang
Hi Mat, Eric,
On 23/01/2026 22:43, Mat Martineau wrote:
> On Fri, 23 Jan 2026, Eric Dumazet wrote:
>
>> syzbot and Eulgyu Kim reported crashes in mptcp_pm_nl_get_local_id()
>> and/or mptcp_pm_nl_is_backup()
>>
>> Root cause is list_splice_init() in mptcp_pm_nl_flush_addrs_doit()
>> which is not RCU ready.
>>
>> list_splice_init_rcu() can not be called here while holding pernet->lock
>> spinlock.
>>
>> Many thanks to Eulgyu Kim for providing a repro and testing our patches.
>>
>> Fixes: 141694df6573 ("mptcp: remove address when netlink flushes addrs")
>> Signed-off-by: Eric Dumazet <edumazet@google.com>
>> Reported-by: syzbot+5498a510ff9de39d37da@syzkaller.appspotmail.com
>> Closes: https://lore.kernel.org/
>> all/6970a46d.a00a0220.3ad28e.5cf0.GAE@google.com/T/
>> Reported-by: Eulgyu Kim <eulgyukim@snu.ac.kr>
>> Cc: Geliang Tang <geliang@kernel.org>
>> ---
>> v2: Make sure the list was not empty, return early otherwise.
>
> Thanks Eric, the v2 code changes LGTM.
Thank you for the patch and the review!
> The netdev tooling wasn't able to
> apply the patch (https://patchwork.kernel.org/project/netdevbpf/
> patch/20260123030327.3041148-1-edumazet@google.com/), so Matthieu is
> planning to send a basically-identical v3 that 'git am' and the netdev
> CI will be happy with.
Just did:
https://lore.kernel.org/20260124-net-mptcp-race_nl_flush_addrs-v3-1-b2dc1b613e9d@kernel.org
I guess we need to manually update Patchwork if the sender is different:
pw-bot: superseded
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-24 11:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 3:03 [PATCH v2 net] mptcp: fix race in mptcp_pm_nl_flush_addrs_doit() Eric Dumazet
2026-01-23 21:43 ` Mat Martineau
2026-01-24 11:17 ` Matthieu Baerts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox