* Re: [PATCH net] tipc: drop discovery messages shorter than the fields they carry
2026-11-24 7:52 [PATCH net] tipc: drop discovery messages shorter than the fields they carry Kyuwon Cho
@ 2026-11-25 8:21 ` netdev-bot+sashiko
2026-11-25 9:44 ` Tung Quang Nguyen
2026-11-25 15:55 ` Kyuwon Cho
2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 8:21 UTC (permalink / raw)
To: kyuwoncho18
Cc: jmaloy, tung.quang.nguyen, ying.xue, davem, edumazet, kuba,
pabeni, willemb, horms, netdev, tipc-discussion, linux-kernel
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 check in tipc_disc_rcv() (`msg_hdr_sz(hdr) <
MAX_H_SIZE`) silently drops every LINK_CONFIG message with a header…
- [Low] In net/tipc/discover.c, tipc_disc_rcv() still reads words 13 and
14 of the header before the new length check runs.
--
tipc: drop discovery messages shorter than the fields they carry
This adds a length check to tipc_disc_rcv() in net/tipc/discover.c. It
drops LINK_CONFIG messages whose declared header is shorter than
MAX_H_SIZE, and also those whose data is shorter than NODE_ID_LEN when
TIPC_NODE_ID128 is set. The aim is to stop the media address, words 13
and 14, and the node identity being read from beyond the end of the
message.
> diff --git a/net/tipc/discover.c b/net/tipc/discover.c
> index b9d06595b0673..0f99e4af1cfa9 100644
> --- a/net/tipc/discover.c
> +++ b/net/tipc/discover.c
> @@ -219,6 +219,12 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
> }
> hdr = buf_msg(skb);
>
> + if (msg_hdr_sz(hdr) < MAX_H_SIZE ||
> + ((caps & TIPC_NODE_ID128) && msg_data_sz(hdr) < NODE_ID_LEN)) {
> + kfree_skb(skb);
> + return;
> + }
[Severity: Medium]
Will this also drop discovery messages from older peers that send a
40-byte INT_H_SIZE header?
Before commit 948fa2d115c5 ("tipc: increase size of tipc discovery
messages"), tipc_disc_init_msg() built discovery messages with an
INT_H_SIZE header. That commit's message says 40 bytes "was enough for
Ethernet/IB/IPv4".
tipc_msg_validate() accepts any hsz from MIN_H_SIZE to MAX_H_SIZE, so
these messages still reach tipc_disc_rcv() via tipc_rcv():
if (unlikely(usr == LINK_CONFIG))
return tipc_disc_rcv(net, skb, b);
The Ethernet and InfiniBand decoders only read bytes inside a 40-byte
header:
- tipc_eth_msg2addr() reads header bytes 24 to 29.
- tipc_ib_msg2addr() reads 20 bytes starting at byte 20, so it stops
at byte 40.
The receiver also still handles peers without TIPC_NODE_ID128:
else
sprintf(peer_id, "%x", src);
Before this patch, discovery with these peers over Ethernet or IB could
still complete, although words 13 and 14 held garbage. After it, the
messages are freed without the "Rcv corrupt discovery message" warning,
and neighbour discovery with those peers stops.
Is dropping interop with these peers intended? If so, could the commit
message say so? The Fixes: tag points at the initial merge, so this
change would go to every stable tree.
Or could the minimum length depend on what each media and the words
13/14 consumers actually need, so that 40-byte Ethernet/IB discovery
keeps working?
[Severity: Low]
This isn't a bug, but words 13 and 14 are still read before this new
check runs. At the top of tipc_disc_rcv():
struct tipc_msg *hdr = buf_msg(skb);
u32 pnet_hash = msg_peer_net_hash(hdr);
u16 caps = msg_node_capabilities(hdr);
bool legacy = tn->legacy_addr_format;
u32 sugg = msg_sugg_node_addr(hdr);
msg_peer_net_hash() returns msg_word(m, 13), and msg_sugg_node_addr()
returns msg_word(m, 14). Both run before skb_linearize() and before the
msg_hdr_sz(hdr) < MAX_H_SIZE test. With a 24-byte header, both words
are still loaded from past the validated header.
The short message is dropped before pnet_hash reaches
tipc_node_check_dest() or sugg reaches tipc_disc_addr_trial_msg(), so
those values are never used.
Could these two reads, or the check, be reordered so the check comes
first? That would match the commit message, which says these fields
"are then read from past the end of the message".
>
> if (caps & TIPC_NODE_ID128)
> memcpy(peer_id, msg_node_id(hdr), NODE_ID_LEN);
> else
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179550610427.774194.2378040347436778640%40gmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH net] tipc: drop discovery messages shorter than the fields they carry
2026-11-24 7:52 [PATCH net] tipc: drop discovery messages shorter than the fields they carry Kyuwon Cho
2026-11-25 8:21 ` netdev-bot+sashiko
@ 2026-11-25 9:44 ` Tung Quang Nguyen
2026-11-25 15:55 ` Kyuwon Cho
2 siblings, 0 replies; 4+ messages in thread
From: Tung Quang Nguyen @ 2026-11-25 9:44 UTC (permalink / raw)
To: Kyuwon Cho
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, tipc-discussion, linux-kernel, Jon Maloy
>Subject: [PATCH net] tipc: drop discovery messages shorter than the fields they
>carry
>
>tipc_disc_rcv() reads the media address and words 13 and 14 of a full
>MAX_H_SIZE header, and the 128-bit node identity from the data after it, but
>tipc_msg_validate() only checks that the declared header is at least
>MIN_H_SIZE. A peer on the bearer can send a discovery message with a 24-
>byte header, and those fields are then read from past the end of the message.
>For a UDP bearer, tipc_udp_msg2addr() takes the peer's address from there:
Discovery message's header size (MAX_H_SIZE == 60) is stated in tipc_disc_init_msg() and it is a protocol message.
How can the peer send a discovery message with a 24-byte header ?
>
> BUG: KMSAN: uninit-value in tipc_udp_msg2addr (net/tipc/udp_media.c:129)
> tipc_udp_msg2addr (net/tipc/udp_media.c:129 net/tipc/udp_media.c:159)
> tipc_disc_rcv (net/tipc/discover.c:227)
> tipc_rcv (net/tipc/node.c:2136)
> tipc_udp_recv (net/tipc/udp_media.c:389)
> udp_queue_rcv_one_skb (net/ipv4/udp.c:2433)
> udp_queue_rcv_skb (net/ipv4/udp.c:2473)
> Uninit was created at:
> kmem_cache_alloc_node_noprof (mm/slub.c:5105)
> __alloc_skb (net/core/skbuff.c:616 net/core/skbuff.c:716)
>
>Discovery messages have been sent with a MAX_H_SIZE header since commit
>948fa2d115c5 ("tipc: increase size of tipc discovery messages"), and with the
>node identity after it when TIPC_NODE_ID128 is set. Drop the shorter ones.
>
>Fixes: b97bf3fd8f6a ("[TIPC] Initial merge")
>Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
>---
>The issue was found by an LLM-guided test generator that we are developing
>as a research prototype: as an unprivileged user in its own user and network
>namespace, it enables a UDP bearer and sends it a discovery message with a
>24-byte header. KASAN stays quiet, as the bytes read are in the skb's tailroom;
>KMSAN reports them as above, and the kernel logs "Rcv corrupt discovery
>message" for the address built from them.
>
>The patch was written with LLM assistance; we reviewed and tested it.
>With it, the short message is dropped without KMSAN reports, and two
>namespaces joined by a veth pair with UDP bearers still discover each other
>and bring the link up.
>
> net/tipc/discover.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/net/tipc/discover.c b/net/tipc/discover.c index
>b9d06595b067..0f99e4af1cfa 100644
>--- a/net/tipc/discover.c
>+++ b/net/tipc/discover.c
>@@ -219,6 +219,12 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
> }
> hdr = buf_msg(skb);
>
>+ if (msg_hdr_sz(hdr) < MAX_H_SIZE ||
As sashiko pointed out, the lecacy node (before commit 948fa2d115c5 ("tipc: increase size of tipc discovery
messages") sends 40-byte header. The above check will drop that discovery message. This breaks our compatibility rule.
---
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] tipc: drop discovery messages shorter than the fields they carry
2026-11-24 7:52 [PATCH net] tipc: drop discovery messages shorter than the fields they carry Kyuwon Cho
2026-11-25 8:21 ` netdev-bot+sashiko
2026-11-25 9:44 ` Tung Quang Nguyen
@ 2026-11-25 15:55 ` Kyuwon Cho
2 siblings, 0 replies; 4+ messages in thread
From: Kyuwon Cho @ 2026-11-25 15:55 UTC (permalink / raw)
To: Tung Quang Nguyen
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, tipc-discussion, linux-kernel, Jon Maloy
Hi Tung,
On Wed, Nov 25, 2026 at 09:44:59AM +0000, Tung Quang Nguyen wrote:
> Discovery message's header size (MAX_H_SIZE == 60) is stated in tipc_disc_init_msg() and it is a protocol message.
> How can the peer send a discovery message with a 24-byte header ?
A TIPC node cannot. Anyone who can reach the bearer can, though: the
message in our test is built by hand and sent as a plain UDP datagram
to the bearer's port, with no TIPC node involved.
> As sashiko pointed out, the lecacy node (before commit 948fa2d115c5 ("tipc: increase size of tipc discovery
> messages") sends 40-byte header. The above check will drop that discovery message. This breaks our compatibility rule.
Since forged discovery messages are outside TIPC's model, I'll drop
this patch.
Thanks,
Kyuwon
^ permalink raw reply [flat|nested] 4+ messages in thread