Skip to content

Commit 172cf7f

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-4.18.0-553.16.1.el8_10 commit-author Felix Fietkau <[email protected]> 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 <[email protected]> Signed-off-by: David S. Miller <[email protected]> (cherry picked from commit d091e57) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 757e4df commit 172cf7f

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
@@ -1727,11 +1727,17 @@ static inline int skb_alloc_rx_flag(const struct sk_buff *skb)
17271727

17281728
struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
17291729
{
1730-
int headerlen = skb_headroom(skb);
1731-
unsigned int size = skb_end_offset(skb) + skb->data_len;
1732-
struct sk_buff *n = __alloc_skb(size, gfp_mask,
1733-
skb_alloc_rx_flag(skb), NUMA_NO_NODE);
1730+
struct sk_buff *n;
1731+
unsigned int size;
1732+
int headerlen;
1733+
1734+
if (WARN_ON_ONCE(skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST))
1735+
return NULL;
17341736

1737+
headerlen = skb_headroom(skb);
1738+
size = skb_end_offset(skb) + skb->data_len;
1739+
n = __alloc_skb(size, gfp_mask,
1740+
skb_alloc_rx_flag(skb), NUMA_NO_NODE);
17351741
if (!n)
17361742
return NULL;
17371743

@@ -1961,12 +1967,17 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
19611967
/*
19621968
* Allocate the copy buffer
19631969
*/
1964-
struct sk_buff *n = __alloc_skb(newheadroom + skb->len + newtailroom,
1965-
gfp_mask, skb_alloc_rx_flag(skb),
1966-
NUMA_NO_NODE);
1967-
int oldheadroom = skb_headroom(skb);
19681970
int head_copy_len, head_copy_off;
1971+
struct sk_buff *n;
1972+
int oldheadroom;
1973+
1974+
if (WARN_ON_ONCE(skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST))
1975+
return NULL;
19691976

1977+
oldheadroom = skb_headroom(skb);
1978+
n = __alloc_skb(newheadroom + skb->len + newtailroom,
1979+
gfp_mask, skb_alloc_rx_flag(skb),
1980+
NUMA_NO_NODE);
19701981
if (!n)
19711982
return NULL;
19721983

0 commit comments

Comments
 (0)