Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cipso: harden use of skb_cow() in cipso_v4_skbuff_setattr()

If skb_cow() is passed a headroom <= -NET_SKB_PAD, it will trigger a
BUG. As a result, use cases should avoid calling with a headroom that
is negative to prevent triggering this issue.

This is the same code pattern fixed in Commit 58fc7342b529 ("ipv6:
BUG() in pskb_expand_head() as part of calipso_skbuff_setattr()").

In cipso_v4_skbuff_setattr(), len_delta can become negative, leading to
a negative headroom passed to skb_cow(). However, the BUG is not
triggerable because the condition headroom <= -NET_SKB_PAD cannot be
satisfied due to limits on the IPv4 options header size.

Avoid potential problems in the future by only using skb_cow() to grow
the skb headroom.

Signed-off-by: Will Rosenberg <whrosenb@asu.edu>
Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://patch.msgid.link/20260120155738.982771-1-whrosenb@asu.edu
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Will Rosenberg and committed by
Paolo Abeni
40cb4cb7 b6d5a622

+2 -1
+2 -1
net/ipv4/cipso_ipv4.c
··· 2196 2196 /* if we don't ensure enough headroom we could panic on the skb_push() 2197 2197 * call below so make sure we have enough, we are also "mangling" the 2198 2198 * packet so we should probably do a copy-on-write call anyway */ 2199 - ret_val = skb_cow(skb, skb_headroom(skb) + len_delta); 2199 + ret_val = skb_cow(skb, 2200 + skb_headroom(skb) + (len_delta > 0 ? len_delta : 0)); 2200 2201 if (ret_val < 0) 2201 2202 return ret_val; 2202 2203