mptcp: pm: fix stale ADD_ADDR anno_list entry on id 0 removal
Subsystems (3)
v5 cover mptcp: pm: fix stale ADD_ADDR anno_list entry on id 0 removal
The in-kernel MPTCP path manager can leave a stale ADD_ADDR announcement entry alive when removing the id 0 endpoint, causing WARN_ON_ONCE() to fire on subsequent PM reselection (issue #620).
**The Problem:**
When the in-kernel PM removes a signal endpoint, it must cancel any pending ADD_ADDR announcement: stop the retransmit timer and unlink the anno_list entry. For non-zero id endpoints, this is done correctly via mptcp_nl_remove_subflow_and_signal_addr() -> mptcp_pm_remove_anno_addr() -> mptcp_pm_announced_remove().
However, the id 0 removal path (mptcp_nl_remove_id_zero_address()) skips this cleanup, only queuing an RM_ADDR and marking the id available. If an ADD_ADDR for that address was previously announced but the echo hasn't arrived yet, the anno_list entry survives.
When the kernel PM later reselects id 0 (after adding another signal endpoint to satisfy the PM's endpoint limits), it finds this stale entry and hits the WARN_ON_ONCE(mptcp_pm_is_kernel()) assertion in mptcp_pm_alloc_anno_list().
**How It Was Found:**
syzkaller detected this via an MPTCP protocol-flow harness. Three crashes were reported between 2026/05/19 and 2026/05/22 on kernels including commit cca95436be15 ("mptcp: remove id 0 address"). The root cause was confirmed through code inspection:
asymmetry between the id 0 and non-zero id removal paths.
**The Fix:**
Patch 1 makes mptcp_nl_remove_id_zero_address() symmetric with the non-zero id path by calling mptcp_pm_announced_remove() before queuing RM_ADDR, and decrementing add_addr_signaled if the address had been announced. The fix is minimal (8 lines) and mirrors existing correct code.
A subtle detail: signal endpoints are stored in anno_list with port 0, but msk_local carries the connection's actual local port. The lookup in mptcp_pm_announced_remove() uses use_port=true, so the port must be cleared before the call to match the stored entry key.
Patch 2 adds a regression test integrated into mptcp_join.sh (per maintainer feedback, avoiding new test files). The test verifies no WARNING appears when removing id 0 from a fully-established MPTCP connection.
**Verification:**
- syzkaller: 3 crashes, issue #620 reproducible
- Docker CI: 23/24 tests pass, no new failures introduced
- Code review: Fix is minimal, correct, and mirrors existing patterns
- Suggested-by: Tao Cui <[email protected]> identified the port mismatch (v4 -> v5 fix)
Kalpan Jani (2):
mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint
selftests: mptcp: add id 0 stale ADD_ADDR regression test
net/mptcp/pm_kernel.c | 8 ++++++++ tools/testing/selftests/net/mptcp/mptcp_join.sh | 11 +++++++++++ 2 files changed, 19 insertions(+)
---
base-commit: net/main
change-id: 20260630-mptcp-id0-stale-anno-fix-kalpanj
PATCH v5 1/2 mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint
The in-kernel MPTCP path manager can leave a stale ADD_ADDR announcement entry alive when removing the id 0 endpoint. This happens because the id 0 removal path does not tear down pending announcements, unlike the non-zero id path.
When the PM later reselects id 0 after adding another signal endpoint, it finds the stale anno_list entry and hits WARN_ON_ONCE(mptcp_pm_is_kernel()) in mptcp_pm_alloc_anno_list().
Root cause: asymmetry between removal paths.
- Non-zero id path: mptcp_nl_remove_subflow_and_signal_addr() calls mptcp_pm_remove_anno_addr() to clean up.
- Id 0 path: mptcp_nl_remove_id_zero_address() skips cleanup entirely.
Fix by making the id 0 path symmetric: call mptcp_pm_announced_remove() and decrement add_addr_signaled before queuing the RM_ADDR.
Subtle detail: signal endpoints are stored in anno_list with port 0, but msk_local carries the connection's local port. mptcp_pm_announced_remove() uses use_port=true for comparison, so clear the port before the lookup.
--- net/mptcp/pm_kernel.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/mptcp/pm_kernel.c +8 -0
@@ -1138,6 +1138,8 @@ 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; +struct mptcp_addr_info anno_addr; +bool announced;if (list_empty (&msk->conn_list) ||mptcp_pm_is_userspace (msk)) goto next;
@@ -1147,7 +1149,13 @@ 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. */ + anno_addr = msk_local; + anno_addr.port =0 ; + announced =mptcp_pm_announced_remove (msk, &anno_addr);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
Re: [PATCH net v5 1/2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint
Hi Matt,
Sorry for the long silence on this.
The packetdrill test is now up at
https://github.com/multipath-tcp/packetdrill/pull/201 - I rewrote it and this time validated it in the virtme-docker environment: 3 failing without the kernel fix, 3 passing with it, on export/20260622T173908. Your suggestion about the endpoint linked to the initial subflow is what unblocked it. Details and the limitations I hit are in the PR.
Two things about v5 itself.
First, patch 1/2 is unchanged from what you have. I said I would rework the addr argument because the anno_addr copy looked fragile for endpoints with a port, but after re-checking I no longer think that case is reachable: the MPC endpoint cannot be a ported endpoint, since both __lookup_addr() and mptcp_nl_add_subflow_or_signal_addr() compare the port when the endpoint has one, and that would require it to match the initial subflow's local port - which mptcp_pm_nl_create_listen_socket() binding the same address:port makes unreachable in practice. So the entry reachable from mptcp_nl_remove_id_zero_address() always has port 0 and clearing it is correct. Tell me if you see a case I have missed.
Second, and I should have raised this earlier: please drop patch 2/2. The selftest does not exercise the fixed path. I used addr_nr_ns1=-1, which deletes the endpoint by its real ID via pm_nl_del_endpoint ${listener_ns} $id and therefore goes through mptcp_nl_remove_subflow_and_signal_addr() - the path that was already correct. Only -9 reaches mptcp_nl_remove_id_zero_address(), and the endpoint is 10.0.2.1, so the address check there would not have matched even with -9. The subtest passes identically with and without patch 1/2, which is why CI was green everywhere, and it largely duplicates the existing "remove single address" subtest. Sorry for not catching that before sending v5.
With the packetdrill test covering the same ground, I think patch 1/2 alone is the right thing to apply. Happy to send a corrected mptcp_join.sh subtest as well if you would rather have both.
Cheers,
Kalpan Jani
From: Kalpan Jani <[email protected]>
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, "Kalpan Jani"<[email protected]>, <[email protected]>, "Tao Cui"<[email protected]>
Date: Tue, 30 Jun 2026 20:36:31 +0530
Subject: [PATCH net v5 1/2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint
Quoted 61 lines
The in-kernel MPTCP path manager can leave a stale
ADD_ADDRannouncement entry alive when removing the id 0 endpoint. This happens because the id 0 removal path does not tear down pending announcements, unlike the non-zero id path.When the PM later reselects id 0 after adding another signal endpoint, it finds the stale
anno_listentry and hits WARN_ON_ONCE(mptcp_pm_is_kernel()) inmptcp_pm_alloc_anno_list().Root cause: asymmetry between removal paths.
- Non-zero id path:mptcp_nl_remove_subflow_and_signal_addr()callsmptcp_pm_remove_anno_addr()to clean up.
- Id 0 path:mptcp_nl_remove_id_zero_address()skips cleanup entirely.Fix by making the id 0 path symmetric: call
mptcp_pm_announced_remove()and decrementadd_addr_signaledbefore queuing theRM_ADDR.Subtle detail: signal endpoints are stored in
anno_listwith port 0, butmsk_localcarries the connection's local port.mptcp_pm_announced_remove()uses use_port=true for comparison, so clear the port before the lookup.Fixes 740d798e8767 ("mptcp: remove id 0 address")Reported-by [email protected]Suggested-by Tao Cui <[email protected]>Signed-off-by Kalpan Jani <[email protected]>--- net/mptcp/pm_kernel.c | 8 ++++++++ 1 file changed, 8 insertions(+)net/mptcp/pm_kernel.c +8
-0@@ -1138,6 +1138,8 @@ 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; +struct mptcp_addr_info anno_addr; +bool announced;if (list_empty (&msk->conn_list) ||mptcp_pm_is_userspace (msk)) goto next;@@ -1147,7 +1149,13 @@ 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. */ + anno_addr = msk_local; + anno_addr.port =0 ; + announced =mptcp_pm_announced_remove (msk, &anno_addr);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
Re: [PATCH net v5 1/2] mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint
Hi Kalpan,
Quoted 1 line · Kalpan Jani
Sorry for the long silence on this.
Np, I was overloaded anyway (still am)
Quoted 6 lines
The packetdrill test is now up at
https://github.com/multipath-tcp/packetdrill/pull/201 - I rewrote it and this time validated it in the virtme-docker environment: 3 failing without the kernel fix, 3 passing with it, on export/20260622T173908. Your suggestion about the endpoint linked to the initial subflow is what unblocked it. Details and the limitations I hit are in the PR.
Thanks, I just send some minor fixes, then merged. I hope that's OK.
Quoted 12 lines
Two things about v5 itself.
First, patch 1/2 is unchanged from what you have. I said I would rework the addr argument because the
anno_addrcopy looked fragile for endpoints with a port, but after re-checking I no longer think that case is reachable: the MPC endpoint cannot be a ported endpoint, since both__lookup_addr()andmptcp_nl_add_subflow_or_signal_addr()compare the port when the endpoint has one, and that would require it to match the initial subflow's local port - whichmptcp_pm_nl_create_listen_socket()binding the same address:port makes unreachable in practice. So the entry reachable frommptcp_nl_remove_id_zero_address()always has port 0 and clearing it is correct. Tell me if you see a case I have missed.
Fine by me.
Quoted 10 lines
Second, and I should have raised this earlier: please drop patch 2/2. The selftest does not exercise the fixed path. I used addr_nr_ns1=-1, which deletes the endpoint by its real ID via
pm_nl_del_endpoint${listener_ns} $id and therefore goes throughmptcp_nl_remove_subflow_and_signal_addr()- the path that was already correct. Only -9 reachesmptcp_nl_remove_id_zero_address(), and the endpoint is 10.0.2.1, so the address check there would not have matched even with -9. The subtest passes identically with and without patch 1/2, which is why CI was green everywhere, and it largely duplicates the existing "remove single address" subtest. Sorry for not catching that before sending v5.
Quoted 3 lines
With the packetdrill test covering the same ground, I think patch 1/2 alone is the right thing to apply. Happy to send a corrected
mptcp_join.shsubtest as well if you would rather have both.
Indeed, dropped.
Quoted 1 line
From: Kalpan Jani <[email protected]>
BTW, do you mind avoiding top-posting please, it is not recommended on most ML:
New patches for t/upstream-net and t/upstream:
- a6a9ee8fc58c: mptcp: pm: drop pending ADD_ADDR when removing id 0 endpoint
- Results: fb78b98bf563..4439056e6ccd (export-net)
- Results: 6f0836d81132..e8891858656d (export)
Tests are now in progress:
- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/420be436959ff2164ff3087f88e6a9756d485436/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/c808c1fcb72b4387c5d2193a4c69f387d5a7e881/checks
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
PATCH v5 2/2 selftests: mptcp: add id 0 stale ADD_ADDR regression test
In reply to Kalpan JaniAdd regression test for issue #620 to the mptcp_join.sh suite: removing the id 0 endpoint while a pending ADD_ADDR echo is outstanding used to leave a stale anno_list entry. A subsequent PM reselection would re-announce
that address and trigger WARN_ON_ONCE() in mptcp_pm_alloc_anno_list().
The test verifies no WARNING appears when removing id 0 from a fully- established MPTCP connection with a signal endpoint.
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +10 -0
@@ -2775,6 +2775,16 @@ remove_tests() chk_rm_nr 1 1 invert chk_rst_nr 0 0 invert fi + # id 0 stale anno list entry (issue #620) + if reset "id 0 stale anno"; then + pm_nl_set_limits $ns1 0 1 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + pm_nl_set_limits $ns2 1 1 + addr_nr_ns1=-1 speed=slow \ + run_tests $ns1 $ns2 10.0.1.1 + chk_add_nr 1 1 + chk_rm_nr 1 1 invert + fi } add_tests()
Signature · 1 line
2.43.0
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/28457083924
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/81b37efcf998
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1119114
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-normalFor 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)