This patch series adds missing annotations to various functions,
that register warnings of context imbalance when built with Sparse tool.
The adds fix the warnings, improve on readability odf the code
and give better insight or directive on what the functions are actually doing.
Jules Irenge (8):
bpf: Add missing annotations for __bpf_prog_enter() and
__bpf_prog_exit()
raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
tcp: Add missing annotation for tcp_child_process()
netfilter: Add missing annotation for ctnetlink_parse_nat_setup()
netfilter: conntrack: Add missing annotations for
nf_conntrack_all_lock() and nf_conntrack_all_unlock()
net: Add missing annotation for *netlink_seq_start()
ALSA: firewire-tascam: Add missing annotation for
tscm_hwdep_read_queue()
ALSA: firewire-tascam: Add missing annotation for
tscm_hwdep_read_locked()
kernel/bpf/trampoline.c | 2 ++
net/ipv4/raw.c | 2 ++
net/ipv4/tcp_minisocks.c | 1 +
net/netfilter/nf_conntrack_core.c | 2 ++
net/netfilter/nf_conntrack_netlink.c | 1 +
net/netlink/af_netlink.c | 1 +
sound/firewire/tascam/tascam-hwdep.c | 2 ++
7 files changed, 11 insertions(+)
--
2.24.1
Sparse reports a warning at ctnetlink_parse_nat_setup()
warning: context imbalance in ctnetlink_parse_nat_setup()
- unexpected unlock
The root cause is the missing annotation at ctnetlink_parse_nat_setup()
Add the missing __must_hold(RCU) annotation
Signed-off-by: Jules Irenge <[email protected]>
---
net/netfilter/nf_conntrack_netlink.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 6a1c8f1f6171..eb190206cd12 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1533,6 +1533,7 @@ static int
ctnetlink_parse_nat_setup(struct nf_conn *ct,
enum nf_nat_manip_type manip,
const struct nlattr *attr)
+ __must_hold(RCU)
{
struct nf_nat_hook *nat_hook;
int err;
--
2.24.1
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 <[email protected]>
---
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
On 3/11/20 2:09 AM, Jules Irenge wrote:
> 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 <[email protected]>
Applied this one to bpf-next, thanks!
On Wed, Mar 11, 2020 at 01:09:04AM +0000, Jules Irenge wrote:
> Sparse reports a warning at ctnetlink_parse_nat_setup()
>
> warning: context imbalance in ctnetlink_parse_nat_setup()
> - unexpected unlock
>
> The root cause is the missing annotation at ctnetlink_parse_nat_setup()
> Add the missing __must_hold(RCU) annotation
Applied, thanks.