* [PATCH net v5] ieee802154: 6lowpan: validate fragment offset against datagram size
@ 2026-11-24 7:45 Ryan Prinz
2026-11-26 19:40 ` Alexander Aring
2026-11-30 3:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Ryan Prinz @ 2026-11-24 7:45 UTC (permalink / raw)
To: linux-wpan, netdev
Cc: Alexander Aring, Stefan Schmidt, Miquel Raynal, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
linux-kernel, Ryan Prinz
A 6LoWPAN fragment carries the datagram's total size (d_size) and its
own offset within it. lowpan_frag_queue() never checks that the
offset, or offset plus length, fits inside d_size, and never rejects
an empty fragment.
A datagram is considered complete once enough bytes have been counted
(fq->q.meat) toward d_size, regardless of whether those bytes actually
form a contiguous range. So an out-of-range or empty fragment's length
still counts toward completion, even though it doesn't belong anywhere
in the datagram.
IPv6's ip6_frag_queue() already bounds each fragment's end against
IPV6_MAXPLEN and rejects zero-length fragments; 6LoWPAN had no
equivalent checks.
Fixed by rejecting any fragment that is empty, or whose offset (or
offset + length) exceeds d_size.
Fixes: 7240cdec60b1 ("6lowpan: handling 6lowpan fragmentation via inet_frag api")
Signed-off-by: Ryan Prinz <rc4d5a@protonmail.com>
---
v5:
- Resent as a new thread instead of in reply to the v1 thread, per
Jakub Kicinski's request. No content changes from v4.
v4:
- Added a check for zero-length fragments (!skb->len), which the
previous check missed. ip6_frag_queue() and nf_ct_frag6_queue()
already reject these; this patch now does too.
- Reworded the impact description to stop claiming one specific
mechanism for how an out-of-range fragment causes harm. A
separate, pre-existing bug elsewhere in the reassembly code made
that mechanism unreliable; it's left out of scope here and will
be addressed on its own.
Reproduced two ways: with a local kernel module calling
lowpan_frag_rcv() directly, and over mac802154_hwsim with three
independent processes standing in for sender, receiver and attacker.
An attacker in radio range who observes one fragment of an
in-progress transmission reads d_tag, d_size and the addressing in the
clear, then sends a single out-of-range fragment of its own before the
legitimate fragment for that span arrives. In this arrival order, the
receiver's reassembly completed with the attacker's bytes included in
the final buffer instead of the out-of-range fragment being rejected.
Both reproducers were re-run against this fix to confirm the
out-of-range fragment is now rejected outright.
AI Disclosure: An AI assistant (Claude) was used to assist with the
analysis and testing. I have verified the vulnerability, the fix, and
the test results myself and take responsibility for this contribution,
per Documentation/process/coding-assistants.rst.
net/ieee802154/6lowpan/reassembly.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c
index ddb6a5817d09..4edd307000c8 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -103,6 +103,9 @@ static int lowpan_frag_queue(struct lowpan_frag_queue *fq,
offset = lowpan_802154_cb(skb)->d_offset << 3;
end = lowpan_802154_cb(skb)->d_size;
+ if (!skb->len || offset > end || skb->len > end - offset)
+ goto err;
+
/* Is this the final fragment? */
if (offset + skb->len == end) {
/* If we already have some bits beyond end
--
2.51.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v5] ieee802154: 6lowpan: validate fragment offset against datagram size
2026-11-24 7:45 [PATCH net v5] ieee802154: 6lowpan: validate fragment offset against datagram size Ryan Prinz
@ 2026-11-26 19:40 ` Alexander Aring
2026-11-30 3:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Aring @ 2026-11-26 19:40 UTC (permalink / raw)
To: Ryan Prinz
Cc: linux-wpan, netdev, Alexander Aring, Stefan Schmidt,
Miquel Raynal, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, linux-kernel
Hi,
On Tue, Nov 24, 2026 at 2:46 AM Ryan Prinz <rc4d5a@protonmail.com> wrote:
>
> A 6LoWPAN fragment carries the datagram's total size (d_size) and its
> own offset within it. lowpan_frag_queue() never checks that the
> offset, or offset plus length, fits inside d_size, and never rejects
> an empty fragment.
>
> A datagram is considered complete once enough bytes have been counted
> (fq->q.meat) toward d_size, regardless of whether those bytes actually
> form a contiguous range. So an out-of-range or empty fragment's length
> still counts toward completion, even though it doesn't belong anywhere
> in the datagram.
>
> IPv6's ip6_frag_queue() already bounds each fragment's end against
> IPV6_MAXPLEN and rejects zero-length fragments; 6LoWPAN had no
> equivalent checks.
There is a check [0] to reject d_size above IPV6_MIN_MTU (max ipv6
ressambled packet size), so checking if the offset is in d_size should
be fine and we have something equivalent here.
>
> Fixed by rejecting any fragment that is empty, or whose offset (or
> offset + length) exceeds d_size.
>
> Fixes: 7240cdec60b1 ("6lowpan: handling 6lowpan fragmentation via inet_frag api")
> Signed-off-by: Ryan Prinz <rc4d5a@protonmail.com>
Acked-by: Alexander Aring <aahringo@redhat.com>
Thanks!
- Alex
[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ieee802154/6lowpan/reassembly.c?h=v7.4-rc4#n302
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v5] ieee802154: 6lowpan: validate fragment offset against datagram size
2026-11-24 7:45 [PATCH net v5] ieee802154: 6lowpan: validate fragment offset against datagram size Ryan Prinz
2026-11-26 19:40 ` Alexander Aring
@ 2026-11-30 3:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-30 3:50 UTC (permalink / raw)
To: Ryan Prinz
Cc: linux-wpan, netdev, alex.aring, stefan, miquel.raynal, davem,
edumazet, kuba, pabeni, horms, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:
On Tue, 24 Nov 2026 07:45:51 +0000 you wrote:
> A 6LoWPAN fragment carries the datagram's total size (d_size) and its
> own offset within it. lowpan_frag_queue() never checks that the
> offset, or offset plus length, fits inside d_size, and never rejects
> an empty fragment.
>
> A datagram is considered complete once enough bytes have been counted
> (fq->q.meat) toward d_size, regardless of whether those bytes actually
> form a contiguous range. So an out-of-range or empty fragment's length
> still counts toward completion, even though it doesn't belong anywhere
> in the datagram.
>
> [...]
Here is the summary with links:
- [net,v5] ieee802154: 6lowpan: validate fragment offset against datagram size
https://git.kernel.org/netdev/net/c/9e16b3557ced
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 3:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 7:45 [PATCH net v5] ieee802154: 6lowpan: validate fragment offset against datagram size Ryan Prinz
2026-11-26 19:40 ` Alexander Aring
2026-11-30 3:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox