bpf: bpf_lock on kallsysms doesn't need to be irqsave
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Wed, 26 Apr 2017 23:39:33 +0000 (01:39 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Apr 2017 19:48:14 +0000 (15:48 -0400)
Hannes rightfully spotted that the bpf_lock doesn't need to be
irqsave variant. We never perform any such updates where this
would be necessary (neither right now nor in future), therefore
relax this further.

Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/core.c

index b4f1cb0c5ac7104c3f12f9ed5c1e3fe159c57824..6f81e0f5a0faa2f7df85ae1771f9dfde48e59651 100644 (file)
@@ -394,27 +394,23 @@ static bool bpf_prog_kallsyms_verify_off(const struct bpf_prog *fp)
 
 void bpf_prog_kallsyms_add(struct bpf_prog *fp)
 {
-       unsigned long flags;
-
        if (!bpf_prog_kallsyms_candidate(fp) ||
            !capable(CAP_SYS_ADMIN))
                return;
 
-       spin_lock_irqsave(&bpf_lock, flags);
+       spin_lock_bh(&bpf_lock);
        bpf_prog_ksym_node_add(fp->aux);
-       spin_unlock_irqrestore(&bpf_lock, flags);
+       spin_unlock_bh(&bpf_lock);
 }
 
 void bpf_prog_kallsyms_del(struct bpf_prog *fp)
 {
-       unsigned long flags;
-
        if (!bpf_prog_kallsyms_candidate(fp))
                return;
 
-       spin_lock_irqsave(&bpf_lock, flags);
+       spin_lock_bh(&bpf_lock);
        bpf_prog_ksym_node_del(fp->aux);
-       spin_unlock_irqrestore(&bpf_lock, flags);
+       spin_unlock_bh(&bpf_lock);
 }
 
 static struct bpf_prog *bpf_prog_kallsyms_find(unsigned long addr)