From: Hui Peng <benquike@gmail.com>
To: jmaloy@redhat.com, tung.quang.nguyen@est.tech,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: horms@kernel.org, netdev@vger.kernel.org,
tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: [PATCH] tipc: fix TLV out-of-bounds read in tipc_nl_compat_net_set() and depth mask
Date: Sat, 19 Sep 2026 21:28:57 +0000 [thread overview]
Message-ID: <20260919212857.3241483-1-benquike@gmail.com> (raw)
Fix two validation flaws in `net/tipc/netlink_compat.c`:
1. `tipc_nl_compat_net_set()` (`TIPC_CMD_SET_NETID` /
`TIPC_CMD_SET_NODE_ADDR`) unconditionally dereferences `*(__be32
*)TLV_DATA(msg->req)` without verifying that
`TLV_GET_DATA_LEN(msg->req) >= sizeof(__be32)` (4 bytes), reading 4
bytes past the end of a 0-byte TLV payload (`tlv_len == 4`).
2. In `tipc_nl_compat_name_table_dump_header()` and
`tipc_nl_compat_name_table_dump()`, `ntq->depth` can contain the high
flag bit `TIPC_NTQ_ALLTYPES` (`0x80000000`).
`tipc_nl_compat_name_table_dump_header()` compares `depth > 4`
without masking off `TIPC_NTQ_ALLTYPES` first (always clamping
`depth` to 4 whenever `TIPC_NTQ_ALLTYPES` is set, even if the low
depth bits are `1`), and `tipc_nl_compat_name_table_dump()` checks
`depth > 1` and `depth > 2` with `TIPC_NTQ_ALLTYPES` still set in
`depth`. Mask off `TIPC_NTQ_ALLTYPES` after testing it.
Fixes: d7cc75d3cb6b ("tipc: convert legacy nl node addr set to nl compat")
Fixes: 44a8ae94fd55 ("tipc: convert legacy nl name table dump to nl compat")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
net/tipc/netlink_compat.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index d9a4f94ea2d4..9b2d93704e23 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -881,7 +881,7 @@ static int tipc_nl_compat_name_table_dump_header(struct tipc_nl_compat_msg *msg)
if (TLV_GET_DATA_LEN(msg->req) < (int)sizeof(struct tipc_name_table_query))
return -EINVAL;
- depth = ntohl(ntq->depth);
+ depth = ntohl(ntq->depth) & ~TIPC_NTQ_ALLTYPES;
if (depth > 4)
depth = 4;
@@ -932,6 +932,7 @@ static int tipc_nl_compat_name_table_dump(struct tipc_nl_compat_msg *msg,
if (!(depth & TIPC_NTQ_ALLTYPES) &&
(type != nla_get_u32(publ[TIPC_NLA_PUBL_TYPE])))
return 0;
+ depth &= ~TIPC_NTQ_ALLTYPES;
if (lowbound && (lowbound > nla_get_u32(publ[TIPC_NLA_PUBL_UPPER])))
return 0;
if (upbound && (upbound < nla_get_u32(publ[TIPC_NLA_PUBL_LOWER])))
@@ -1139,6 +1140,9 @@ static int tipc_nl_compat_net_set(struct tipc_nl_compat_cmd_doit *cmd,
u32 val;
struct nlattr *net;
+ if (TLV_GET_DATA_LEN(msg->req) < (int)sizeof(__be32))
+ return -EINVAL;
+
val = ntohl(*(__be32 *)TLV_DATA(msg->req));
net = nla_nest_start_noflag(skb, TIPC_NLA_NET);
--
2.55.0.1082.g2b9226bbc0-goog
reply other threads:[~2026-09-19 21:28 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=20260919212857.3241483-1-benquike@gmail.com \
--to=benquike@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=tung.quang.nguyen@est.tech \
/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
all inboxes | Powered by JetHome®