From: Felix Hoffmann <f3lix.dev@gmx.de>
To: linux-x25@vger.kernel.org, Martin Schiller <ms@dev.tdt.de>
Cc: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
linux-kernel@vger.kernel.org,
Willem de Bruijn <willemb@google.com>
Subject: [PATCH net v2] net: x25: shut down T20 timer before freeing neighbour
Date: Tue, 24 Nov 2026 10:39:22 +0100 [thread overview]
Message-ID: <20261124093922.39573-1-f3lix.dev@gmx.de> (raw)
x25_link_terminated() cancels the T20 restart timer with
timer_delete(). If the callback is already running on another CPU, the
cancel does not wait. The callback can then rearm the timer before
x25_link_device_down() removes the neighbour and drops its last
reference. This frees the neighbour while its embedded timer is active,
leading to a use-after-free on expiry.
Shut the timer down synchronously in __x25_remove_neigh() before
dropping the list-owned reference. timer_shutdown_sync() also prevents
the callback's unconditional rearm. The callback does not acquire
x25_neigh_list_lock, so it is safe to wait while neighbour removal keeps
the list protected.
Also purge queued frames before releasing the neighbour, restoring the
cleanup removed by commit 7eed751b3b2a ("net/x25: handle additional
netdev events").
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Hoffmann <f3lix.dev@gmx.de>
Acked-by: Martin Schiller <ms@dev.tdt.de>
---
Tested with a two-vCPU KASAN, timer debugobjects and lockdep kernel using
a deterministic callback/teardown race. All 10 timer callbacks completed
without a KASAN, debugobjects, lockdep, warning, oops, or panic report.
Build-tested with W=1 under allmodconfig and allyesconfig.
The reproducer is available privately on request.
net/x25/x25_link.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/x25/x25_link.c b/net/x25/x25_link.c
index d1e8cd81c2143..b9f290616e3a8 100644
--- a/net/x25/x25_link.c
+++ b/net/x25/x25_link.c
@@ -299,6 +299,8 @@ void x25_link_device_up(struct net_device *dev)
static void __x25_remove_neigh(struct x25_neigh *nb)
{
if (nb->node.next) {
+ timer_shutdown_sync(&nb->t20timer);
+ skb_queue_purge(&nb->queue);
list_del(&nb->node);
x25_neigh_put(nb);
}
--
2.43.0
next reply other threads:[~2026-11-24 9:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:39 Felix Hoffmann [this message]
2026-11-24 9:43 ` [PATCH net v2] net: x25: shut down T20 timer before freeing neighbour netdev-bot+sinfo
2026-11-25 9:39 ` netdev-bot+sashiko
2026-11-25 10:06 ` Martin Schiller
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=20261124093922.39573-1-f3lix.dev@gmx.de \
--to=f3lix.dev@gmx.de \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-x25@vger.kernel.org \
--cc=ms@dev.tdt.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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.