* [PATCH net] tipc: reject bundles too short for an inner header
@ 2026-11-28 14:08 Andrew Stellman
0 siblings, 0 replies; only message in thread
From: Andrew Stellman @ 2026-11-28 14:08 UTC (permalink / raw)
To: Jon Maloy, Tung Quang Nguyen
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, tipc-discussion, linux-kernel
From: Andrew Stellman <astellman@stellman-greene.com>
tipc_msg_extract() checks *pos against msg_data_sz(hdr) - MIN_H_SIZE.
msg_data_sz() is unsigned, so for a header-only MSG_BUNDLER, which
tipc_msg_validate() accepts, the subtraction wraps and the check
passes. The following msg_size(ihdr) then reads four bytes past the
end of the bundle. Check that the data can hold an inner header
before subtracting.
Tested on mainline (7cd8495c0f16) in arm64 QEMU with KASAN. A test-only
debugfs hook, not part of this patch, built a header-only bundle in the
kernel, passed it to tipc_msg_validate() and tipc_msg_extract(), and
poisoned 8 bytes of tailroom after it as a redzone so KASAN would flag
the read. No live TIPC link was used, and the bundle didn't come from a
peer. Without this patch KASAN reported a 4 byte read in
tipc_msg_extract() in both of two runs; with it, none in one run. A
bundle holding one valid 24 byte message was extracted the same way in
all three runs. No selftests were run.
Fixes: ef9be755697f ("tipc: eliminate buffer cloning in function tipc_msg_extract()")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
The issue was found by Claude Opus 5.5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
Claude Opus 5.5, and both were reviewed by me.
A reproducer is available on request.
net/tipc/msg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 39dfd33c8eecc8..657c0709a0f7a1 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -600,7 +600,8 @@ bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos)
goto none;
hdr = buf_msg(skb);
- if (unlikely(*pos > (msg_data_sz(hdr) - MIN_H_SIZE)))
+ if (unlikely(msg_data_sz(hdr) < MIN_H_SIZE ||
+ *pos > (msg_data_sz(hdr) - MIN_H_SIZE)))
goto none;
ihdr = (struct tipc_msg *)(msg_data(hdr) + *pos);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-28 14:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 14:08 [PATCH net] tipc: reject bundles too short for an inner header Andrew Stellman
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®