Skip to content

Commit b90ddd5

Browse files
wdebruijdavem330
authored andcommitted
skbuff: skb_copy_ubufs must release uarg even without user frags
skb_copy_ubufs creates a private copy of frags[] to release its hold on user frags, then calls uarg->callback to notify the owner. Call uarg->callback even when no frags exist. This edge case can happen when zerocopy_sg_from_iter finds enough room in skb_headlen to copy all the data. Fixes: 3ece782 ("sock: skb_copy_ubufs support for compound pages") Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 268b790 commit b90ddd5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/core/skbuff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
11781178
u32 d_off;
11791179

11801180
if (!num_frags)
1181-
return 0;
1181+
goto release;
11821182

11831183
if (skb_shared(skb) || skb_unclone(skb, gfp_mask))
11841184
return -EINVAL;
@@ -1238,6 +1238,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
12381238
__skb_fill_page_desc(skb, new_frags - 1, head, 0, d_off);
12391239
skb_shinfo(skb)->nr_frags = new_frags;
12401240

1241+
release:
12411242
skb_zcopy_clear(skb, false);
12421243
return 0;
12431244
}

0 commit comments

Comments
 (0)