milos-linux/net/6lowpan
Yizhou Zhao 2a58899d11 6lowpan: fix off-by-one in multicast context address compression
The second memcpy in lowpan_iphc_mcast_ctx_addr_compress() uses
&data[1] as destination and &ipaddr->s6_addr[11] as source, but
both should be offset by one: &data[2] and &ipaddr->s6_addr[12]
respectively.

This off-by-one has two consequences:
1. data[1] is overwritten with s6_addr[11], corrupting the RIID
   field in the compressed multicast address
2. data[5] is never written, so uninitialized kernel stack memory
   is transmitted over the network via lowpan_push_hc_data(),
   leaking kernel stack contents

The correct inline data layout must match what the decompression
function lowpan_uncompress_multicast_ctx_daddr() expects:
  data[0..1] = s6_addr[1..2]  (flags/scope + RIID)
  data[2..5] = s6_addr[12..15] (group ID)

Also zero-initialize the data array as a defensive measure against
similar bugs in the future.

Fixes: 5609c185f2 ("6lowpan: iphc: add support for stateful compression")
Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
Reported-by: Ao Wang <wangao@seu.edu.cn>
Reported-by: Xuewei Feng <fengxw06@126.com>
Reported-by: Qi Li <qli01@tsinghua.edu.cn>
Reported-by: Ke Xu <xuke@tsinghua.edu.cn>
Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Acked-by: Alexander Aring <aahringo@redhat.com>
Link: https://patch.msgid.link/20260527081806.42747-1-zhaoyz24@mails.tsinghua.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-01 19:10:16 -07:00
..
6lowpan_i.h
core.c net: fill in MODULE_DESCRIPTION()s for 6LoWPAN 2024-02-09 14:12:01 -08:00
debugfs.c
iphc.c 6lowpan: fix off-by-one in multicast context address compression 2026-06-01 19:10:16 -07:00
Kconfig
Makefile
ndisc.c net: replace ND_PRINTK with dynamic debug 2025-07-10 15:27:32 -07:00
nhc.c net: 6lowpan: constify lowpan_nhc structures 2022-06-09 21:53:28 +02:00
nhc.h net: 6lowpan: constify lowpan_nhc structures 2022-06-09 21:53:28 +02:00
nhc_dest.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_fragment.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_ghc_ext_dest.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_ghc_ext_frag.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_ghc_ext_hop.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_ghc_ext_route.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_ghc_icmpv6.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_ghc_udp.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_hop.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_ipv6.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_mobility.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_routing.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00
nhc_udp.c net: 6lowpan: use array for find nhc id 2022-06-09 21:53:28 +02:00