Subject: Re: [PATCH RESEND net v2 1/1] net/sched: sch_netem: fix out-of-bounds access in packet corruption

From: Stephen Hemminger <[email-masked]>
Date: Wed, 1 Apr 2026 07:46:31 -0700

On Tue, 31 Mar 2026 16:00:21 +0800
Yucheng Lu <[email-masked]> wrote:

> In netem_enqueue(), the packet corruption logic uses
> get_random_u32_below(skb_headlen(skb)) to select an index for
> modifying skb->data. When an AF_PACKET TX_RING sends fully non-linear
> packets over an IPIP tunnel, skb_headlen(skb) evaluates to 0.
> 
> Passing 0 to get_random_u32_below() takes the variable-ceil slow path
> which returns an unconstrained 32-bit random integer. Using this
> unconstrained value as an offset into skb->data results in an
> out-of-bounds memory access.
> 
> Fix this by verifying skb_headlen(skb) is non-zero before attempting
> to corrupt the linear data area. Fully non-linear packets will silently
> bypass the corruption logic.
> 
> Fixes: c865e5d99e25 ("[PKT_SCHED] netem: packet corruption option")
> Reported-by: Yifan Wu <[email-masked]>
> Reported-by: Juefei Pu <[email-masked]>
> Signed-off-by: Yuan Tan <[email-masked]>
> Signed-off-by: Xin Liu <[email-masked]>
> Signed-off-by: Yuhang Zheng <[email-masked]>
> Signed-off-by: Yucheng Lu <[email-masked]>
> ---

This is the correct fix for the net tree. Will make a more robust
fix for net-next which handles non linear packets better.

Reviewed-by: Stephen Hemminger <[email-masked]>