public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <martineau@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>, Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Matthieu Baerts <matttbe@kernel.org>,
	 Geliang Tang <geliang.tang@linux.dev>,
	Florian Westphal <fw@strlen.de>,
	 netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 syzbot+5498a510ff9de39d37da@syzkaller.appspotmail.com,
	 Eulgyu Kim <eulgyukim@snu.ac.kr>,
	Geliang Tang <geliang@kernel.org>
Subject: Re: [PATCH net] mptcp: fix race in mptcp_pm_nl_flush_addrs_doit()
Date: Thu, 22 Jan 2026 17:31:49 -0800 (PST)	[thread overview]
Message-ID: <681f0f86-fa46-ced3-71c5-f489b67b7fbb@kernel.org> (raw)
In-Reply-To: <6fdf2b6c-2c92-4b74-b746-6c68ed7cdf59@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3412 bytes --]

On Thu, 22 Jan 2026, Paolo Abeni wrote:

> On 1/22/26 2:54 PM, Eric Dumazet wrote:
>> On Thu, Jan 22, 2026 at 2:13 PM Eric Dumazet <edumazet@google.com> 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>
>>> ---
>>>  net/mptcp/pm_kernel.c | 14 +++++++++++---
>>>  1 file changed, 11 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
>>> index 57570a44e4185370f531047fe97ce9f9fbd1480b..1a97d0eafa2b0c9e4275b90d4a576f837dc286a9 100644
>>> --- a/net/mptcp/pm_kernel.c
>>> +++ b/net/mptcp/pm_kernel.c
>>> @@ -1294,16 +1294,24 @@ 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);
>>>         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;
>>
>>
>> We have to test if the list was empty, and avoid the synchronize_rcu
>> in this case.
>>
>> I will squash in V2, unless someone complains.
>>
>> diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
>> index 1a97d0eafa2b0c9e4275b90d4a576f837dc286a9..af23be6658ded4860133bb9495c7738014815d28
>> 100644
>> --- a/net/mptcp/pm_kernel.c
>> +++ b/net/mptcp/pm_kernel.c
>> @@ -1305,6 +1305,10 @@ int mptcp_pm_nl_flush_addrs_doit(struct sk_buff
>> *skb, struct genl_info *info)
>>         pernet->next_id = 1;
>>         bitmap_zero(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
>>         spin_unlock_bh(&pernet->lock);
>> +
>> +       if (free_list.next == &pernet->endp_list)
>> +               return 0;
>> +
>>         synchronize_rcu();
>>
>>         /* Adjust the pointers to free_list instead of pernet->endp_list */
>>
>
> LGTM, thanks Eric!

Likewise, I think the patch (plus squash) is good, no complaints. I'll 
watch for v2.

>
> Side note: I think is very busy elsewhere and this could go directly via
> the net tree.

I agree, straight to the net tree would be best in this case.


Thanks Eric and Paolo,


- Mat

  reply	other threads:[~2026-01-23  1:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-22 13:13 [PATCH net] mptcp: fix race in mptcp_pm_nl_flush_addrs_doit() Eric Dumazet
2026-01-22 13:54 ` Eric Dumazet
2026-01-22 14:49   ` Paolo Abeni
2026-01-23  1:31     ` Mat Martineau [this message]
2026-01-23  2:59       ` Eric Dumazet
2026-01-22 21:06 ` [syzbot ci] " syzbot ci

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=681f0f86-fa46-ced3-71c5-f489b67b7fbb@kernel.org \
    --to=martineau@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=eulgyukim@snu.ac.kr \
    --cc=fw@strlen.de \
    --cc=geliang.tang@linux.dev \
    --cc=geliang@kernel.org \
    --cc=kuba@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+5498a510ff9de39d37da@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox