Netdev List
 help / color / mirror / Atom feed
From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: Jon Maloy <jmaloy@redhat.com>,
	Tung Quang Nguyen <tung.quang.nguyen@est.tech>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	Ying Xue <ying.xue@windriver.com>,
	netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net
Subject: [PATCH net] tipc: check the monitor record length before reading it
Date: Wed, 25 Nov 2026 11:04:50 +0900	[thread overview]
Message-ID: <179553307368.1670514.4694378910047786259@gmail.com> (raw)

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


                 reply	other threads:[~2026-11-25  2:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=179553307368.1670514.4694378910047786259@gmail.com \
    --to=kyuwoncho18@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jmaloy@redhat.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tipc-discussion@lists.sourceforge.net \
    --cc=tung.quang.nguyen@est.tech \
    --cc=willemb@google.com \
    --cc=ying.xue@windriver.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