* [PATCH net] tipc: free the tunnel packets when failover tunnelling stops early
@ 2026-11-22 23:39 Andrew Stellman
2026-11-24 0:03 ` netdev-bot+sashiko
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Stellman @ 2026-11-22 23:39 UTC (permalink / raw)
To: Jon Maloy, Tung Quang Nguyen
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Tuong Lien, Ying Xue, netdev, tipc-discussion,
linux-kernel, Andrew Stellman
tipc_link_tnl_prepare() returns from the middle of its tunnelling loop
when a packet does not fit the tunnel link MTU and the peer lacks
TIPC_TUNNEL_ENHANCED, when fragmenting such a packet fails, and when a
tunnel packet cannot be allocated. The tunnel packets already built on
the local tnlq are leaked, and for FAILOVER_MSG the receive side
hand-over at the end of the function (drop_point, failover_reasm_skb,
deferdq) is skipped.
Purge tnlq on these paths and go on with the hand-over.
Reproduced on net (af6737b90668) under QEMU with kmemleak, with two
guests joined by two TIPC eth links: MTU 9000 (active) and MTU 1500
(standby). The receiving guest runs the same kernel with
TIPC_TUNNEL_ENHANCED removed from TIPC_NODE_CAPABILITIES, to stand in
for a peer whose kernel predates that capability; the sending guest's
kernel is unmodified. The sender blocks the MTU 9000 link in both
directions with tc, sends three 100 byte messages and one 4000 byte
message, and waits for the link to fail. Without this patch that logs
tipc: Link tunneling error, too large msg <0, 2>: 4040!
and kmemleak reports three skbs (six objects) allocated by
tipc_link_tnl_prepare():
unreferenced object 0xff11000004d34780 (size 472):
backtrace (crc dd2ea0a1):
kmem_cache_alloc_node_noprof+0x296/0x3a0
__alloc_skb+0xde/0x890
tipc_buf_acquire+0x1d/0xe0
tipc_link_tnl_prepare+0x94b/0x1960
__tipc_node_link_down+0x4ae/0x13e0
tipc_rcv+0x2187/0x2e20
tipc_l2_rcv_msg+0x1d8/0x2e0
With this patch the same test logs the warning and kmemleak reports
nothing. With a 1000 byte message instead of the 4000 byte one, all
four messages reach the receiver over the tunnel with and without this
patch. Apart from the receiver's capability change, no kernel changes,
fault injection, debug code or delays were used. There are no TIPC
selftests to run.
The issue was found by Claude Opus 5.5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix and this changelog were drafted with Claude Opus 5.5 and
reviewed by me.
Fixes: 2320bcdae628 ("tipc: fix changeover issues due to large packet")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
A reproducer is available on request.
net/tipc/link.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 6427c69f892..2fead2f4ed0 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2035,7 +2035,7 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
if (rc) {
pr_warn("%sunable to frag msg: rc %d\n",
link_co_err, rc);
- return;
+ goto out;
}
pktcnt += skb_queue_len(&frags) - 1;
pktcnt_need_update = true;
@@ -2043,19 +2043,19 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
continue;
}
/* Unluckily, peer doesn't have TIPC_TUNNEL_ENHANCED
- * => Just warn it and return!
+ * => Just warn it and stop tunnelling!
*/
pr_warn_ratelimited("%stoo large msg <%d, %d>: %d!\n",
link_co_err, msg_user(hdr),
msg_type(hdr), msg_size(hdr));
- return;
+ goto out;
}
msg_set_size(&tnlhdr, pktlen + INT_H_SIZE);
tnlskb = tipc_buf_acquire(pktlen + INT_H_SIZE, GFP_ATOMIC);
if (!tnlskb) {
pr_warn("%sunable to send packet\n", link_co_err);
- return;
+ goto out;
}
skb_copy_to_linear_data(tnlskb, &tnlhdr, INT_H_SIZE);
skb_copy_to_linear_data_offset(tnlskb, INT_H_SIZE, hdr, pktlen);
@@ -2073,6 +2073,9 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
}
tipc_link_xmit(tnl, &tnlq, xmitq);
+out:
+ /* Empty unless tunnelling stopped early */
+ __skb_queue_purge(&tnlq);
if (mtyp == FAILOVER_MSG) {
struct sk_buff_head *fdefq = &tnl->failover_deferdq;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] tipc: free the tunnel packets when failover tunnelling stops early
2026-11-22 23:39 [PATCH net] tipc: free the tunnel packets when failover tunnelling stops early Andrew Stellman
@ 2026-11-24 0:03 ` netdev-bot+sashiko
2026-11-24 0:14 ` Andrew Stellman
0 siblings, 1 reply; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 0:03 UTC (permalink / raw)
To: astellman
Cc: jmaloy, tung.quang.nguyen, davem, edumazet, kuba, pabeni, horms,
tuong.t.lien, ying.xue, netdev, tipc-discussion, linux-kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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 patch leaves one early exit in tipc_link_tnl_prepare()
(net/tipc/link.c) that still skips the FAILOVER_MSG receive-side hand-…
--
tipc: free the tunnel packets when failover tunnelling stops early
The three early returns inside the tunnelling loop of
tipc_link_tnl_prepare() now jump to a new out: label. That label purges
any tunnel packets left on tnlq. It then runs the FAILOVER_MSG receive
side hand-over (drop_point, failover_reasm_skb, deferdq).
> diff --git a/net/tipc/link.c b/net/tipc/link.c
> index 6427c69f89294..2fead2f4ed0fa 100644
> --- a/net/tipc/link.c
> +++ b/net/tipc/link.c
[ ... ]
> @@ -2073,6 +2073,9 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
> }
>
> tipc_link_xmit(tnl, &tnlq, xmitq);
> +out:
> + /* Empty unless tunnelling stopped early */
> + __skb_queue_purge(&tnlq);
>
> if (mtyp == FAILOVER_MSG) {
> struct sk_buff_head *fdefq = &tnl->failover_deferdq;
[Severity: Medium]
The commit message says the fix is to "go on with the hand-over" when
tunnelling stops early. Should the earlier exit, taken when the dummy
packet can't be allocated, also jump to out?
That path in tipc_link_tnl_prepare() still returns directly:
net/tipc/link.c:tipc_link_tnl_prepare() {
...
skb = tipc_msg_create(TIPC_LOW_IMPORTANCE, TIPC_DIRECT_MSG,
BASIC_H_SIZE, 0, l->addr, tipc_own_addr(l->net),
0, 0, TIPC_ERR_NO_PORT);
if (!skb) {
pr_warn("%sunable to create tunnel packet\n", link_co_err);
return;
}
...
}
tipc_msg_create() allocates with tipc_buf_acquire(..., GFP_ATOMIC), so it
can fail under memory pressure. If it fails for FAILOVER_MSG, this code
never runs:
tnl->drop_point = l->rcv_nxt;
tnl->failover_reasm_skb = l->reasm_buf;
skb_queue_splice_init(&l->deferdq, fdefq);
The caller goes into failover anyway:
__tipc_node_link_down()
tipc_link_tnl_prepare(l, tnl, FAILOVER_MSG, xmitq);
tipc_link_reset(l); <- frees l->reasm_buf, purges l->deferdq
tipc_link_fsm_evt(l, LINK_RESET_EVT);
tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
tipc_node_fsm_evt(n, NODE_FAILOVER_BEGIN_EVT);
tnl->drop_point then keeps a stale value. That is 0 from link creation,
1 from tipc_link_failover_prepare(), or whatever an earlier failover left.
tipc_link_failover_rcv() then does this:
if (unlikely(less(seqno, l->drop_point))) {
kfree_skb(iskb);
continue;
}
if (unlikely(seqno != l->drop_point)) {
__tipc_skb_queue_sorted(fdefq, seqno, iskb);
continue;
}
Could this drop the peer's tunnelled messages? Could it also leave them
in failover_deferdq for good, since drop_point only moves forward on an
exact match?
tnlq is already initialised and empty at that point, and the out: block
only touches tnlq, l and tnl. So changing that return to goto out looks
safe.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122233958.10462-1-astellman%40stellman-greene.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] tipc: free the tunnel packets when failover tunnelling stops early
2026-11-24 0:03 ` netdev-bot+sashiko
@ 2026-11-24 0:14 ` Andrew Stellman
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Stellman @ 2026-11-24 0:14 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: jmaloy, tung.quang.nguyen, davem, edumazet, kuba, pabeni, horms,
tuong.t.lien, ying.xue, netdev, tipc-discussion, linux-kernel
Agreed: that return also skips the FAILOVER_MSG hand-over, and goto
out is safe there since tnlq is already initialised and empty. I'll
include it in v2.
pw-bot: cr
On Mon, Nov 23, 2026 at 7:03 PM <netdev-bot+sashiko@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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 patch leaves one early exit in tipc_link_tnl_prepare()
> (net/tipc/link.c) that still skips the FAILOVER_MSG receive-side hand-…
>
> --
>
> tipc: free the tunnel packets when failover tunnelling stops early
>
> The three early returns inside the tunnelling loop of
> tipc_link_tnl_prepare() now jump to a new out: label. That label purges
> any tunnel packets left on tnlq. It then runs the FAILOVER_MSG receive
> side hand-over (drop_point, failover_reasm_skb, deferdq).
>
> > diff --git a/net/tipc/link.c b/net/tipc/link.c
> > index 6427c69f89294..2fead2f4ed0fa 100644
> > --- a/net/tipc/link.c
> > +++ b/net/tipc/link.c
>
> [ ... ]
>
> > @@ -2073,6 +2073,9 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
> > }
> >
> > tipc_link_xmit(tnl, &tnlq, xmitq);
> > +out:
> > + /* Empty unless tunnelling stopped early */
> > + __skb_queue_purge(&tnlq);
> >
> > if (mtyp == FAILOVER_MSG) {
> > struct sk_buff_head *fdefq = &tnl->failover_deferdq;
>
> [Severity: Medium]
> The commit message says the fix is to "go on with the hand-over" when
> tunnelling stops early. Should the earlier exit, taken when the dummy
> packet can't be allocated, also jump to out?
>
> That path in tipc_link_tnl_prepare() still returns directly:
>
> net/tipc/link.c:tipc_link_tnl_prepare() {
> ...
> skb = tipc_msg_create(TIPC_LOW_IMPORTANCE, TIPC_DIRECT_MSG,
> BASIC_H_SIZE, 0, l->addr, tipc_own_addr(l->net),
> 0, 0, TIPC_ERR_NO_PORT);
> if (!skb) {
> pr_warn("%sunable to create tunnel packet\n", link_co_err);
> return;
> }
> ...
> }
>
> tipc_msg_create() allocates with tipc_buf_acquire(..., GFP_ATOMIC), so it
> can fail under memory pressure. If it fails for FAILOVER_MSG, this code
> never runs:
>
> tnl->drop_point = l->rcv_nxt;
> tnl->failover_reasm_skb = l->reasm_buf;
> skb_queue_splice_init(&l->deferdq, fdefq);
>
> The caller goes into failover anyway:
>
> __tipc_node_link_down()
> tipc_link_tnl_prepare(l, tnl, FAILOVER_MSG, xmitq);
> tipc_link_reset(l); <- frees l->reasm_buf, purges l->deferdq
> tipc_link_fsm_evt(l, LINK_RESET_EVT);
> tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
> tipc_node_fsm_evt(n, NODE_FAILOVER_BEGIN_EVT);
>
> tnl->drop_point then keeps a stale value. That is 0 from link creation,
> 1 from tipc_link_failover_prepare(), or whatever an earlier failover left.
> tipc_link_failover_rcv() then does this:
>
> if (unlikely(less(seqno, l->drop_point))) {
> kfree_skb(iskb);
> continue;
> }
> if (unlikely(seqno != l->drop_point)) {
> __tipc_skb_queue_sorted(fdefq, seqno, iskb);
> continue;
> }
>
> Could this drop the peer's tunnelled messages? Could it also leave them
> in failover_deferdq for good, since drop_point only moves forward on an
> exact match?
>
> tnlq is already initialised and empty at that point, and the out: block
> only touches tnlq, l and tnl. So changing that return to goto out looks
> safe.
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122233958.10462-1-astellman%40stellman-greene.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 0:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 23:39 [PATCH net] tipc: free the tunnel packets when failover tunnelling stops early Andrew Stellman
2026-11-24 0:03 ` netdev-bot+sashiko
2026-11-24 0:14 ` Andrew Stellman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®