mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] net: fix negative transport offset handling in GSO pkt len calculation
@ 2026-09-17 12:21 zjamg
  2026-09-17 12:21 ` [PATCH 1/2] net: fix OOB read in qdisc_pkt_len_segs_init() on negative transport offset zjamg
  2026-09-17 12:21 ` [PATCH 2/2] net/sched: sch_cake: check negative transport offset in cake_overhead() zjamg
  0 siblings, 2 replies; 3+ messages in thread
From: zjamg @ 2026-09-17 12:21 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, Toke Høiland-Jørgensen, Jamal Hadi Salim,
	Jiri Pirko, netdev, linux-kernel, zjamg

Hi,

This series fixes an out-of-bounds read and kernel crash in
qdisc_pkt_len_segs_init() (and similar borrowed logic in sch_cake) when
processing packets whose transport offset has become negative.

Both skb_transport_offset() and skb_inner_transport_offset() return a
signed int. However, qdisc_pkt_len_segs_init() stores the offset into an
unsigned int hdr_len.

When an encapsulated or tagged packet has undergone header operations
(such as skb_vlan_untag() pulling stacked VLAN tags without updating
inner_transport_header, or other header stripping that advances skb->data
past the transport header), the computed offset becomes negative.

Converting this negative int to unsigned int results in a value near
UINT_MAX (e.g. 0xFFFFFFF0). Consequently:

1. pskb_may_pull(skb, hdr_len + sizeof(struct tcphdr)) computes
   0xFFFFFFF0 + 20, which wraps around in 32-bit unsigned arithmetic to 4.
   This passes the check if skb->len >= 4, completely defeating the guard.

2. th = (const struct tcphdr *)(skb->data + hdr_len) zero-extends hdr_len
   to 64 bits, producing a wild pointer ~4 GiB past skb->data.

3. __tcp_hdrlen(th) dereferences th->doff at that address, triggering an
   immediate translation fault / KASAN wild-memory-access panic.

Patch 1 declares hdr_len as int and drops packets with negative offset
via SKB_DROP_REASON_SKB_BAD_GSO.
Patch 2 fixes the corresponding logic borrowed in sch_cake.

Thanks,
zjamg

zjamg (2):
  net: fix OOB read in qdisc_pkt_len_segs_init() on negative transport
    offset
  net/sched: sch_cake: check negative transport offset in
    cake_overhead()

 net/core/dev.c       | 5 ++++-
 net/sched/sch_cake.c | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

-- 
2.53.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-17 12:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 12:21 [PATCH 0/2] net: fix negative transport offset handling in GSO pkt len calculation zjamg
2026-09-17 12:21 ` [PATCH 1/2] net: fix OOB read in qdisc_pkt_len_segs_init() on negative transport offset zjamg
2026-09-17 12:21 ` [PATCH 2/2] net/sched: sch_cake: check negative transport offset in cake_overhead() zjamg

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®