Skip to content

Commit 9997702

Browse files
committed
net: core: reject skb_copy(_expand) for fraglist GSO skbs
jira LE-1907 cve CVE-2024-36929 Rebuild_History Non-Buildable kernel-5.14.0-427.31.1.el9_4 commit-author Felix Fietkau <nbd@nbd.name> commit d091e57 SKB_GSO_FRAGLIST skbs must not be linearized, otherwise they become invalid. Return NULL if such an skb is passed to skb_copy or skb_copy_expand, in order to prevent a crash on a potential later call to skb_gso_segment. Fixes: 3a1296a ("net: Support GRO/GSO fraglist chaining.") Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit d091e57) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 0e70807 commit 9997702

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

net/core/skbuff.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,11 +1885,17 @@ static inline int skb_alloc_rx_flag(const struct sk_buff *skb)
18851885

18861886
struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
18871887
{
1888-
int headerlen = skb_headroom(skb);
1889-
unsigned int size = skb_end_offset(skb) + skb->data_len;
1890-
struct sk_buff *n = __alloc_skb(size, gfp_mask,
1891-
skb_alloc_rx_flag(skb), NUMA_NO_NODE);
1888+
struct sk_buff *n;
1889+
unsigned int size;
1890+
int headerlen;
1891+
1892+
if (WARN_ON_ONCE(skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST))
1893+
return NULL;
18921894

1895+
headerlen = skb_headroom(skb);
1896+
size = skb_end_offset(skb) + skb->data_len;
1897+
n = __alloc_skb(size, gfp_mask,
1898+
skb_alloc_rx_flag(skb), NUMA_NO_NODE);
18931899
if (!n)
18941900
return NULL;
18951901

@@ -2203,12 +2209,17 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
22032209
/*
22042210
* Allocate the copy buffer
22052211
*/
2206-
struct sk_buff *n = __alloc_skb(newheadroom + skb->len + newtailroom,
2207-
gfp_mask, skb_alloc_rx_flag(skb),
2208-
NUMA_NO_NODE);
2209-
int oldheadroom = skb_headroom(skb);
22102212
int head_copy_len, head_copy_off;
2213+
struct sk_buff *n;
2214+
int oldheadroom;
2215+
2216+
if (WARN_ON_ONCE(skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST))
2217+
return NULL;
22112218

2219+
oldheadroom = skb_headroom(skb);
2220+
n = __alloc_skb(newheadroom + skb->len + newtailroom,
2221+
gfp_mask, skb_alloc_rx_flag(skb),
2222+
NUMA_NO_NODE);
22122223
if (!n)
22132224
return NULL;
22142225

0 commit comments

Comments
 (0)