diff options
| author | Daniel Borkmann <daniel@iogearbox.net> | 2016-02-19 23:05:25 +0100 |
|---|---|---|
| committer | Ben Hutchings <ben@decadent.org.uk> | 2017-07-18 18:40:20 +0100 |
| commit | 0c361c9410c11a75755b1889fcc24cb2ae4ddcdb (patch) | |
| tree | 4b5a3ebacc918f36c51a239dd7f6df36d8721c58 /include/linux | |
| parent | 51fb67d1b633d6b222707ac094f13706b1138a18 (diff) | |
bpf: try harder on clones when writing into skb
commit 3697649ff29e0f647565eed04b27a7779c646a22 upstream.
When we're dealing with clones and the area is not writeable, try
harder and get a copy via pskb_expand_head(). Replace also other
occurences in tc actions with the new skb_try_make_writable().
Reported-by: Ashhad Sheikh <ashhadsheikh394@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: drop changes to bpf; only tc actions need fixing]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/skbuff.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 629f519224ee..63c9d381e0d9 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2307,6 +2307,13 @@ static inline int skb_clone_writable(const struct sk_buff *skb, unsigned int len skb_headroom(skb) + len <= skb->hdr_len; } +static inline int skb_try_make_writable(struct sk_buff *skb, + unsigned int write_len) +{ + return skb_cloned(skb) && !skb_clone_writable(skb, write_len) && + pskb_expand_head(skb, 0, 0, GFP_ATOMIC); +} + static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom, int cloned) { |
