diff options
author | Eric Dumazet <edumazet@google.com> | 2017-04-26 12:09:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-30 22:23:16 -0400 |
commit | d1f496fd8f34a40458d0eda6be0655926559e546 (patch) | |
tree | 06b7b187db463b7e59a63e20498e5a57027399d1 /net/core | |
parent | ae3696c167cc04d32634c4af82f43b446c5176b0 (diff) |
bpf: restore skb->sk before pskb_trim() call
While testing a fix [1] in ___pskb_trim(), addressing the WARN_ON_ONCE()
in skb_try_coalesce() reported by Andrey, I found that we had an skb
with skb->sk set but no skb->destructor.
This invalidated heuristic found in commit 158f323b9868 ("net: adjust
skb->truesize in pskb_expand_head()") and in cited patch.
Considering the BUG_ON(skb->sk) we have in skb_orphan(), we should
restrain the temporary setting to a minimal section.
[1] https://patchwork.ozlabs.org/patch/755570/
net: adjust skb->truesize in ___pskb_trim()
Fixes: 8f917bba0042 ("bpf: pass sk to helper functions")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/filter.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/core/filter.c b/net/core/filter.c index 9a37860a80fc..a253a6197e6b 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -98,8 +98,8 @@ int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap) | |||
98 | 98 | ||
99 | skb->sk = sk; | 99 | skb->sk = sk; |
100 | pkt_len = bpf_prog_run_save_cb(filter->prog, skb); | 100 | pkt_len = bpf_prog_run_save_cb(filter->prog, skb); |
101 | err = pkt_len ? pskb_trim(skb, max(cap, pkt_len)) : -EPERM; | ||
102 | skb->sk = save_sk; | 101 | skb->sk = save_sk; |
102 | err = pkt_len ? pskb_trim(skb, max(cap, pkt_len)) : -EPERM; | ||
103 | } | 103 | } |
104 | rcu_read_unlock(); | 104 | rcu_read_unlock(); |
105 | 105 | ||