MPTCP Linux Development
 help / color / mirror / Atom feed
From: Li Xiasong <xiasonglee@gmail.com>
To: mptcp@lists.linux.dev
Cc: lixiasong1@huawei.com
Subject: [PATCH mptcp-net 2/2] mptcp: use sk_shutdown_timer_sync() for add_addr timer teardown
Date: Tue, 26 May 2026 10:36:47 +0000	[thread overview]
Message-ID: <20260526103647.732350-3-xiasong.lee@gmail.com> (raw)
In-Reply-To: <20260526103647.732350-1-xiasong.lee@gmail.com>

From: Li Xiasong <lixiasong1@huawei.com>

Sashiko reported a possible use-after-free in add_addr timer teardown.

The add_addr timer callback can re-arm itself on the sock_owned_by_user()
path. In final teardown paths, sk_stop_timer_sync() only waits for a
running callback to finish, but does not prevent a concurrent callback
from re-arming the timer.

Use sk_shutdown_timer_sync() for add_addr timer teardown so the timer
cannot be re-armed after teardown starts, preventing a possible
use-after-free on a freed add entry.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/623
Fixes: 5cd6e0ad79d2 ("mptcp: pm: ADD_ADDR rtx: fix potential data-race")
Signed-off-by: Li Xiasong <lixiasong1@huawei.com>
---
 net/mptcp/pm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 3e770c7407e1..cda3efb2c206 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -424,7 +424,7 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk,
 		if (check_id)
 			sk_stop_timer(sk, &entry->add_timer);
 		else
-			sk_stop_timer_sync(sk, &entry->add_timer);
+			sk_shutdown_timer_sync(sk, &entry->add_timer);
 	}
 
 	rcu_read_unlock();
@@ -483,7 +483,7 @@ static void mptcp_pm_free_anno_list(struct mptcp_sock *msk)
 
 	list_for_each_entry_safe(entry, tmp, &free_list, list) {
 		if (!entry->timer_done)
-			sk_stop_timer_sync(sk, &entry->add_timer);
+			sk_shutdown_timer_sync(sk, &entry->add_timer);
 		kfree_rcu(entry, rcu);
 	}
 }
-- 
2.43.0


  parent reply	other threads:[~2026-05-26 10:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 10:36 [PATCH mptcp-net 0/2] mptcp: prevent add_addr timer rearm during teardown Li Xiasong
2026-05-26 10:36 ` [PATCH mptcp-net 1/2] net: add sk_shutdown_timer_sync() helper Li Xiasong
2026-05-26 10:36 ` Li Xiasong [this message]
2026-05-27  4:44   ` [PATCH mptcp-net 2/2] mptcp: use sk_shutdown_timer_sync() for add_addr timer teardown Matthieu Baerts
2026-05-28 12:33     ` Li Xiasong
2026-05-27  5:16 ` [PATCH mptcp-net 0/2] mptcp: prevent add_addr timer rearm during teardown MPTCP CI
2026-06-04  7:19 ` [PATCH mptcp-net] " Kalpan Jani
2026-06-05  7:31   ` Li Xiasong
2026-06-11  6:59 ` Kalpan Jani

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=20260526103647.732350-3-xiasong.lee@gmail.com \
    --to=xiasonglee@gmail.com \
    --cc=lixiasong1@huawei.com \
    --cc=mptcp@lists.linux.dev \
    /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