[PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit()

From: Jules Irenge
Date: Tue Mar 10 2020 - 21:09:37 EST


Sparse reports a warning at __bpf_prog_enter() and __bpf_prog_exit()

warning: context imbalance in __bpf_prog_enter() - wrong count at exit
warning: context imbalance in __bpf_prog_exit() - unexpected unlock

The root cause is the missing annotation at __bpf_prog_enter()
and __bpf_prog_exit()

Add the missing __acquires(RCU) annotation
Add the missing __releases(RCU) annotation

Signed-off-by: Jules Irenge <jbi.octave@xxxxxxxxx>
---
kernel/bpf/trampoline.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
index 6b264a92064b..09bce10ad1cc 100644
--- a/kernel/bpf/trampoline.c
+++ b/kernel/bpf/trampoline.c
@@ -374,6 +374,7 @@ void bpf_trampoline_put(struct bpf_trampoline *tr)
* call __bpf_prog_exit
*/
u64 notrace __bpf_prog_enter(void)
+ __acquires(RCU)
{
u64 start = 0;

@@ -385,6 +386,7 @@ u64 notrace __bpf_prog_enter(void)
}

void notrace __bpf_prog_exit(struct bpf_prog *prog, u64 start)
+ __releases(RCU)
{
struct bpf_prog_stats *stats;

--
2.24.1