Commit 37d17dc
committed
net: fix OOB reads and unbounded growth in IPv6 net-channel classifier and DHCPv6 client
Security hardening for the two network-reachable memory-safety issues in the
new IPv6/DHCPv6 code (found in audit):
1. classify_ipv6_tcp() OOB read (core/net_channel.cc). ip6_lasthdr_nofrag only
guarantees the base IPv6 header + extension headers fit; it did NOT
guarantee a full TCP header is present and contiguous, yet the code then
dereferenced tcp_hdr (th_flags at +13, ports at +0..3) on the lock-free RX
fast path. A crafted IPv6/TCP frame (short, or with extension headers
pushing the L4 offset toward the end, or split across a mergeable-buffer
mbuf chain via GRO/jumbo) could read out of bounds in the driver softirq.
Require nxt_off + sizeof(tcphdr) <= mh_len before touching the TCP header;
otherwise fall through to the slow path (tcp_input), which pulls up.
2. DHCPv6 parse() OOB read across an mbuf chain (bsd/porting/dhcp6.cc). The
option walk bounded off against pkthdr.len (whole chain) while reading via
mtod (first mbuf only); udp6_input makes only the UDP header contiguous. A
malicious on-link DHCPv6 server (DHCPv6 is unauthenticated; the client is
auto-started on a Managed-flag RA) sending a >4 KiB reply on a jumbo/GRO
link becomes an mbuf chain and the walk reads past the first mbuf. Clamp
blen to the contiguous first-mbuf length (a well-formed reply is far smaller
than one RX buffer).
3. DHCPv6 unbounded state growth (DoS). process_packet() parsed every packet
even when BOUND, and parse() appended to _dns/_server_duid, so an on-link
attacker who observed our SOLICIT xid could spray REPLYs and grow those
without bound. Ignore packets outside SOLICITING/REQUESTING, and reset the
per-reply learned state only after the xid matches (so a spoofed packet
cannot wipe good state and repeated replies do not accumulate).
Verified: IPv6 loopback + dual-stack TCP smoke still passes.1 parent 1ef2c3a commit 37d17dc
2 files changed
Lines changed: 39 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
276 | 287 | | |
277 | 288 | | |
278 | 289 | | |
| |||
281 | 292 | | |
282 | 293 | | |
283 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
284 | 301 | | |
285 | 302 | | |
286 | 303 | | |
| |||
358 | 375 | | |
359 | 376 | | |
360 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
361 | 386 | | |
362 | 387 | | |
363 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
288 | 301 | | |
289 | 302 | | |
290 | 303 | | |
| |||
0 commit comments