Lock warning cleanups
Subsystems (8)
PATCH 1/8 bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit()
In reply to Jules IrengeSparse 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
--- kernel/bpf/trampoline.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/bpf/trampoline.c +2 -0
@@ -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;
Signature · 1 line
2.24.1
cover Lock warning cleanups
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(+)
Signature · 1 line
2.24.1
PATCH 2/8 raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
Sparse reports warnings at raw_seq_start() and raw_seq_stop()
warning: context imbalance in raw_seq_start() - wrong count at exit
warning: context imbalance in raw_seq_stop() - unexpected unlock
The root cause is the missing annotations at raw_seq_start()
and raw_seq_stop()
Add the missing __acquires(&h->lock) annotation Add the missing __releases(&h->lock) annotation
--- net/ipv4/raw.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/raw.c +2 -0
@@ -1034,6 +1034,7 @@ static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos) }void *raw_seq_start (struct seq_file *seq,loff_t *pos) + __acquires(&h->lock) {struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file));
@@ -1056,6 +1057,7 @@ void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos)EXPORT_SYMBOL_GPL (raw_seq_next);void raw_seq_stop (struct seq_file *seq,void *v) + __releases(&h->lock) {struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file));
Signature · 1 line
2.24.1
PATCH 5/8 netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock()
In reply to Jules IrengeSparse reports warnings at nf_conntrack_all_lock()
and nf_conntrack_all_unlock()
warning: context imbalance in nf_conntrack_all_lock()
- wrong count at exit
warning: context imbalance in nf_conntrack_all_unlock()
- unexpected unlock
Add the missing __acquires(&nf_conntrack_locks_all_lock) Add missing __releases(&nf_conntrack_locks_all_lock)
--- net/netfilter/nf_conntrack_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_conntrack_core.c +2 -0
@@ -143,6 +143,7 @@ static bool nf_conntrack_double_lock(struct net *net, unsigned int h1, }static void nf_conntrack_all_lock (void ) + __acquires(&nf_conntrack_locks_all_lock) {int i;
@@ -162,6 +163,7 @@ static void nf_conntrack_all_lock(void) }static void nf_conntrack_all_unlock (void ) + __releases(&nf_conntrack_locks_all_lock) {/* All prior stores must be complete before we clear * 'nf_conntrack_locks_all'. Otherwise nf_conntrack_lock()
Signature · 1 line
2.24.1
PATCH 6/8 net: Add missing annotation for *netlink_seq_start()
In reply to Jules IrengeSparse reports a warning at netlink_seq_start()
warning: context imbalance in netlink_seq_start() - wrong count at exit The root cause is the missing annotation at netlink_seq_start() Add the missing __acquires(RCU) annotation
--- net/netlink/af_netlink.c | 1 + 1 file changed, 1 insertion(+)
net/netlink/af_netlink.c +1 -0
@@ -2582,6 +2582,7 @@ static void *__netlink_seq_next(struct seq_file *seq) }static void *netlink_seq_start (struct seq_file *seq,loff_t *posp) +__acquires (RCU ) {struct nl_seq_iter *iter = seq->private;void *obj =SEQ_START_TOKEN ;
Signature · 1 line
2.24.1
PATCH 7/8 ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue()
In reply to Jules IrengeSparse reports a warning at tscm_hwdep_read_queue()
warning: context imbalance in tscm_hwdep_read_queue() - unexpected unlock
The root cause is the missing annotation at tscm_hwdep_read_queue() Add the missing __releases(&tscm->lock) annotation
--- sound/firewire/tascam/tascam-hwdep.c | 1 + 1 file changed, 1 insertion(+)
sound/firewire/tascam/tascam-hwdep.c +1 -0
@@ -36,6 +36,7 @@ static long tscm_hwdep_read_locked(struct snd_tscm *tscm, char __user *buf,static long tscm_hwdep_read_queue (struct snd_tscm *tscm,char __user *buf,long remained,loff_t *offset) + __releases(&tscm->lock) {char __user *pos = buf;unsigned int type =SNDRV_FIREWIRE_EVENT_TASCAM_CONTROL ;
Signature · 1 line
2.24.1
PATCH 8/8 ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked()
In reply to Jules IrengeSparse reports a warning at tscm_hwdep_read_locked()
warning: context imbalance in tscm_hwdep_read_locked() - unexpected unlock
The root cause is the missing annotation at tscm_hwdep_read_locked() Add the missing __releases(&tscm->lock) annotation
--- sound/firewire/tascam/tascam-hwdep.c | 1 + 1 file changed, 1 insertion(+)
sound/firewire/tascam/tascam-hwdep.c +1 -0
@@ -17,6 +17,7 @@static long tscm_hwdep_read_locked (struct snd_tscm *tscm,char __user *buf,long count,loff_t *offset) + __releases(&tscm->lock) {struct snd_firewire_event_lock_status event = { .type =SNDRV_FIREWIRE_EVENT_LOCK_STATUS ,
Signature · 1 line
2.24.1
PATCH 4/8 netfilter: Add missing annotation for ctnetlink_parse_nat_setup()
In reply to Jules IrengeSparse 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
--- net/netfilter/nf_conntrack_netlink.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_conntrack_netlink.c +1 -0
@@ -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;
Signature · 1 line
2.24.1
PATCH 3/8 tcp: Add missing annotation for tcp_child_process()
In reply to Jules IrengeSparse reports warning at tcp_child_process()
warning: context imbalance in tcp_child_process() - unexpected unlock The root cause is the missing annotation at tcp_child_process()
Add the missing __releases(&((child)->sk_lock.slock)) annotation
--- net/ipv4/tcp_minisocks.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/tcp_minisocks.c +1 -0
@@ -817,6 +817,7 @@ EXPORT_SYMBOL(tcp_check_req);int tcp_child_process (struct sock *parent,struct sock *child,struct sk_buff *skb) + __releases(&((child)->sk_lock.slock)) {int ret =0 ;int state = child->sk_state;
Signature · 1 line
2.24.1
Re: [PATCH 3/8] tcp: Add missing annotation for tcp_child_process()
Quoted 17 lines · Jules Irenge
Sparse reports warning at
tcp_child_process()
warning: context imbalance intcp_child_process()- unexpected unlock The root cause is the missing annotation attcp_child_process()Add the missing __releases(&((child)->sk_lock.slock)) annotation
Signed-off-by Jules Irenge <[email protected]>--- net/ipv4/tcp_minisocks.c | 1 + 1 file changed, 1 insertion(+)net/ipv4/tcp_minisocks.c +0
-0
net/ipv4/tcp_minisocks.c EXPORT_SYMBOL(tcp_check_req); · line 823
Quoted 7 lines
net/ipv4/tcp_minisocks.c +1
-0@@ -817,6 +817,7 @@ EXPORT_SYMBOL(tcp_check_req);int tcp_child_process (struct sock *parent,struct sock *child,struct sk_buff *skb) + __releases(&((child)->sk_lock.slock)) {int ret =0 ;int state = child->sk_state;
Yeah, although we prefer to use lockdep these days ;)
Re: [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
In reply to Jules IrengeQuoted 20 lines · Jules Irenge
Sparse reports warnings at
raw_seq_start()andraw_seq_stop()warning: context imbalance in
raw_seq_start()- wrong count at exit
warning: context imbalance inraw_seq_stop()- unexpected unlockThe root cause is the missing annotations at
raw_seq_start()
andraw_seq_stop()
Add the missing__acquires(&h->lock)annotation Add the missing__releases(&h->lock)annotationSigned-off-by Jules Irenge <[email protected]>--- net/ipv4/raw.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv4/raw.c +0
-0
net/ipv4/raw.c static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos) · line 1037
Quoted 4 lines
net/ipv4/raw.c +1
-0@@ -1034,6 +1034,7 @@ static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos) }void *raw_seq_start (struct seq_file *seq,loff_t *pos) + __acquires(&h->lock)
I dunno, h variable is not yet defined/declared at this point, this looks weird.
Quoted 12 lines
net/ipv4/raw.c +1
-0{struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file));@@ -1056,6 +1057,7 @@ void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos)EXPORT_SYMBOL_GPL (raw_seq_next);void raw_seq_stop (struct seq_file *seq,void *v) + __releases(&h->lock) {struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file));
Re: [PATCH 3/8] tcp: Add missing annotation for tcp_child_process()
In reply to Eric DumazetThanks for the feedbacks. Good to know I have not used lockdep but I will try it.
Quoted 31 lines · Eric Dumazet
Quoted 17 lines · Jules Irenge
Sparse reports warning at
tcp_child_process()
warning: context imbalance intcp_child_process()- unexpected unlock The root cause is the missing annotation attcp_child_process()Add the missing __releases(&((child)->sk_lock.slock)) annotation
Signed-off-by Jules Irenge <[email protected]>--- net/ipv4/tcp_minisocks.c | 1 + 1 file changed, 1 insertion(+)net/ipv4/tcp_minisocks.c +0
-0net/ipv4/tcp_minisocks.c EXPORT_SYMBOL(tcp_check_req); · line 823
Quoted 7 lines
net/ipv4/tcp_minisocks.c +1
-0@@ -817,6 +817,7 @@ EXPORT_SYMBOL(tcp_check_req);int tcp_child_process (struct sock *parent,struct sock *child,struct sk_buff *skb) + __releases(&((child)->sk_lock.slock)) {int ret =0 ;int state = child->sk_state;Yeah, although we prefer to use lockdep these days ;)
Reviewed-by Eric Dumazet <[email protected]>
Re: [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
In reply to Eric DumazetQuoted 37 lines · Eric Dumazet
Quoted 20 lines · Jules Irenge
Sparse reports warnings at
raw_seq_start()andraw_seq_stop()warning: context imbalance in
raw_seq_start()- wrong count at exit
warning: context imbalance inraw_seq_stop()- unexpected unlockThe root cause is the missing annotations at
raw_seq_start()
andraw_seq_stop()
Add the missing__acquires(&h->lock)annotation Add the missing__releases(&h->lock)annotationSigned-off-by Jules Irenge <[email protected]>--- net/ipv4/raw.c | 2 ++ 1 file changed, 2 insertions(+)net/ipv4/raw.c +0
-0net/ipv4/raw.c static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos) · line 1037
Quoted 4 lines
net/ipv4/raw.c +1
-0@@ -1034,6 +1034,7 @@ static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos) }void *raw_seq_start (struct seq_file *seq,loff_t *pos) + __acquires(&h->lock)I dunno, h variable is not yet defined/declared at this point, this looks weird.
Quoted 6 lines
net/ipv4/raw.c +0
-0{struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file));@@ -1056,6 +1057,7 @@ void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos)EXPORT_SYMBOL_GPL (raw_seq_next);
Quoted 7 lines
net/ipv4/raw.c void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos) · line 1063
Quoted 6 lines
net/ipv4/raw.c +1
-0void raw_seq_stop (struct seq_file *seq,void *v) + __releases(&h->lock) {struct raw_hashinfo *h =PDE_DATA (file_inode (seq->file));
Thanks for the feedback,
I think h is a pointer of type struct raw_hashinfo, in which member lock is initialized on line number 89.
Kind regards
Re: [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked()
In reply to Jules IrengeHi,
Quoted 11 lines · Jules Irenge
Sparse reports a warning at
tscm_hwdep_read_locked()warning: context imbalance in
tscm_hwdep_read_locked()- unexpected unlockThe root cause is the missing annotation at
tscm_hwdep_read_locked()Add the missing__releases(&tscm->lock)annotationSigned-off-by Jules Irenge <[email protected]>--- sound/firewire/tascam/tascam-hwdep.c | 1 + 1 file changed, 1 insertion(+)
Thanks for your care of the warning. Although I have found it, I had no idea to suppress it.
Quoted 15 lines
sound/firewire/tascam/tascam-hwdep.c +1
-0@@ -17,6 +17,7 @@static long tscm_hwdep_read_locked (struct snd_tscm *tscm,char __user *buf,long count,loff_t *offset) + __releases(&tscm->lock) {struct snd_firewire_event_lock_status event = { .type =SNDRV_FIREWIRE_EVENT_LOCK_STATUS ,Signature · 1 line
2.24.1
Re: [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue()
In reply to Jules IrengeQuoted 11 lines · Jules Irenge
Sparse reports a warning at
tscm_hwdep_read_queue()warning: context imbalance in
tscm_hwdep_read_queue()- unexpected unlockThe root cause is the missing annotation at
tscm_hwdep_read_queue()Add the missing__releases(&tscm->lock)annotationSigned-off-by Jules Irenge <[email protected]>--- sound/firewire/tascam/tascam-hwdep.c | 1 + 1 file changed, 1 insertion(+)
This looks good.
Quoted 14 lines
sound/firewire/tascam/tascam-hwdep.c +1
-0@@ -36,6 +36,7 @@ static long tscm_hwdep_read_locked(struct snd_tscm *tscm, char __user *buf,static long tscm_hwdep_read_queue (struct snd_tscm *tscm,char __user *buf,long remained,loff_t *offset) + __releases(&tscm->lock) {char __user *pos = buf;unsigned int type =SNDRV_FIREWIRE_EVENT_TASCAM_CONTROL ;Signature · 1 line
2.24.1
Regards
Takashi Sakamoto
Takashi Iwai
AppliedRe: [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked()
In reply to Jules IrengeQuoted 9 lines · Jules Irenge
Sparse reports a warning at
tscm_hwdep_read_locked()warning: context imbalance in
tscm_hwdep_read_locked()- unexpected unlockThe root cause is the missing annotation at
tscm_hwdep_read_locked()Add the missing__releases(&tscm->lock)annotationSigned-off-by Jules Irenge <[email protected]>
Applied, thanks.
Takashi
Takashi Iwai
AppliedRe: [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue()
In reply to Jules IrengeQuoted 9 lines · Jules Irenge
Sparse reports a warning at
tscm_hwdep_read_queue()warning: context imbalance in
tscm_hwdep_read_queue()- unexpected unlockThe root cause is the missing annotation at
tscm_hwdep_read_queue()Add the missing__releases(&tscm->lock)annotationSigned-off-by Jules Irenge <[email protected]>
Applied, thanks.
Takashi
Re: [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
In reply to Jules IrengeFrom: Jules Irenge <[email protected]>
Date: Wed, 11 Mar 2020 01:09:02 +0000
Quoted 11 lines
Sparse reports warnings at
raw_seq_start()andraw_seq_stop()warning: context imbalance in
raw_seq_start()- wrong count at exit
warning: context imbalance inraw_seq_stop()- unexpected unlockThe root cause is the missing annotations at
raw_seq_start()
andraw_seq_stop()
Add the missing__acquires(&h->lock)annotation Add the missing__releases(&h->lock)annotationSigned-off-by Jules Irenge <[email protected]>
Applied.
Re: [PATCH 3/8] tcp: Add missing annotation for tcp_child_process()
In reply to Jules IrengeFrom: Jules Irenge <[email protected]>
Date: Wed, 11 Mar 2020 01:09:03 +0000
Quoted 7 lines
Sparse reports warning at
tcp_child_process()
warning: context imbalance intcp_child_process()- unexpected unlock The root cause is the missing annotation attcp_child_process()Add the missing __releases(&((child)->sk_lock.slock)) annotation
Signed-off-by Jules Irenge <[email protected]>
Applied.
Re: [PATCH 6/8] net: Add missing annotation for *netlink_seq_start()
In reply to Jules IrengeFrom: Jules Irenge <[email protected]>
Date: Wed, 11 Mar 2020 01:09:06 +0000
Quoted 7 lines
Sparse reports a warning at
netlink_seq_start()warning: context imbalance in
netlink_seq_start()- wrong count at exit The root cause is the missing annotation atnetlink_seq_start()Add the missing__acquires(RCU)annotationSigned-off-by Jules Irenge <[email protected]>
Applied.
Re: [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit()
In reply to Jules IrengeQuoted 5 lines · Jules Irenge
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
Quoted 7 lines
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)annotationSigned-off-by Jules Irenge <[email protected]>
Applied this one to bpf-next, thanks!
Re: [PATCH 4/8] netfilter: Add missing annotation for ctnetlink_parse_nat_setup()
In reply to Jules IrengeQuoted 7 lines · Jules Irenge
Sparse reports a warning at
ctnetlink_parse_nat_setup()warning: context imbalance in
ctnetlink_parse_nat_setup()
- unexpected unlockThe root cause is the missing annotation at
ctnetlink_parse_nat_setup()Add the missing__must_hold(RCU)annotation
Applied, thanks.
Pablo Neira Ayuso
maintainerRe: [PATCH 5/8] netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock()
In reply to Jules IrengeQuoted 10 lines · Jules Irenge
Sparse reports warnings at
nf_conntrack_all_lock()
andnf_conntrack_all_unlock()warning: context imbalance in
nf_conntrack_all_lock()
- wrong count at exit
warning: context imbalance innf_conntrack_all_unlock()
- unexpected unlockAdd the missing
__acquires(&nf_conntrack_locks_all_lock)Add missing__releases(&nf_conntrack_locks_all_lock)
Also applied, thanks.