Skip to contentSkip to conversation

mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint

PATCH Superseded Kalpan Jani 3 participants 12 messages May 29 – Jul 8

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint

syzkaller hit the WARN_ON_ONCE() in mptcp_pm_alloc_anno_list() with the in-kernel path manager.

When a signal endpoint is removed, the pending ADD_ADDR has to be
cancelled: its retransmit timer stopped and the anno_list entry unlinked and freed. For a non-zero id endpoint this is done via mptcp_nl_remove_subflow_and_signal_addr() -> mptcp_pm_remove_anno_addr() -> mptcp_remove_anno_list_by_saddr().

The id 0 removal path, mptcp_nl_remove_id_zero_address(), does not do
this: it only queues a RM_ADDR and marks the id available again, but leaves any pending anno_list entry and its armed retransmit timer alive.

So when the id 0 endpoint is removed and re-added while its previously sent ADD_ADDR is still awaiting the echo, the stale entry survives. The kernel PM reselects id 0, reaches mptcp_pm_alloc_anno_list() a second time, finds the stale entry and hits the WARN.

Make the id 0 removal path symmetric with the non-zero one: drop the pending ADD_ADDR before queuing the RM_ADDR, and decrement add_addr_signaled if the address had been announced. This closes the race at its source, so the WARN_ON_ONCE() stays a valid assertion.

Fixes 740d798e8767 ("mptcp: remove id 0 address")
Reported-by [email protected]

---

v1 -> v2:
- Do not drop the WARN_ON_ONCE(); it is a valid assertion. (Matthieu Baerts)
- Fix mptcp_nl_remove_id_zero_address() to tear down the pending ADD_ADDR entry: call mptcp_remove_anno_list_by_saddr() and decrement add_addr_signaled, mirroring the non-zero id path. (Matthieu Baerts)

 net/mptcp/pm_kernel.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
net/mptcp/pm_kernel.c +10 -0
index fc818b63752e..ed0ad1c1b140 100644
@@ -1126,6 +1126,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
 	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
 		struct sock *sk = (struct sock *)msk;
 		struct mptcp_addr_info msk_local;
+		bool announced;
 
 		if (list_empty(&msk->conn_list) || mptcp_pm_is_userspace(msk))
 			goto next;
@@ -1135,7 +1136,16 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
 			goto next;
 
 		lock_sock(sk);
+		/* Drop a possibly pending ADD_ADDR for this address: stop its
+		 * retransmit timer and unlink the anno_list entry, so a later
+		 * re-add cannot find a stale entry and hit the WARN_ON_ONCE()
+		 * in mptcp_pm_alloc_anno_list(). Mirrors the non-zero id path
+		 * in mptcp_pm_remove_anno_addr().
+		 */
+		announced = mptcp_remove_anno_list_by_saddr(msk, &msk_local);
 		spin_lock_bh(&msk->pm.lock);
+		if (announced)
+			msk->pm.add_addr_signaled--;
 		mptcp_pm_remove_addr(msk, &list);
 		mptcp_pm_rm_subflow(msk, &list);
 		__mark_subflow_endp_available(msk, 0);
Signature · 1 line
2.43.0
maintainer
#1 lore raw

Hi Kalpan,

Thank you for the v2.

29 May 2026 16:44:12 Kalpan Jani <[email protected]>:

Quoted 54 lines

syzkaller hit the WARN_ON_ONCE() in mptcp_pm_alloc_anno_list() with the in-kernel path manager.

When a signal endpoint is removed, the pending ADD_ADDR has to be
cancelled: its retransmit timer stopped and the anno_list entry unlinked and freed. For a non-zero id endpoint this is done via mptcp_nl_remove_subflow_and_signal_addr() -> mptcp_pm_remove_anno_addr() -> mptcp_remove_anno_list_by_saddr().

The id 0 removal path, mptcp_nl_remove_id_zero_address(), does not do
this: it only queues a RM_ADDR and marks the id available again, but leaves any pending anno_list entry and its armed retransmit timer alive.

So when the id 0 endpoint is removed and re-added while its previously sent ADD_ADDR is still awaiting the echo, the stale entry survives. The kernel PM reselects id 0, reaches mptcp_pm_alloc_anno_list() a second time, finds the stale entry and hits the WARN.

Make the id 0 removal path symmetric with the non-zero one: drop the pending ADD_ADDR before queuing the RM_ADDR, and decrement add_addr_signaled if the address had been announced. This closes the race at its source, so the WARN_ON_ONCE() stays a valid assertion.

Fixes 740d798e8767 ("mptcp: remove id 0 address")
Reported-by [email protected]

---

v1 -> v2:
- Do not drop the WARN_ON_ONCE(); it is a valid assertion. (Matthieu Baerts)
- Fix mptcp_nl_remove_id_zero_address() to tear down the pending ADD_ADDR entry: call mptcp_remove_anno_list_by_saddr() and decrement add_addr_signaled, mirroring the non-zero id path. (Matthieu Baerts)

net/mptcp/pm_kernel.c | 10 ++++++++++

1 file changed, 10 insertions(+)
net/mptcp/pm_kernel.c +1 -0
index fc818b63752e..ed0ad1c1b140 100644
@@ -1126,6 +1126,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
     while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
         struct sock *sk = (struct sock *)msk;
         struct mptcp_addr_info msk_local;
+       bool announced;
 
         if (list_empty(&msk->conn_list) || mptcp_pm_is_userspace(msk))
             goto next;

net/mptcp/pm_kernel.c static int mptcp_nl_remove_id_zero_address(struct net *net, · line 1144

Quoted 9 lines
net/mptcp/pm_kernel.c +6 -0
@@ -1135,7 +1136,16 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
             goto next;
 
         lock_sock(sk);
+       /* Drop a possibly pending ADD_ADDR for this address: stop its
+        * retransmit timer and unlink the anno_list entry, so a later
+        * re-add cannot find a stale entry and hit the WARN_ON_ONCE()
+        * in mptcp_pm_alloc_anno_list(). Mirrors the non-zero id path
+        * in mptcp_pm_remove_anno_addr().
+        */

I'm not sure such a long comment in the code is that useful, and it
might: it can quickly become outdated when other parts are modified. Limit it to the first line, the rest can be seen in the commit message.

net/mptcp/pm_kernel.c static int mptcp_nl_remove_id_zero_address(struct net *net, · line 1148

Quoted 4 lines
net/mptcp/pm_kernel.c +3 -0
+       announced = mptcp_remove_anno_list_by_saddr(msk, &msk_local);
         spin_lock_bh(&msk->pm.lock);
+       if (announced)
+           msk->pm.add_addr_signaled--;

It would be good to check this counter on the test/reproducer you will provide. Did it work with packetdrill?

Cheers,
Matt

Quoted 5 lines
net/mptcp/pm_kernel.c +0 -1
         mptcp_pm_remove_addr(msk, &list);
         mptcp_pm_rm_subflow(msk, &list);
         __mark_subflow_endp_available(msk, 0);
--

2.43.0

#2 lore raw

Hi Matt,

Quoted 1 line

Did it work with packetdrill?

I worked on a packetdrill test based on add_addr4_server.pkt with the MP_JOIN extra subflow and the delete/re-add sequence. The environment is working (add_addr4_server.pkt passes cleanly), but I was not able to reliably trigger the WARN through packetdrill within the test timeframe.

The difficulty is that the id 0 ADD_ADDR is only sent when the endpoint is re-added after the connection is established AND after mptcp_nl_remove_id_zero_address() has run to restore the id_avail_bitmap bit via __mark_subflow_endp_available(). Getting packetdrill to control this timing precisely — while also keeping conn_list non-empty so mptcp_nl_remove_id_zero_address() actually processes the msk — proved tricky.

syzbot is reproducing the bug reliably on current upstream (3 crashes between 2026/05/19 and 2026/05/22 on kernels including cca95436be15). The syzbot reproducer is the most reliable pre-fix evidence available.

I will continue working on the packetdrill test and send it as a follow-up once I have a clean before/after result. For v3 I have addressed your comment shortening request.

Thanks,
Kalpan Jani

From: Matthieu Baerts <[email protected]>
To: "Kalpan Jani"<[email protected]>
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Date: Fri, 29 May 2026 12:25:09 +0530
Subject: Re: [PATCH net v2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint

Quoted 92 lines

Hi Kalpan,

Thank you for the v2.

29 May 2026 16:44:12 Kalpan Jani <[email protected]>:

Quoted 54 lines

syzkaller hit the WARN_ON_ONCE() in mptcp_pm_alloc_anno_list() with the in-kernel path manager.

When a signal endpoint is removed, the pending ADD_ADDR has to be
cancelled: its retransmit timer stopped and the anno_list entry unlinked and freed. For a non-zero id endpoint this is done via mptcp_nl_remove_subflow_and_signal_addr() -> mptcp_pm_remove_anno_addr() -> mptcp_remove_anno_list_by_saddr().

The id 0 removal path, mptcp_nl_remove_id_zero_address(), does not do
this: it only queues a RM_ADDR and marks the id available again, but leaves any pending anno_list entry and its armed retransmit timer alive.

So when the id 0 endpoint is removed and re-added while its previously sent ADD_ADDR is still awaiting the echo, the stale entry survives. The kernel PM reselects id 0, reaches mptcp_pm_alloc_anno_list() a second time, finds the stale entry and hits the WARN.

Make the id 0 removal path symmetric with the non-zero one: drop the pending ADD_ADDR before queuing the RM_ADDR, and decrement add_addr_signaled if the address had been announced. This closes the race at its source, so the WARN_ON_ONCE() stays a valid assertion.

Fixes 740d798e8767 ("mptcp: remove id 0 address")
Reported-by [email protected]

---

v1 -> v2:
- Do not drop the WARN_ON_ONCE(); it is a valid assertion. (Matthieu Baerts)
- Fix mptcp_nl_remove_id_zero_address() to tear down the pending ADD_ADDR entry: call mptcp_remove_anno_list_by_saddr() and decrement add_addr_signaled, mirroring the non-zero id path. (Matthieu Baerts)

net/mptcp/pm_kernel.c | 10 ++++++++++

1 file changed, 10 insertions(+)
net/mptcp/pm_kernel.c +1 -0
index fc818b63752e..ed0ad1c1b140 100644
@@ -1126,6 +1126,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
    while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
        struct sock *sk = (struct sock *)msk;
        struct mptcp_addr_info msk_local;
+       bool announced;
 
        if (list_empty(&msk->conn_list) || mptcp_pm_is_userspace(msk))
            goto next;

net/mptcp/pm_kernel.c static int mptcp_nl_remove_id_zero_address(struct net *net, · line 1144

Quoted 9 lines
net/mptcp/pm_kernel.c +6 -0
@@ -1135,7 +1136,16 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
            goto next;
 
        lock_sock(sk);
+       /* Drop a possibly pending ADD_ADDR for this address: stop its
+        * retransmit timer and unlink the anno_list entry, so a later
+        * re-add cannot find a stale entry and hit the WARN_ON_ONCE()
+        * in mptcp_pm_alloc_anno_list(). Mirrors the non-zero id path
+        * in mptcp_pm_remove_anno_addr().
+        */

I'm not sure such a long comment in the code is that useful, and it
might: it can quickly become outdated when other parts are modified. Limit it to the first line, the rest can be seen in the commit message.

net/mptcp/pm_kernel.c static int mptcp_nl_remove_id_zero_address(struct net *net, · line 1148

Quoted 4 lines
net/mptcp/pm_kernel.c +3 -0
+       announced = mptcp_remove_anno_list_by_saddr(msk, &msk_local);
        spin_lock_bh(&msk->pm.lock);
+       if (announced)
+           msk->pm.add_addr_signaled--;

It would be good to check this counter on the test/reproducer you will provide. Did it work with packetdrill?

Cheers,
Matt

Quoted 5 lines
net/mptcp/pm_kernel.c +0 -1
        mptcp_pm_remove_addr(msk, &list);
        mptcp_pm_rm_subflow(msk, &list);
        __mark_subflow_endp_available(msk, 0);
--

2.43.0

maintainer
#3 lore raw

Hi Kalpan,

Quoted 10 lines · Kalpan Jani

Hi Matt,

Quoted 1 line

Did it work with packetdrill?

I worked on a packetdrill test based on add_addr4_server.pkt with the MP_JOIN extra subflow and the delete/re-add sequence. The environment is working (add_addr4_server.pkt passes cleanly), but I was not able to reliably trigger the WARN through packetdrill within the test timeframe.

Quoted 7 lines

The difficulty is that the id 0 ADD_ADDR is only sent when the endpoint is re-added after the connection is established AND after mptcp_nl_remove_id_zero_address() has run to restore the id_avail_bitmap bit via __mark_subflow_endp_available(). Getting packetdrill to control this timing precisely — while also keeping conn_list non-empty so mptcp_nl_remove_id_zero_address() actually processes the msk — proved tricky.

I understand it might be tricky, but do you mind sharing what you have so far. Maybe someone else can help you to reproduce the issue. Also, it might be enough to have a test that can reproduce the WARN not 100% of the time, as long as it is not 0. I will wait for this test before applying the v3.

At least having something exercising new paths: here, having the new call to mptcp_remove_anno_list_by_saddr() returning true.

Quoted 3 lines

syzbot is reproducing the bug reliably on current upstream (3 crashes between 2026/05/19 and 2026/05/22 on kernels including cca95436be15). The syzbot reproducer is the most reliable pre-fix evidence available.

Because syzbot didn't manage to generate a reproducer, we cannot really rely on syzbot to say that the bug is fixed. 3 crashes out of how many thousands/millions attempts? :)

Quoted 3 lines

I will continue working on the packetdrill test and send it as a follow-up once I have a clean before/after result. For v3 I have addressed your comment shortening request.

Thanks!

Do not forget to wait ~1 day between submissions, otherwise it is even harder for reviewers and various tools to follow the modifications and discussions.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#4 lore raw

Hi Matt,

Quoted 2 lines

do you mind sharing what you have so far. Maybe someone else can help you to reproduce the issue.

Attached is the WIP packetdrill test (server side, based on the existing add_addr/mp_join server tests, with an extra MP_JOIN subflow). I have not been able to reproduce the WARN with it yet, so please treat it as a work-in-progress rather than a finished test -- the status and the open question are written at the top of the file.

The trigger is "ip mptcp endpoint delete id 0 <saddr>", which is the only op that reaches mptcp_nl_remove_id_zero_address(). (flush is not usable: it goes through mptcp_pm_flush_addrs_and_subflows(), which already calls mptcp_pm_announced_remove(), so that path was never buggy.)

Where I am stuck is getting ADD_ADDR(id 0) announced in the first place. The signal endpoint on the MPC address has its id bit cleared by mptcp_mpc_endpoint_setup(), so it is not announced on connect. "delete id 0" frees the bit again, but I could not confirm that the PM worker re-runs and announces id 0 on an otherwise idle connection. Without that announcement no pending anno_list entry is created, so the second "delete id 0" has nothing stale to leave behind and the WARN does not trigger.

So my question: what is the minimal way to get the id-0 address actually announced via packetdrill? Does this need the MP_JOIN subflow and/or a data exchange to wake the PM worker between the operations, or is there a simpler approach I am missing?

Quoted 1 line

I will wait for this test before applying the v3.

Understood, I will keep working on it. One thing I wanted to ask directly:
is a deterministic packetdrill test a hard requirement for applying v3, or could the fix go in on the reasoning + the syzbot report alone? The change only makes the id-0 removal path symmetric with the non-zero id path (tear down the pending ADD_ADDR and decrement add_addr_signaled), so it is fairly contained and independent of whether I can script a reliable trigger.

(Note: the anno-list helpers were renamed in current export, so v3 no longer applies as-is; I can send a trivially rebased v4 that swaps mptcp_remove_anno_list_by_saddr() for mptcp_pm_announced_remove() if useful.)

Cheers,
Kalpan Jani

From: Matthieu Baerts <[email protected]>
To: "Kalpan Jani"<[email protected]>
Cc: "mptcp"<[email protected]>, "martineau"<[email protected]>, "pabeni"<[email protected]>, "shardul.b"<[email protected]>, "janak"<[email protected]>, "kalpanjani009"<[email protected]>, "shardulsb08"<[email protected]>, "syzbot+55c2a5c871441261ed14"<[email protected]>
Date: Sun, 31 May 2026 12:09:53 +0530
Subject: Re: [PATCH net v2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint

Quoted 54 lines

Hi Kalpan,

Quoted 10 lines · Kalpan Jani

Hi Matt,

Quoted 1 line

Did it work with packetdrill?

I worked on a packetdrill test based on add_addr4_server.pkt with the MP_JOIN extra subflow and the delete/re-add sequence. The environment is working (add_addr4_server.pkt passes cleanly), but I was not able to reliably trigger the WARN through packetdrill within the test timeframe.

Quoted 7 lines

The difficulty is that the id 0 ADD_ADDR is only sent when the endpoint is re-added after the connection is established AND after mptcp_nl_remove_id_zero_address() has run to restore the id_avail_bitmap bit via __mark_subflow_endp_available(). Getting packetdrill to control this timing precisely — while also keeping conn_list non-empty so mptcp_nl_remove_id_zero_address() actually processes the msk — proved tricky.

I understand it might be tricky, but do you mind sharing what you have so far. Maybe someone else can help you to reproduce the issue. Also, it might be enough to have a test that can reproduce the WARN not 100% of the time, as long as it is not 0. I will wait for this test before applying the v3.

At least having something exercising new paths: here, having the new call to mptcp_remove_anno_list_by_saddr() returning true.

Quoted 3 lines

syzbot is reproducing the bug reliably on current upstream (3 crashes between 2026/05/19 and 2026/05/22 on kernels including cca95436be15). The syzbot reproducer is the most reliable pre-fix evidence available.

Because syzbot didn't manage to generate a reproducer, we cannot really rely on syzbot to say that the bug is fixed. 3 crashes out of how many thousands/millions attempts? :)

Quoted 3 lines

I will continue working on the packetdrill test and send it as a follow-up once I have a clean before/after result. For v3 I have addressed your comment shortening request.

Thanks!

Do not forget to wait ~1 day between submissions, otherwise it is even harder for reviewers and various tools to follow the modifications and discussions.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#5 lore raw

Hi Kalpan,

Sorry for the delay.

Quoted 22 lines · Kalpan Jani
Quoted 2 lines

do you mind sharing what you have so far. Maybe someone else can help you to reproduce the issue.

Attached is the WIP packetdrill test (server side, based on the existing add_addr/mp_join server tests, with an extra MP_JOIN subflow). I have not been able to reproduce the WARN with it yet, so please treat it as a work-in-progress rather than a finished test -- the status and the open question are written at the top of the file.

The trigger is "ip mptcp endpoint delete id 0 <saddr>", which is the only op that reaches mptcp_nl_remove_id_zero_address(). (flush is not usable: it goes through mptcp_pm_flush_addrs_and_subflows(), which already calls mptcp_pm_announced_remove(), so that path was never buggy.)

Where I am stuck is getting ADD_ADDR(id 0) announced in the first place. The signal endpoint on the MPC address has its id bit cleared by mptcp_mpc_endpoint_setup(), so it is not announced on connect. "delete id 0" frees the bit again, but I could not confirm that the PM worker re-runs and announces id 0 on an otherwise idle connection. Without that announcement no pending anno_list entry is created, so the second "delete id 0" has nothing stale to leave behind and the WARN does not trigger.

Quoted 4 lines

So my question: what is the minimal way to get the id-0 address actually announced via packetdrill? Does this need the MP_JOIN subflow and/or a data exchange to wake the PM worker between the operations, or is there a simpler approach I am missing?

With the in-kernel PM, I think you need to:

- create a subflow using a second local IP address (maybe optional): use multi-ep.sh (or add an IP address and inject a SYN+MPJ)

- remove the endpoint linked to the initial subflow: ip mptcp endp del

- re-create the same endpoint: ip mptcp endp add (or adapt multi-ep.sh to avoid the flush)

That's what the mptcp_join.sh's "delete re-add signal" subtest does if I remember well.

Quoted 8 lines
Quoted 1 line

I will wait for this test before applying the v3.

Understood, I will keep working on it. One thing I wanted to ask directly:
is a deterministic packetdrill test a hard requirement for applying v3, or could the fix go in on the reasoning + the syzbot report alone? The change only makes the id-0 removal path symmetric with the non-zero id path (tear down the pending ADD_ADDR and decrement add_addr_signaled), so it is fairly contained and independent of whether I can script a reliable trigger.

Having a reproducer (packetdrill, selftests, syzbot repro) are not just added to avoid having the same issue later on, but it also helps the reviewers to understand what is being fixed. Here, we don't have a syzbot reproducer, so I think it is even more important to prove that something is being fixed here: maybe syzbot found another path, and having such test here would really help for later to exercise one "known path".

Quoted 3 lines

(Note: the anno-list helpers were renamed in current export, so v3 no longer applies as-is; I can send a trivially rebased v4 that swaps mptcp_remove_anno_list_by_saddr() for mptcp_pm_announced_remove() if useful.)

I see that you sent a v5 for this. I guess you did the rebase, and you added a reproducer in the selftest. It should be enough for now. But here, I would like to get your feedback if you don't mind: now that you have a clearer view on what needed to be tested, do you think there was/is a blocking point to get such validation in packetdrill? I do think Packetdrill tests are often better in terms of maintenance, clarity, and execution time to reproduce exactly what is needed (not just with MPTCP), so I think it is important to make sure this tool is still adapted, and understood by multiple people.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#6 lore raw

Hi Matt,

Thank you for the clear question — here is my honest assessment.

The blocking point for a packetdrill test of this specific bug is that the trigger sequence requires the kernel PM worker to run between a "del id 0" and a second signal endpoint add, and packetdrill's shell-escape timing is coarser than what reliably controls that window.

More specifically, the reproducer needs:

1. A fully-established MPTCP connection.
2. A second subflow via MP_JOIN (to keep the connection alive across the id 0 removal) — this part packetdrill handles well, as shown in mp_join_server.pkt.
3. An ADD_ADDR for the id-0 address already in flight with the echo withheld — also doable: just don't send the echo packet.
4. ip mptcp endpoint delete id 0 <addr> via a shell escape — packetdrill supports this.
5. ip mptcp endpoint add <addr> flags signal to force PM reselection — also a shell escape.

The difficulty is between steps 3 and 4: the ADD_ADDR for id 0 only gets sent after mptcp_mpc_endpoint_setup() has accounted the MPC endpoint and the PM worker has run. In the mptcp_join.sh reproducer this is handled by waiting for the second join (wait_mpj) and checking the add_addr_signal counter before proceeding. In packetdrill, the closest control is expecting the > add_address address_id=0 ... line before issuing the shell escape — and that does work in principle.

Where it gets fragile: after the del+re-add, the PM reselects id 0 and the WARN fires inside the add_addr_doit netlink handler, which is synchronous with the shell-escape command. Packetdrill would then need to expect a second > add_address address_id=0 ... line that a fixed kernel would *not* send (since mptcp_pm_announced_alloc returns false silently). That asymmetry — expecting a packet that a fixed kernel suppresses — means the test structure naturally
inverts: you'd write it to expect *no* retransmission after the del+re-add, which is harder to express cleanly than "this packet must appear". The mptcp_join.sh counter check (add_addr_signal going from 2 to 1 after the del) is a more direct assertion.

That said, I think a packetdrill test *is* achievable if it's structured around the ADD_ADDR retransmit that fires on an unfixed kernel after the del+re-add: on an unfixed kernel the stale entry triggers a second > add_address address_id=0 packet; a fixed kernel does not send it. So the test would:

- inject the MP_JOIN to create the second subflow;
- see > add_address address_id=0 (the first, legitimate one);
- not send the echo;
- issue ip mptcp endpoint delete id 0 $OPT_LOCAL_IP as a

    shell escape;

- issue ip mptcp endpoint add $OPT_LOCAL_IP flags signal;
- add a ~* line that expects *no* spurious second add_address — which is the opposite of what unfixed kernels produce.

The main uncertainty is whether packetdrill's * (any-packet) handling can cleanly express "this packet must NOT appear within N ms", or whether we'd need a short timeout + close to flush the pipe. That's the part I haven't mastered yet in packetdrill.

If you can point me at an existing test that uses a negative packet assertion (or a timeout to prove absence), I can turn the mptcp_join.sh reproducer into a packetdrill test for the next version. Otherwise I'll send the mptcp_join.sh subtest as patch 2 of v6 (with the addr fix in patch 1), and follow up with a packetdrill test separately once I understand that idiom better.

Cheers,
Kalpan Jani

From: Matthieu Baerts <[email protected]>
To: "Kalpan Jani"<[email protected]>
Cc: "mptcp"<[email protected]>, "martineau"<[email protected]>, "pabeni"<[email protected]>, "shardul.b"<[email protected]>, "janak"<[email protected]>, "kalpanjani009"<[email protected]>, "shardulsb08"<[email protected]>
Date: Mon, 06 Jul 2026 22:16:55 +0530
Subject: Re: [PATCH net v2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint

Quoted 81 lines

Hi Kalpan,

Sorry for the delay.

Quoted 22 lines · Kalpan Jani
Quoted 2 lines

do you mind sharing what you have so far. Maybe someone else can help you to reproduce the issue.

Attached is the WIP packetdrill test (server side, based on the existing add_addr/mp_join server tests, with an extra MP_JOIN subflow). I have not been able to reproduce the WARN with it yet, so please treat it as a work-in-progress rather than a finished test -- the status and the open question are written at the top of the file.

The trigger is "ip mptcp endpoint delete id 0 <saddr>", which is the only op that reaches mptcp_nl_remove_id_zero_address(). (flush is not usable: it goes through mptcp_pm_flush_addrs_and_subflows(), which already calls mptcp_pm_announced_remove(), so that path was never buggy.)

Where I am stuck is getting ADD_ADDR(id 0) announced in the first place. The signal endpoint on the MPC address has its id bit cleared by mptcp_mpc_endpoint_setup(), so it is not announced on connect. "delete id 0" frees the bit again, but I could not confirm that the PM worker re-runs and announces id 0 on an otherwise idle connection. Without that announcement no pending anno_list entry is created, so the second "delete id 0" has nothing stale to leave behind and the WARN does not trigger.

Quoted 4 lines

So my question: what is the minimal way to get the id-0 address actually announced via packetdrill? Does this need the MP_JOIN subflow and/or a data exchange to wake the PM worker between the operations, or is there a simpler approach I am missing?

With the in-kernel PM, I think you need to:

- create a subflow using a second local IP address (maybe optional): use multi-ep.sh (or add an IP address and inject a SYN+MPJ)

- remove the endpoint linked to the initial subflow: ip mptcp endp del

- re-create the same endpoint: ip mptcp endp add (or adapt multi-ep.sh to avoid the flush)

That's what the mptcp_join.sh's "delete re-add signal" subtest does if I remember well.

Quoted 8 lines
Quoted 1 line

I will wait for this test before applying the v3.

Understood, I will keep working on it. One thing I wanted to ask directly:
is a deterministic packetdrill test a hard requirement for applying v3, or could the fix go in on the reasoning + the syzbot report alone? The change only makes the id-0 removal path symmetric with the non-zero id path (tear down the pending ADD_ADDR and decrement add_addr_signaled), so it is fairly contained and independent of whether I can script a reliable trigger.

Having a reproducer (packetdrill, selftests, syzbot repro) are not just added to avoid having the same issue later on, but it also helps the reviewers to understand what is being fixed. Here, we don't have a syzbot reproducer, so I think it is even more important to prove that something is being fixed here: maybe syzbot found another path, and having such test here would really help for later to exercise one "known path".

Quoted 3 lines

(Note: the anno-list helpers were renamed in current export, so v3 no longer applies as-is; I can send a trivially rebased v4 that swaps mptcp_remove_anno_list_by_saddr() for mptcp_pm_announced_remove() if useful.)

I see that you sent a v5 for this. I guess you did the rebase, and you added a reproducer in the selftest. It should be enough for now. But here, I would like to get your feedback if you don't mind: now that you have a clearer view on what needed to be tested, do you think there was/is a blocking point to get such validation in packetdrill? I do think Packetdrill tests are often better in terms of maintenance, clarity, and execution time to reproduce exactly what is needed (not just with MPTCP), so I think it is important to make sure this tool is still adapted, and understood by multiple people.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#7 lore raw

Hi Kalpan,

Thank you for your reply.

Quoted 23 lines · Kalpan Jani

Hi Matt,

Thank you for the clear question — here is my honest assessment.

The blocking point for a packetdrill test of this specific bug is that the trigger sequence requires the kernel PM worker to run between a "del id 0" and a second signal endpoint add, and packetdrill's shell-escape timing is coarser than what reliably controls that window.

More specifically, the reproducer needs:

1. A fully-established MPTCP connection.
2. A second subflow via MP_JOIN (to keep the connection alive across the id 0 removal) — this part packetdrill handles well, as shown in mp_join_server.pkt.
3. An ADD_ADDR for the id-0 address already in flight with the echo withheld — also doable: just don't send the echo packet.
4. ip mptcp endpoint delete id 0 <addr> via a shell escape — packetdrill supports this.
5. ip mptcp endpoint add <addr> flags signal to force PM reselection — also a shell escape.

Quoted 8 lines

The difficulty is between steps 3 and 4: the ADD_ADDR for id 0 only gets sent after mptcp_mpc_endpoint_setup() has accounted the MPC endpoint and the PM worker has run. In the mptcp_join.sh reproducer this is handled by waiting for the second join (wait_mpj) and checking the add_addr_signal counter before proceeding. In packetdrill, the closest control is expecting the > add_address address_id=0 ... line before issuing the shell escape — and that does work in principle.

Note that if needed (but I don't think it is if I understood correctly), you can always call commands or scripts in Packetdrill, e.g. to wait for an internal state to change.

Quoted 11 lines

Where it gets fragile: after the del+re-add, the PM reselects id 0 and the WARN fires inside the add_addr_doit netlink handler, which is synchronous with the shell-escape command. Packetdrill would then need to expect a second > add_address address_id=0 ... line that a fixed kernel would *not* send (since mptcp_pm_announced_alloc returns false silently). That asymmetry — expecting a packet that a fixed kernel suppresses — means the test structure naturally
inverts: you'd write it to expect *no* retransmission after the del+re-add, which is harder to express cleanly than "this packet must appear". The mptcp_join.sh counter check (add_addr_signal going from 2 to 1 after the del) is a more direct assertion.

You can also check ss' status. But here, you can also simply inject another packet after a small delay, and expect an ACK without ADD_ADDR to be sent instead.

Quoted 21 lines

That said, I think a packetdrill test *is* achievable if it's structured around the ADD_ADDR retransmit that fires on an unfixed kernel after the del+re-add: on an unfixed kernel the stale entry triggers a second > add_address address_id=0 packet; a fixed kernel does not send it. So the test would:

- inject the MP_JOIN to create the second subflow;
- see > add_address address_id=0 (the first, legitimate one);
- not send the echo;
- issue ip mptcp endpoint delete id 0 $OPT_LOCAL_IP as a

    shell escape;

- issue ip mptcp endpoint add $OPT_LOCAL_IP flags signal;
- add a ~* line that expects *no* spurious second add_address — which is the opposite of what unfixed kernels produce.

The main uncertainty is whether packetdrill's * (any-packet) handling can cleanly express "this packet must NOT appear within N ms", or whether we'd need a short timeout + close to flush the pipe. That's the part I haven't mastered yet in packetdrill.

Quoted 6 lines

If you can point me at an existing test that uses a negative packet assertion (or a timeout to prove absence), I can turn the mptcp_join.sh reproducer into a packetdrill test for the next version. Otherwise I'll send the mptcp_join.sh subtest as patch 2 of v6 (with the addr fix in patch 1), and follow up with a packetdrill test separately once I understand that idiom better.

I think the easiest is to inject a packet after the timeout to force the kernel to react, e.g. sending a DATA_FIN, data, an out of window packet, etc. Then see that the reaction is the expected one, not a wrong retransmission. I just noticed that's what is done in add_addr_retry_errors.pkt, lines 32-38.

In general, about Packetdrill, I recommend this presentation:

https://netdevconf.info/0x19/sessions/tutorial/tutorial-using-packetdrill-to-write-automated-tests-for-the-linux-networking-stack.html

e.g. on page 15, there are some explanations about timing:

https://netdevconf.info/0x19/docs/netdev-0x19-paper23-talk-slides/packetdrill%20-%20NetDev%202025-03-10.pdf

Back to the series you sent: we could say that the mptcp_join.sh reproducer is enough, but I think it would be useful for you -- and to avoid a new "speed=slow" subtest: mptcp_join.sh's execution is already long enough -- to try a bit more with Packetdrill if that's OK. WDYT?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#8 lore raw

Hi Matt,
Thank you for pointing me to add_addr_retry_errors.pkt — that makes the idiom clear. Inject a data packet after the del+re-add sequence and expect a plain DSS ACK back with no add_address option piggybacked. On an unfixed kernel the stale entry causes a spurious ADD_ADDR(id=0) retransmit to appear on that ACK, which packetdrill catches as an unexpected option. I will write the packetdrill test using that pattern and send v6 with:

Patch 1: kernel fix (also correcting the addr argument — the &anno_addr copy in v5 is fragile for with-port endpoints) Patch 2: packetdrill regression test in gtests/net/mptcp/regressions/

Also noted on the NetDev slides — reading those before drafting the test.

Cheers,
Kalpan Jani

From: Matthieu Baerts <[email protected]>
To: "Kalpan Jani"<[email protected]>
Cc: "mptcp"<[email protected]>, "martineau"<[email protected]>, "pabeni"<[email protected]>, "shardul.b"<[email protected]>, "janak"<[email protected]>, "kalpanjani009"<[email protected]>, "shardulsb08"<[email protected]>
Date: Tue, 07 Jul 2026 16:57:06 +0530
Subject: Re: [PATCH net v2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint

Quoted 112 lines

Hi Kalpan,

Thank you for your reply.

Quoted 23 lines · Kalpan Jani

Hi Matt,

Thank you for the clear question — here is my honest assessment.

The blocking point for a packetdrill test of this specific bug is that the trigger sequence requires the kernel PM worker to run between a "del id 0" and a second signal endpoint add, and packetdrill's shell-escape timing is coarser than what reliably controls that window.

More specifically, the reproducer needs:

1. A fully-established MPTCP connection.
2. A second subflow via MP_JOIN (to keep the connection alive across the id 0 removal) — this part packetdrill handles well, as shown in mp_join_server.pkt.
3. An ADD_ADDR for the id-0 address already in flight with the echo withheld — also doable: just don't send the echo packet.
4. ip mptcp endpoint delete id 0 <addr> via a shell escape — packetdrill supports this.
5. ip mptcp endpoint add <addr> flags signal to force PM reselection — also a shell escape.

Quoted 8 lines

The difficulty is between steps 3 and 4: the ADD_ADDR for id 0 only gets sent after mptcp_mpc_endpoint_setup() has accounted the MPC endpoint and the PM worker has run. In the mptcp_join.sh reproducer this is handled by waiting for the second join (wait_mpj) and checking the add_addr_signal counter before proceeding. In packetdrill, the closest control is expecting the > add_address address_id=0 ... line before issuing the shell escape — and that does work in principle.

Note that if needed (but I don't think it is if I understood correctly), you can always call commands or scripts in Packetdrill, e.g. to wait for an internal state to change.

Quoted 11 lines

Where it gets fragile: after the del+re-add, the PM reselects id 0 and the WARN fires inside the add_addr_doit netlink handler, which is synchronous with the shell-escape command. Packetdrill would then need to expect a second > add_address address_id=0 ... line that a fixed kernel would *not* send (since mptcp_pm_announced_alloc returns false silently). That asymmetry — expecting a packet that a fixed kernel suppresses — means the test structure naturally
inverts: you'd write it to expect *no* retransmission after the del+re-add, which is harder to express cleanly than "this packet must appear". The mptcp_join.sh counter check (add_addr_signal going from 2 to 1 after the del) is a more direct assertion.

You can also check ss' status. But here, you can also simply inject another packet after a small delay, and expect an ACK without ADD_ADDR to be sent instead.

Quoted 21 lines

That said, I think a packetdrill test *is* achievable if it's structured around the ADD_ADDR retransmit that fires on an unfixed kernel after the del+re-add: on an unfixed kernel the stale entry triggers a second > add_address address_id=0 packet; a fixed kernel does not send it. So the test would:

- inject the MP_JOIN to create the second subflow;
- see > add_address address_id=0 (the first, legitimate one);
- not send the echo;
- issue ip mptcp endpoint delete id 0 $OPT_LOCAL_IP as a

    shell escape;

- issue ip mptcp endpoint add $OPT_LOCAL_IP flags signal;
- add a ~* line that expects *no* spurious second add_address — which is the opposite of what unfixed kernels produce.

The main uncertainty is whether packetdrill's * (any-packet) handling can cleanly express "this packet must NOT appear within N ms", or whether we'd need a short timeout + close to flush the pipe. That's the part I haven't mastered yet in packetdrill.

Quoted 6 lines

If you can point me at an existing test that uses a negative packet assertion (or a timeout to prove absence), I can turn the mptcp_join.sh reproducer into a packetdrill test for the next version. Otherwise I'll send the mptcp_join.sh subtest as patch 2 of v6 (with the addr fix in patch 1), and follow up with a packetdrill test separately once I understand that idiom better.

I think the easiest is to inject a packet after the timeout to force the kernel to react, e.g. sending a DATA_FIN, data, an out of window packet, etc. Then see that the reaction is the expected one, not a wrong retransmission. I just noticed that's what is done in add_addr_retry_errors.pkt, lines 32-38.

In general, about Packetdrill, I recommend this presentation:

https://netdevconf.info/0x19/sessions/tutorial/tutorial-using-packetdrill-to-write-automated-tests-for-the-linux-networking-stack.html

e.g. on page 15, there are some explanations about timing:

https://netdevconf.info/0x19/docs/netdev-0x19-paper23-talk-slides/packetdrill%20-%20NetDev%202025-03-10.pdf

Back to the series you sent: we could say that the mptcp_join.sh reproducer is enough, but I think it would be useful for you -- and to avoid a new "speed=slow" subtest: mptcp_join.sh's execution is already long enough -- to try a bit more with Packetdrill if that's OK. WDYT?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#9 lore raw
Quoted 2 lines · Kalpan Jani

Hi Matt,
Thank you for pointing me to add_addr_retry_errors.pkt — that makes the idiom clear. Inject a data packet after the del+re-add sequence and expect a plain DSS ACK back with no add_address option piggybacked. On an unfixed kernel the stale entry causes a spurious ADD_ADDR(id=0) retransmit to appear on that ACK, which packetdrill catches as an unexpected option.

Great!

Quoted 3 lines

I will write the packetdrill test using that pattern and send v6 with:

Patch 1: kernel fix (also correcting the addr argument — the &anno_addr copy in v5 is fragile for with-port endpoints)

If that's the same version as the v5, no need to resend it.

Quoted 1 line

Patch 2: packetdrill regression test in gtests/net/mptcp/regressions/

Can you open a PR instead, please?

https://github.com/multipath-tcp/packetdrill/

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#10 lore raw

Hi Matt,

PR opened: https://github.com/multipath-tcp/packetdrill/pull/201

One note on patch 1: v5 passes &anno_addr (a zeroed copy of msk_local) instead of addr directly. This works for no-port endpoints but is fragile for with-port ones. Should I send a corrected v6 for patch 1, or can you fix it up while applying?

Cheers,
Kalpan Jani

From: Matthieu Baerts <[email protected]>
To: "Kalpan Jani"<[email protected]>
Cc: "mptcp"<[email protected]>, "martineau"<[email protected]>, "pabeni"<[email protected]>, "shardul.b"<[email protected]>, "janak"<[email protected]>, "kalpanjani009"<[email protected]>, "shardulsb08"<[email protected]>
Date: Tue, 07 Jul 2026 19:44:57 +0530
Subject: Re: [PATCH net v2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint

Quoted 24 lines · Kalpan Jani
Quoted 2 lines

Hi Matt,
Thank you for pointing me to add_addr_retry_errors.pkt — that makes the idiom clear. Inject a data packet after the del+re-add sequence and expect a plain DSS ACK back with no add_address option piggybacked. On an unfixed kernel the stale entry causes a spurious ADD_ADDR(id=0) retransmit to appear on that ACK, which packetdrill catches as an unexpected option.

Great!

Quoted 3 lines

I will write the packetdrill test using that pattern and send v6 with:

Patch 1: kernel fix (also correcting the addr argument — the &anno_addr copy in v5 is fragile for with-port endpoints)

If that's the same version as the v5, no need to resend it.

Quoted 1 line

Patch 2: packetdrill regression test in gtests/net/mptcp/regressions/

Can you open a PR instead, please?

https://github.com/multipath-tcp/packetdrill/

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#11 lore raw
In reply to Kalpan Jani

Hi Kalpan,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/26623410540

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/ed6268d8c29c
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1102655

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)