Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Kyuwon Cho
Wed, 25 Nov 2026 02:04
[PATCH net] tipc: check the monitor record length before reading it
Author: Kyuwon Cho
Date: Wed, 25 Nov 2026 02:04
Date: Wed, 25 Nov 2026 02:04
90 lines
14144 bytes
14144 bytes
tipc_mon_rcv() reads member_cnt, gen, ack_gen and len from the domain
record before it checks that dlen covers the record header. A node
whose monitor is not active sends its STATE messages without a record
(tipc_mon_prep() leaves dlen at 0), which is the normal case in a
cluster below the monitoring threshold, so the receiver reads these
fields past the end of every such message:
BUG: KMSAN: uninit-value in tipc_mon_rcv (net/tipc/monitor.c:499)
tipc_mon_rcv (net/tipc/monitor.c:499)
tipc_link_proto_rcv (net/tipc/link.c:2301)
tipc_link_rcv (net/tipc/link.c:1773)
tipc_rcv (net/tipc/node.c:2174)
tipc_udp_recv (net/tipc/udp_media.c:389)
udp_queue_rcv_one_skb (net/ipv4/udp.c:2433)
Uninit was created at:
__alloc_skb (net/core/skbuff.c:716)
tipc_msg_create (net/tipc/msg.c:104)
tipc_link_build_proto_msg (net/tipc/link.c:1857)
tipc_link_proto_rcv (net/tipc/link.c:2311)
Read the fields only after the dlen check.
Fixes: 35c55c9877f8 ("tipc: add neighbor monitoring framework")
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. Any link between two nodes below
the monitoring threshold shows it, for example, as any user:
unshare -Urn sh -e <<'END'
unshare -n sleep 30 &
sleep 1
ip link add v0 type veth peer name v1 netns $!
ip addr add 10.0.0.1/24 dev v0
ip link set v0 up
nsenter -t $! -n ip addr add 10.0.0.2/24 dev v1
nsenter -t $! -n ip link set v1 up
tipc bearer enable media udp name b localip 10.0.0.1 remoteip 10.0.0.2
nsenter -t $! -n tipc bearer enable media udp name b localip 10.0.0.2 remoteip 10.0.0.1
sleep 5
tipc link list
END
Without the patch, KMSAN reports the uninit-value above as soon as the
link exchanges STATE messages; with it, it does not, and the link comes
up as before.
The patch was written with LLM assistance; we reviewed and tested it.
net/tipc/monitor.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 0164a034b57e..9a8b3e5010c1 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -485,21 +485,22 @@ void tipc_mon_rcv(struct net *net, void *data, u16 dlen, u32 addr,
struct tipc_mon_domain dom_bef;
struct tipc_mon_domain *dom;
struct tipc_peer *peer;
- u16 new_member_cnt = mon_le16_to_cpu(arrv_dom->member_cnt);
- int new_dlen = dom_rec_len(arrv_dom, new_member_cnt);
- u16 new_gen = mon_le16_to_cpu(arrv_dom->gen);
- u16 acked_gen = mon_le16_to_cpu(arrv_dom->ack_gen);
- u16 arrv_dlen = mon_le16_to_cpu(arrv_dom->len);
+ u16 new_member_cnt, new_gen, acked_gen, arrv_dlen;
bool probing = state->probing;
- int i, applied_bef;
+ int i, applied_bef, new_dlen;
state->probing = false;
/* Sanity check received domain record */
- if (new_member_cnt > MAX_MON_DOMAIN)
- return;
if (dlen < dom_rec_len(arrv_dom, 0))
return;
+ new_member_cnt = mon_le16_to_cpu(arrv_dom->member_cnt);
+ new_dlen = dom_rec_len(arrv_dom, new_member_cnt);
+ new_gen = mon_le16_to_cpu(arrv_dom->gen);
+ acked_gen = mon_le16_to_cpu(arrv_dom->ack_gen);
+ arrv_dlen = mon_le16_to_cpu(arrv_dom->len);
+ if (new_member_cnt > MAX_MON_DOMAIN)
+ return;
if (dlen != dom_rec_len(arrv_dom, new_member_cnt))
return;
if (dlen < new_dlen || arrv_dlen != new_dlen)
--
2.43.0
RE: [PATCH net] tipc: check the monitor record length before reading it
Author: Tung Quang Nguyen
Date: Thu, 26 Nov 2026 08:28
Date: Thu, 26 Nov 2026 08:28
82 lines
20218 bytes
20218 bytes
>Subject: [PATCH net] tipc: check the monitor record length before reading it
>
>tipc_mon_rcv() reads member_cnt, gen, ack_gen and len from the domain
>record before it checks that dlen covers the record header. A node whose
>monitor is not active sends its STATE messages without a record
>(tipc_mon_prep() leaves dlen at 0), which is the normal case in a cluster below
>the monitoring threshold, so the receiver reads these fields past the end of
>every such message:
>
> BUG: KMSAN: uninit-value in tipc_mon_rcv (net/tipc/monitor.c:499)
> tipc_mon_rcv (net/tipc/monitor.c:499)
> tipc_link_proto_rcv (net/tipc/link.c:2301)
> tipc_link_rcv (net/tipc/link.c:1773)
> tipc_rcv (net/tipc/node.c:2174)
> tipc_udp_recv (net/tipc/udp_media.c:389)
> udp_queue_rcv_one_skb (net/ipv4/udp.c:2433)
> Uninit was created at:
> __alloc_skb (net/core/skbuff.c:716)
> tipc_msg_create (net/tipc/msg.c:104)
> tipc_link_build_proto_msg (net/tipc/link.c:1857)
> tipc_link_proto_rcv (net/tipc/link.c:2311)
>
>Read the fields only after the dlen check.
>
>Fixes: 35c55c9877f8 ("tipc: add neighbor monitoring framework")
>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. Any link between two nodes below the monitoring
>threshold shows it, for example, as any user:
>
>unshare -Urn sh -e <<'END'
>unshare -n sleep 30 &
>sleep 1
>ip link add v0 type veth peer name v1 netns $!
>ip addr add 10.0.0.1/24 dev v0
>ip link set v0 up
>nsenter -t $! -n ip addr add 10.0.0.2/24 dev v1 nsenter -t $! -n ip link set v1 up
>tipc bearer enable media udp name b localip 10.0.0.1 remoteip 10.0.0.2
>nsenter -t $! -n tipc bearer enable media udp name b localip 10.0.0.2 remoteip
>10.0.0.1 sleep 5 tipc link list END
>
>Without the patch, KMSAN reports the uninit-value above as soon as the link
>exchanges STATE messages; with it, it does not, and the link comes up as
>before.
>
>The patch was written with LLM assistance; we reviewed and tested it.
>
> net/tipc/monitor.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
>diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c index
>0164a034b57e..9a8b3e5010c1 100644
>--- a/net/tipc/monitor.c
>+++ b/net/tipc/monitor.c
>@@ -485,21 +485,22 @@ void tipc_mon_rcv(struct net *net, void *data, u16
>dlen, u32 addr,
> struct tipc_mon_domain dom_bef;
> struct tipc_mon_domain *dom;
> struct tipc_peer *peer;
>- u16 new_member_cnt = mon_le16_to_cpu(arrv_dom->member_cnt);
>- int new_dlen = dom_rec_len(arrv_dom, new_member_cnt);
>- u16 new_gen = mon_le16_to_cpu(arrv_dom->gen);
>- u16 acked_gen = mon_le16_to_cpu(arrv_dom->ack_gen);
>- u16 arrv_dlen = mon_le16_to_cpu(arrv_dom->len);
>+ u16 new_member_cnt, new_gen, acked_gen, arrv_dlen;
> bool probing = state->probing;
>- int i, applied_bef;
>+ int i, applied_bef, new_dlen;
Please restructure above variable declarations that follows "reverse xmas tree" style.
---
pw-bot: cr
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads