* [PATCH net v3] tipc: free the tunnel packets when failover tunnelling stops early
@ 2026-11-25 15:54 Andrew Stellman
2026-11-26 8:36 ` Tung Quang Nguyen
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-11-25 15:54 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
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. The earlier
return taken when the dummy tunnel packet can't be allocated leaks
nothing but skips the same hand-over, so take the same exit there.
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!
In four runs without this patch, kmemleak reported three skbs (six
objects) allocated by tipc_link_tnl_prepare() in two, five leaks whose
details were not captured in one, and nothing in one. From one of the
two, run on a rebuild of the same commit with debug info enabled,
decoded and trimmed:
unreferenced object 0xff11000005117b80 (size 472):
backtrace (crc 539599dc):
__alloc_skb (net/core/skbuff.c:705 (discriminator 2))
tipc_buf_acquire (include/linux/skbuff.h:1441 net/tipc/msg.c:72)
tipc_link_tnl_prepare (net/tipc/link.c:2055)
__tipc_node_link_down (net/tipc/node.c:1053)
tipc_rcv (net/tipc/node.c:2008 net/tipc/node.c:2186)
tipc_l2_rcv_msg (net/tipc/bearer.c:721 (discriminator 1))
In one run 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. The allocation failure paths and the skipped hand-over were
found by reading the code and were not exercised. 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.
Fixes: 2320bcdae628 ("tipc: fix changeover issues due to large packet")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
v3: decoded the kmemleak trace and moved the tool credit below the
cut line (Tung Quang Nguyen); stated how many runs reported the leak.
v2: also take the out: exit when the dummy tunnel packet can't be
allocated (Sashiko review).
v2: https://lore.kernel.org/netdev/20261124001740.83267-1-astellman@stellman-greene.com/
v1: https://lore.kernel.org/netdev/20261122233958.10462-1-astellman@stellman-greene.com/
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.
A reproducer is available on request.
net/tipc/link.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 6427c69f8929..ce6739d6cbba 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1995,7 +1995,7 @@ void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl,
0, 0, TIPC_ERR_NO_PORT);
if (!skb) {
pr_warn("%sunable to create tunnel packet\n", link_co_err);
- return;
+ goto out;
}
__skb_queue_tail(&tnlq, skb);
tipc_link_xmit(l, &tnlq, &tmpxq);
@@ -2035,7 +2035,7 @@ 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 @@ 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 @@ 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] 2+ messages in thread
* RE: [PATCH net v3] tipc: free the tunnel packets when failover tunnelling stops early
2026-11-25 15:54 [PATCH net v3] tipc: free the tunnel packets when failover tunnelling stops early Andrew Stellman
@ 2026-11-26 8:36 ` Tung Quang Nguyen
0 siblings, 0 replies; 2+ messages in thread
From: Tung Quang Nguyen @ 2026-11-26 8:36 UTC (permalink / raw)
To: Andrew Stellman
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, tipc-discussion, linux-kernel, Jon Maloy
>Subject: [PATCH net v3] tipc: free the tunnel packets when failover tunnelling
>stops early
>
>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. The earlier return
>taken when the dummy tunnel packet can't be allocated leaks nothing but
>skips the same hand-over, so take the same exit there.
>
>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!
>
>In four runs without this patch, kmemleak reported three skbs (six
>objects) allocated by tipc_link_tnl_prepare() in two, five leaks whose details
>were not captured in one, and nothing in one. From one of the two, run on a
>rebuild of the same commit with debug info enabled, decoded and trimmed:
>
> unreferenced object 0xff11000005117b80 (size 472):
> backtrace (crc 539599dc):
> __alloc_skb (net/core/skbuff.c:705 (discriminator 2))
> tipc_buf_acquire (include/linux/skbuff.h:1441 net/tipc/msg.c:72)
> tipc_link_tnl_prepare (net/tipc/link.c:2055)
> __tipc_node_link_down (net/tipc/node.c:1053)
> tipc_rcv (net/tipc/node.c:2008 net/tipc/node.c:2186)
> tipc_l2_rcv_msg (net/tipc/bearer.c:721 (discriminator 1))
>
>In one run 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.
>The allocation failure paths and the skipped hand-over were found by reading
>the code and were not exercised. 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.
>
>Fixes: 2320bcdae628 ("tipc: fix changeover issues due to large packet")
>Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 8:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 15:54 [PATCH net v3] tipc: free the tunnel packets when failover tunnelling stops early Andrew Stellman
2026-11-26 8:36 ` Tung Quang Nguyen
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®