Merge tag 'v5.15' into android-mainline
Linux 5.15 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I81d96ada6b66bcf73d192ddde9018f1804e7d90b
This commit is contained in:
@@ -81,6 +81,7 @@
|
||||
#include <trace/hooks/net.h>
|
||||
|
||||
#include "datagram.h"
|
||||
#include "sock_destructor.h"
|
||||
|
||||
struct kmem_cache *skbuff_head_cache __ro_after_init;
|
||||
static struct kmem_cache *skbuff_fclone_cache __ro_after_init;
|
||||
@@ -1806,30 +1807,39 @@ EXPORT_SYMBOL(skb_realloc_headroom);
|
||||
struct sk_buff *skb_expand_head(struct sk_buff *skb, unsigned int headroom)
|
||||
{
|
||||
int delta = headroom - skb_headroom(skb);
|
||||
int osize = skb_end_offset(skb);
|
||||
struct sock *sk = skb->sk;
|
||||
|
||||
if (WARN_ONCE(delta <= 0,
|
||||
"%s is expecting an increase in the headroom", __func__))
|
||||
return skb;
|
||||
|
||||
/* pskb_expand_head() might crash, if skb is shared */
|
||||
if (skb_shared(skb)) {
|
||||
delta = SKB_DATA_ALIGN(delta);
|
||||
/* pskb_expand_head() might crash, if skb is shared. */
|
||||
if (skb_shared(skb) || !is_skb_wmem(skb)) {
|
||||
struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
|
||||
|
||||
if (likely(nskb)) {
|
||||
if (skb->sk)
|
||||
skb_set_owner_w(nskb, skb->sk);
|
||||
consume_skb(skb);
|
||||
} else {
|
||||
kfree_skb(skb);
|
||||
}
|
||||
if (unlikely(!nskb))
|
||||
goto fail;
|
||||
|
||||
if (sk)
|
||||
skb_set_owner_w(nskb, sk);
|
||||
consume_skb(skb);
|
||||
skb = nskb;
|
||||
}
|
||||
if (skb &&
|
||||
pskb_expand_head(skb, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) {
|
||||
kfree_skb(skb);
|
||||
skb = NULL;
|
||||
if (pskb_expand_head(skb, delta, 0, GFP_ATOMIC))
|
||||
goto fail;
|
||||
|
||||
if (sk && is_skb_wmem(skb)) {
|
||||
delta = skb_end_offset(skb) - osize;
|
||||
refcount_add(delta, &sk->sk_wmem_alloc);
|
||||
skb->truesize += delta;
|
||||
}
|
||||
return skb;
|
||||
|
||||
fail:
|
||||
kfree_skb(skb);
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(skb_expand_head);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user