Skip to content

Commit 0ab36da

Browse files
qsnbmastbergen
authored andcommitted
net: gro: don't merge zcopy skbs
cve CVE-Pending commit-author Sabrina Dubroca <sd@queasysnail.net> commit 4db79a3 upstream-diff | Context conflict in net/core/gro.c: 5.14 uses a local gro_max_size variable lookup instead of upstream's netif_get_gro_max_size() helper. The skb_zcopy() check was added at the same location, before the gro_max_size lookup. Functionally identical to upstream. skb_gro_receive() can currently copy frags between the source and GRO skb, without checking the zerocopy status, and in particular the SKBFL_MANAGED_FRAG_REFS flag. When SKBFL_MANAGED_FRAG_REFS is set, the skb doesn't hold a reference on the pages in shinfo->frags. Appending those frags to another skb's frags without fixing up the page refcount can lead to UAF. When either the last skb in the GRO chain (the one we would append frags to) or the source skb is zerocopy, don't merge the skbs. Fixes: 753f1ca ("net: introduce managed frags infrastructure") Reported-by: Huzaifa Sidhpurwala <huzaifas@redhat.com> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/c3b7f906bbfcbdfd7b4fa9d6c18a438870df85be.1779307748.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Shreeya Patel <spatel@ciq.com>
1 parent 5e94638 commit 0ab36da

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

net/core/gro.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)
113113
if (p->pp_recycle != skb->pp_recycle)
114114
return -ETOOMANYREFS;
115115

116+
if (skb_zcopy(p) || skb_zcopy(skb))
117+
return -ETOOMANYREFS;
118+
116119
/* pairs with WRITE_ONCE() in netif_set_gro(_ipv4)_max_size() */
117120
gro_max_size = p->protocol == htons(ETH_P_IPV6) ?
118121
READ_ONCE(p->dev->gro_max_size) :

0 commit comments

Comments
 (0)