All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: syzbot+f3a31fb909db9b2a5c4d@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org,
	"Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Subject: [PATCH net] mptcp: pm: Fix uaf in __timer_delete_sync
Date: Wed,  4 Sep 2024 19:05:18 +0200	[thread overview]
Message-ID: <20240904170517.237863-2-matttbe@kernel.org> (raw)
In-Reply-To: <000000000000b341bb062136d2d9@google.com>

#syz test

Fixes: 00cfd77b9063 ("mptcp: retransmit ADD_ADDR when timeout")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/pm_netlink.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index f891bc714668..792b5f09a915 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -332,17 +332,21 @@ struct mptcp_pm_add_entry *
 mptcp_pm_del_add_timer(struct mptcp_sock *msk,
 		       const struct mptcp_addr_info *addr, bool check_id)
 {
-	struct mptcp_pm_add_entry *entry;
 	struct sock *sk = (struct sock *)msk;
+	struct timer_list *add_timer = NULL;
+	struct mptcp_pm_add_entry *entry;
 
 	spin_lock_bh(&msk->pm.lock);
 	entry = mptcp_lookup_anno_list_by_saddr(msk, addr);
-	if (entry && (!check_id || entry->addr.id == addr->id))
+	if (entry && (!check_id || entry->addr.id == addr->id)) {
 		entry->retrans_times = ADD_ADDR_RETRANS_MAX;
+		add_timer = &entry->add_timer;
+	}
 	spin_unlock_bh(&msk->pm.lock);
 
-	if (entry && (!check_id || entry->addr.id == addr->id))
-		sk_stop_timer_sync(sk, &entry->add_timer);
+	/* no lock, because sk_stop_timer_sync() is calling del_timer_sync() */
+	if (add_timer)
+		sk_stop_timer_sync(sk, add_timer);
 
 	return entry;
 }
-- 
2.45.2


  parent reply	other threads:[~2024-09-04 17:05 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03 13:13 [syzbot] [mptcp?] KASAN: slab-use-after-free Read in __timer_delete_sync syzbot
2024-09-03 13:43 ` Edward Adam Davis
2024-09-03 14:09   ` syzbot
2024-09-03 13:52 ` Edward Adam Davis
2024-09-03 14:24   ` syzbot
2024-09-03 15:09 ` [PATCH] mptcp: pm: Fix uaf " Edward Adam Davis
2024-09-03 15:18   ` Eric Dumazet
2024-09-04  0:52     ` Edward Adam Davis
2024-09-04  1:01       ` [PATCH V2] " Edward Adam Davis
2024-09-04  1:52         ` MPTCP CI
2024-09-04 20:39         ` Matthieu Baerts
2024-09-05 12:27           ` [PATCH net v3] " Edward Adam Davis
2024-09-05 13:20             ` MPTCP CI
2024-09-05 14:52             ` MPTCP CI
2024-09-06 18:55             ` Matthieu Baerts
2024-09-06 22:02               ` Jakub Kicinski
2024-09-09  7:01                 ` Matthieu Baerts
2024-09-09 13:07             ` Paolo Abeni
2024-09-10  3:59               ` Edward Adam Davis
2024-09-10  9:58                 ` [PATCH V4] " Edward Adam Davis
2024-09-10 10:54                   ` MPTCP CI
2024-09-10  9:58                 ` [PATCH net " Edward Adam Davis
2024-09-10 10:51                   ` MPTCP CI
2024-09-10 11:27                   ` Paolo Abeni
2024-09-10 14:29                   ` Matthieu Baerts
2024-09-11 23:20                   ` patchwork-bot+netdevbpf
2024-09-05 12:35           ` [PATCH V2] " Edward Adam Davis
2024-09-03 16:03   ` [PATCH] " MPTCP CI
2024-09-04  0:20 ` [syzbot] [mptcp?] KASAN: slab-use-after-free Read " Edward Adam Davis
2024-09-04  0:42   ` syzbot
2024-09-04 17:05 ` Matthieu Baerts (NGI0) [this message]
2024-09-05  0:46   ` syzbot
2024-09-04 17:45 ` [PATCH net v2] mptcp: pm: Fix uaf " Matthieu Baerts (NGI0)
2024-09-05  1:10   ` [syzbot] [mptcp?] KASAN: slab-use-after-free Read " syzbot
2024-09-10  3:54 ` Edward Adam Davis
2024-09-10  6:56   ` syzbot
2024-09-10  7:10 ` Edward Adam Davis
2024-09-10  7:43   ` syzbot
2024-09-10  8:03 ` Edward Adam Davis
2024-09-10  8:32   ` syzbot
2024-09-10  9:32 ` Edward Adam Davis
2024-09-10  9:57   ` syzbot

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=20240904170517.237863-2-matttbe@kernel.org \
    --to=matttbe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+f3a31fb909db9b2a5c4d@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.