bpf: don't enable preemption twice in smap_do_verdict
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 17 Aug 2017 15:22:36 +0000 (17:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Aug 2017 17:25:18 +0000 (10:25 -0700)
In smap_do_verdict(), the fall-through branch leads to call
preempt_enable() twice for the SK_REDIRECT, which creates an
imbalance. Only enable it for all remaining cases again.

Fixes: 174a79ff9515 ("bpf: sockmap with sk redirect support")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/sockmap.c

index f7e5e6cf124aa31e6074f805318242756ca91fe9..39de541fbcdcf96bd74432a1c0a8b3f56c4a40f6 100644 (file)
@@ -135,7 +135,8 @@ static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb)
        /* Fall through and free skb otherwise */
        case SK_DROP:
        default:
-               preempt_enable();
+               if (rc != SK_REDIRECT)
+                       preempt_enable();
                kfree_skb(skb);
        }
 }