From: Michael Bommarito <michael.bommarito@gmail.com>
To: Jon Maloy <jmaloy@redhat.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Ying Xue <ying.xue@windriver.com>,
netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: [PATCH net 2/4] tipc: validate discovery message length before reading media address
Date: Tue, 2 Jun 2026 09:35:53 -0400 [thread overview]
Message-ID: <20260602133555.769727-3-michael.bommarito@gmail.com> (raw)
In-Reply-To: <20260602133555.769727-1-michael.bommarito@gmail.com>
tipc_disc_rcv() reads the sender's media address from the fixed
media-info area of the header (msg_media_addr(), offset
TIPC_MEDIA_INFO_OFFSET) and, when the peer advertises 128-bit node
ids, copies a NODE_ID_LEN node id appended after the header. Neither
read is bounded against the actual received length: tipc_msg_validate()
only enforces a header size in the range [MIN_H_SIZE, MAX_H_SIZE], so a
LINK_CONFIG message as short as MIN_H_SIZE (24 bytes) passes validation
while the media-address read reaches up to MAX_H_SIZE and the node-id
read reaches MAX_H_SIZE + NODE_ID_LEN.
A node always builds discovery messages at MAX_H_SIZE + NODE_ID_LEN
(tipc_disc_init_msg()), so a shorter LINK_CONFIG message is malformed.
Drop such messages before the reads so the media address and node id
are taken from received data rather than from uninitialised tail room
or memory beyond the buffer.
A crafted short LINK_CONFIG datagram otherwise makes tipc_disc_rcv()
read past the received message data when a bearer is enabled.
Fixes: 3d749a6a26b0 ("tipc: Hide media-specific addressing details from generic bearer code")
Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
---
net/tipc/discover.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 3e54d2df5683a..daf5f11fc82b4 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -217,6 +217,20 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
}
hdr = buf_msg(skb);
+ /* A discovery message carries the sender's media address within the
+ * fixed-size header and, when 128-bit ids are advertised, a node id
+ * appended after it. A node always builds these messages at
+ * MAX_H_SIZE + NODE_ID_LEN, so drop anything too short to hold what
+ * is read below and keep msg2addr() and the node-id copy within the
+ * received data.
+ */
+ if (skb->len < MAX_H_SIZE ||
+ ((caps & TIPC_NODE_ID128) && skb->len < MAX_H_SIZE + NODE_ID_LEN)) {
+ pr_warn_ratelimited("Rcv corrupt discovery message\n");
+ kfree_skb(skb);
+ return;
+ }
+
if (caps & TIPC_NODE_ID128)
memcpy(peer_id, msg_node_id(hdr), NODE_ID_LEN);
else
--
2.53.0
next prev parent reply other threads:[~2026-06-02 13:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 13:35 [PATCH net 0/4] tipc: fix missing netlink admin gate and receive-path bugs Michael Bommarito
2026-06-02 13:35 ` [PATCH net 1/4] tipc: require net admin for TIPCv2 netlink mutators Michael Bommarito
2026-06-02 13:35 ` Michael Bommarito [this message]
2026-06-02 13:35 ` [PATCH net 3/4] tipc: prevent snt_unacked underflow on CONN_ACK Michael Bommarito
2026-06-02 13:35 ` [PATCH net 4/4] tipc: reject inverted service ranges from peer bindings Michael Bommarito
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=20260602133555.769727-3-michael.bommarito@gmail.com \
--to=michael.bommarito@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tipc-discussion@lists.sourceforge.net \
--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