Skip to content

mptcp: prevent add_addr timer rearm during teardown

Li Xiasong mptcp 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2net: add sk_shutdown_timer_sync() helperinclude/net/sock.h net/core/sock.c+12 -00 replies
2/2mptcp: use sk_shutdown_timer_sync() for add_addr timer teardownnet/mptcp/pm.c+2 -22 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH mptcp-net 0/2] mptcp: prevent add_addr timer rearm during teardown

From: Li Xiasong <[email protected]>

This series fixes a potential use-after-free in MPTCP ADD_ADDR timer teardown.

The ADD_ADDR retransmission timer callback may re-arm itself on the sock_owned_by_user() path. During final teardown, this can race with timer cancellation and leave a timer pending after the entry is removed and freed.

Using sk_stop_timer_sync() is not sufficient for this case because it waits for a running callback but does not permanently disable the timer.

This series does two things:

1. Add sk_shutdown_timer_sync() to socket timer helpers.
It wraps timer_shutdown_sync() and preserves sk reference accounting semantics by dropping a socket reference when a pending timer is removed.

2. Switch MPTCP ADD_ADDR final teardown paths to sk_shutdown_timer_sync(), so the timer cannot be re-armed once teardown starts.

Reported scenario:

Li Xiasong (2):
net: add sk_shutdown_timer_sync() helper
mptcp: use sk_shutdown_timer_sync() for add_addr timer teardown

 include/net/sock.h | 5 +++++
 net/core/sock.c    | 7 +++++++
 net/mptcp/pm.c     | 4 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0