From: netdev-bot+sashiko@kernel.org
To: f3lix.dev@gmx.de
Cc: linux-x25@vger.kernel.org, ms@dev.tdt.de, netdev@vger.kernel.org,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org,
linux-kernel@vger.kernel.org, willemb@google.com
Subject: Re: [PATCH net v2] net: x25: shut down T20 timer before freeing neighbour
Date: Wed, 25 Nov 2026 09:39:47 +0000 [thread overview]
Message-ID: <179559958721.3135.5593816176235018299@kernel.org> (raw)
In-Reply-To: <20261124093922.39573-1-f3lix.dev@gmx.de>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new skb_queue_purge(&nb->queue) runs in
__x25_remove_neigh() (net/x25/x25_link.c:303).
- [Low] The kernel-doc for __x25_remove_neigh()
(net/x25/x25_link.c:292-298) still describes only list removal:…
--
net: x25: shut down T20 timer before freeing neighbour
This commit makes __x25_remove_neigh() call timer_shutdown_sync() on the
T20 timer, so a callback that is already running can't rearm the timer
after the neighbour is freed. It also purges nb->queue before the
list-owned reference is dropped. That restores the cleanup removed by
commit 7eed751b3b2a.
> 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);
[Severity: Medium]
Is this the right place for the purge? __x25_remove_neigh() only drops the
reference that x25_neigh_list owns. The neighbour is actually freed by
whoever calls x25_neigh_put() last, and that function only calls kfree():
include/net/x25.h:x25_neigh_put() {
if (refcount_dec_and_test(&nb->refcnt))
kfree(nb);
}
Anyone still holding a reference after list removal can add frames to
nb->queue through x25_transmit_link() while nb->state is 0, 1 or 2:
net/x25/x25_link.c:x25_transmit_link() {
case X25_LINK_STATE_0:
skb_queue_tail(&nb->queue, skb);
...
case X25_LINK_STATE_1:
case X25_LINK_STATE_2:
skb_queue_tail(&nb->queue, skb);
}
A socket is one way to get there. On NETDEV_DOWN, x25_device_event() calls
x25_link_terminated()->x25_kill_by_neigh() before x25_route_device_down().
A non-blocking x25_connect() running at the same time can find the route
and take the reference after x25_kill_by_neigh() has already walked the
socket list:
x25->neighbour = x25_get_neigh(rt->dev);
That socket is never disconnected. It sends CALL_REQUEST, which moves nb
to X25_LINK_STATE_1, then returns -EINPROGRESS and keeps the reference.
NETDEV_UNREGISTER then runs x25_link_device_down()->__x25_remove_neigh().
That purges nb->queue and drops the list reference, but the socket still
holds nb. Later, either T21 expiry in X25_STATE_1 or close() queues
another frame:
x25_do_timer_expiry()
x25_write_internal(sk, X25_CLEAR_REQUEST)
x25_transmit_link()
skb_queue_tail(&nb->queue, skb)
When x25_disconnect()->x25_neigh_put() later drops the last reference,
won't nb be freed with that skb still on nb->queue? x25_forward_data() and
x25_forward_call() follow the same pattern: take a reference, transmit,
then drop it.
The commit message says:
Also purge queued frames before releasing the neighbour
As written, this only covers frames queued before the list reference is
dropped. Would it be more robust to purge nb->queue in x25_neigh_put()
before kfree()? At that point nobody else can add to the queue, and
skb_queue_purge() is safe in atomic context.
> list_del(&nb->node);
> x25_neigh_put(nb);
> }
[Severity: Low]
This isn't a bug, but the kernel-doc above __x25_remove_neigh() still
describes only the list removal:
* __x25_remove_neigh - remove neighbour from x25_neigh_list
* @nb: - neigh to remove
*
* Remove neighbour from x25_neigh_list. If it was there.
* Caller must hold x25_neigh_list_lock.
Could it say that the function now shuts down T20 for good and purges
nb->queue? It could also note that timer_shutdown_sync() may wait for a
running callback while the caller holds x25_neigh_list_lock.
The rule that x25_t20timer_expiry() must never take x25_neigh_list_lock
is currently written down only in the commit message. If the callback
ever took that lock, x25_link_device_down() and x25_link_free() would
deadlock.
Separately, this one is pre-existing: the if (nb->node.next) guard can't
detect an entry already removed with list_del(), because LIST_POISON1 is
non-NULL. Today the function is only called while iterating the list.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124093922.39573-1-f3lix.dev%40gmx.de
prev parent reply other threads:[~2026-11-25 9:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:39 [PATCH net v2] net: x25: shut down T20 timer before freeing neighbour Felix Hoffmann
2026-11-24 9:43 ` netdev-bot+sinfo
2026-11-25 9:39 ` netdev-bot+sashiko [this message]
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=179559958721.3135.5593816176235018299@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=f3lix.dev@gmx.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox