bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] Lock warning cleanups
       [not found] <0/8>
@ 2020-03-11  1:09 ` Jules Irenge
  2020-03-11  1:09   ` [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit() Jules Irenge
                     ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, Alexei Starovoitov, Daniel Borkmann,
	Martin KaFai Lau, Song Liu, Yonghong Song, Andrii Nakryiko

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and  __bpf_prog_exit()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-13 19:49     ` Daniel Borkmann
  2020-03-11  1:09   ` [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop() Jules Irenge
                     ` (6 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, Alexei Starovoitov, Daniel Borkmann,
	Martin KaFai Lau, Song Liu, Yonghong Song, Andrii Nakryiko

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
  2020-03-11  1:09   ` [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit() Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-11  1:15     ` Eric Dumazet
  2020-03-12  6:20     ` David Miller
  2020-03-11  1:09   ` [PATCH 3/8] tcp: Add missing annotation for tcp_child_process() Jules Irenge
                     ` (5 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski

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

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 net/ipv4/raw.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 3183413ebc6c..47665919048f 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -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));
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/8] tcp: Add missing annotation for tcp_child_process()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
  2020-03-11  1:09   ` [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit() Jules Irenge
  2020-03-11  1:09   ` [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop() Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-11  1:14     ` Eric Dumazet
  2020-03-12  6:20     ` David Miller
  2020-03-11  1:09   ` [PATCH 4/8] netfilter: Add missing annotation for ctnetlink_parse_nat_setup() Jules Irenge
                     ` (4 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, Eric Dumazet, David S. Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI, Jakub Kicinski

Sparse 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

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 net/ipv4/tcp_minisocks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index ad3b56d9fa71..0e8a5b6e477c 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/8] netfilter: Add missing annotation for ctnetlink_parse_nat_setup()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
                     ` (2 preceding siblings ...)
  2020-03-11  1:09   ` [PATCH 3/8] tcp: Add missing annotation for tcp_child_process() Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-27 17:22     ` Pablo Neira Ayuso
  2020-03-11  1:09   ` [PATCH 5/8] netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock() Jules Irenge
                     ` (3 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, Jakub Kicinski,
	open list:NETFILTER, open list:NETFILTER

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 <jbi.octave@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/8] netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
                     ` (3 preceding siblings ...)
  2020-03-11  1:09   ` [PATCH 4/8] netfilter: Add missing annotation for ctnetlink_parse_nat_setup() Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-27 17:22     ` Pablo Neira Ayuso
  2020-03-11  1:09   ` [PATCH 6/8] net: Add missing annotation for *netlink_seq_start() Jules Irenge
                     ` (2 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, Jakub Kicinski,
	open list:NETFILTER, open list:NETFILTER

Sparse 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)

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 net/netfilter/nf_conntrack_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index d1305423640f..a0bc122d5df1 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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()
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 6/8] net: Add missing annotation for *netlink_seq_start()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
                     ` (4 preceding siblings ...)
  2020-03-11  1:09   ` [PATCH 5/8] netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock() Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-12  6:20     ` David Miller
  2020-03-11  1:09   ` [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue() Jules Irenge
  2020-03-11  1:09   ` [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked() Jules Irenge
  7 siblings, 1 reply; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, David S. Miller, Jakub Kicinski,
	Allison Randal, Pankaj Bharadiya, Patrick Talbert, Taehee Yoo,
	Li RongQing, Thomas Gleixner, Tetsuo Handa

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 at netlink_seq_start()
Add the missing  __acquires(RCU) annotation

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 net/netlink/af_netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 7a287dc73f63..99eef04a51ec 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
                     ` (5 preceding siblings ...)
  2020-03-11  1:09   ` [PATCH 6/8] net: Add missing annotation for *netlink_seq_start() Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-11  3:19     ` Takashi Sakamoto
  2020-03-11  6:56     ` Takashi Iwai
  2020-03-11  1:09   ` [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked() Jules Irenge
  7 siblings, 2 replies; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, Clemens Ladisch, Takashi Sakamoto,
	Jaroslav Kysela, Takashi Iwai, Alexios Zavras,
	Greg Kroah-Hartman, Allison Randal, Thomas Gleixner,
	moderated list:FIREWIRE AUDIO DRIVERS and IEC 61883-1/6 PACKET...

Sparse 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

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 sound/firewire/tascam/tascam-hwdep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c
index c29a97f6f638..9801e33e7f2a 100644
--- a/sound/firewire/tascam/tascam-hwdep.c
+++ b/sound/firewire/tascam/tascam-hwdep.c
@@ -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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked()
  2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
                     ` (6 preceding siblings ...)
  2020-03-11  1:09   ` [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue() Jules Irenge
@ 2020-03-11  1:09   ` Jules Irenge
  2020-03-11  3:18     ` Takashi Sakamoto
  2020-03-11  6:56     ` Takashi Iwai
  7 siblings, 2 replies; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:09 UTC (permalink / raw)
  To: boqun.feng
  Cc: linux-kernel, bpf, netdev, Clemens Ladisch, Takashi Sakamoto,
	Jaroslav Kysela, Takashi Iwai, Alexios Zavras,
	Greg Kroah-Hartman, Thomas Gleixner, Allison Randal,
	moderated list:FIREWIRE AUDIO DRIVERS and IEC 61883-1/6 PACKET...

Sparse 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

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 sound/firewire/tascam/tascam-hwdep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c
index 9801e33e7f2a..6f38335fe10b 100644
--- a/sound/firewire/tascam/tascam-hwdep.c
+++ b/sound/firewire/tascam/tascam-hwdep.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 3/8] tcp: Add missing annotation for tcp_child_process()
  2020-03-11  1:09   ` [PATCH 3/8] tcp: Add missing annotation for tcp_child_process() Jules Irenge
@ 2020-03-11  1:14     ` Eric Dumazet
  2020-03-11  1:28       ` Jules Irenge
  2020-03-12  6:20     ` David Miller
  1 sibling, 1 reply; 23+ messages in thread
From: Eric Dumazet @ 2020-03-11  1:14 UTC (permalink / raw)
  To: Jules Irenge
  Cc: boqun.feng, LKML, bpf, netdev, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski

On Tue, Mar 10, 2020 at 6:09 PM Jules Irenge <jbi.octave@gmail.com> wrote:
>
> Sparse 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
>
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> ---
>  net/ipv4/tcp_minisocks.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
> index ad3b56d9fa71..0e8a5b6e477c 100644
> --- a/net/ipv4/tcp_minisocks.c
> +++ b/net/ipv4/tcp_minisocks.c
> @@ -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 <edumazet@google.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
  2020-03-11  1:09   ` [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop() Jules Irenge
@ 2020-03-11  1:15     ` Eric Dumazet
  2020-03-11  1:40       ` Jules Irenge
  2020-03-12  6:20     ` David Miller
  1 sibling, 1 reply; 23+ messages in thread
From: Eric Dumazet @ 2020-03-11  1:15 UTC (permalink / raw)
  To: Jules Irenge, boqun.feng
  Cc: linux-kernel, bpf, netdev, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski



On 3/10/20 6:09 PM, Jules Irenge wrote:
> 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
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> ---
>  net/ipv4/raw.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> index 3183413ebc6c..47665919048f 100644
> --- a/net/ipv4/raw.c
> +++ b/net/ipv4/raw.c
> @@ -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.

>  {
>  	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));
>  
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 3/8] tcp: Add missing annotation for tcp_child_process()
  2020-03-11  1:14     ` Eric Dumazet
@ 2020-03-11  1:28       ` Jules Irenge
  0 siblings, 0 replies; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:28 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Jules Irenge, boqun.feng, LKML, bpf, netdev, David S. Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI, Jakub Kicinski

Thanks for the feedbacks. Good to know I have not used lockdep but I will 
try it.

On Tue, 10 Mar 2020, Eric Dumazet wrote:

> On Tue, Mar 10, 2020 at 6:09 PM Jules Irenge <jbi.octave@gmail.com> wrote:
> >
> > Sparse 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
> >
> > Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> > ---
> >  net/ipv4/tcp_minisocks.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
> > index ad3b56d9fa71..0e8a5b6e477c 100644
> > --- a/net/ipv4/tcp_minisocks.c
> > +++ b/net/ipv4/tcp_minisocks.c
> > @@ -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 <edumazet@google.com>
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
  2020-03-11  1:15     ` Eric Dumazet
@ 2020-03-11  1:40       ` Jules Irenge
  0 siblings, 0 replies; 23+ messages in thread
From: Jules Irenge @ 2020-03-11  1:40 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Jules Irenge, boqun.feng, linux-kernel, bpf, netdev,
	David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	Jakub Kicinski



On Tue, 10 Mar 2020, Eric Dumazet wrote:

> 
> 
> On 3/10/20 6:09 PM, Jules Irenge wrote:
> > 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
> > 
> > Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> > ---
> >  net/ipv4/raw.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> > index 3183413ebc6c..47665919048f 100644
> > --- a/net/ipv4/raw.c
> > +++ b/net/ipv4/raw.c
> > @@ -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.
> 
> >  {
> >  	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));
> >  
> > 
> 
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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked()
  2020-03-11  1:09   ` [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked() Jules Irenge
@ 2020-03-11  3:18     ` Takashi Sakamoto
  2020-03-11  6:56     ` Takashi Iwai
  1 sibling, 0 replies; 23+ messages in thread
From: Takashi Sakamoto @ 2020-03-11  3:18 UTC (permalink / raw)
  To: Jules Irenge
  Cc: boqun.feng, linux-kernel, bpf, netdev, Clemens Ladisch,
	Jaroslav Kysela, Takashi Iwai, Alexios Zavras,
	Greg Kroah-Hartman, Thomas Gleixner, Allison Randal,
	moderated list:FIREWIRE AUDIO DRIVERS and IEC 61883-1/6 PACKET...

Hi,

On Wed, Mar 11, 2020 at 01:09:08AM +0000, Jules Irenge wrote:
> Sparse 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
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> ---
>  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.

Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

> diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c
> index 9801e33e7f2a..6f38335fe10b 100644
> --- a/sound/firewire/tascam/tascam-hwdep.c
> +++ b/sound/firewire/tascam/tascam-hwdep.c
> @@ -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,
> -- 
> 2.24.1
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue()
  2020-03-11  1:09   ` [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue() Jules Irenge
@ 2020-03-11  3:19     ` Takashi Sakamoto
  2020-03-11  6:56     ` Takashi Iwai
  1 sibling, 0 replies; 23+ messages in thread
From: Takashi Sakamoto @ 2020-03-11  3:19 UTC (permalink / raw)
  To: Jules Irenge
  Cc: boqun.feng, linux-kernel, bpf, netdev, Clemens Ladisch,
	Jaroslav Kysela, Takashi Iwai, Alexios Zavras,
	Greg Kroah-Hartman, Allison Randal, Thomas Gleixner,
	moderated list:FIREWIRE AUDIO DRIVERS and IEC 61883-1/6 PACKET...

On Wed, Mar 11, 2020 at 01:09:07AM +0000, Jules Irenge wrote:
> Sparse 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
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> ---
>  sound/firewire/tascam/tascam-hwdep.c | 1 +
>  1 file changed, 1 insertion(+)
 
This looks good.

Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

> diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c
> index c29a97f6f638..9801e33e7f2a 100644
> --- a/sound/firewire/tascam/tascam-hwdep.c
> +++ b/sound/firewire/tascam/tascam-hwdep.c
> @@ -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;
> -- 
> 2.24.1


Regards

Takashi Sakamoto

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked()
  2020-03-11  1:09   ` [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked() Jules Irenge
  2020-03-11  3:18     ` Takashi Sakamoto
@ 2020-03-11  6:56     ` Takashi Iwai
  1 sibling, 0 replies; 23+ messages in thread
From: Takashi Iwai @ 2020-03-11  6:56 UTC (permalink / raw)
  To: Jules Irenge
  Cc: boqun.feng, linux-kernel, bpf, netdev, Clemens Ladisch,
	Takashi Sakamoto, Jaroslav Kysela, Takashi Iwai, Alexios Zavras,
	Greg Kroah-Hartman, Thomas Gleixner, Allison Randal,
	moderated list:FIREWIRE AUDIO DRIVERS and IEC 61883-1/6 PACKET...

On Wed, 11 Mar 2020 02:09:08 +0100,
Jules Irenge wrote:
> 
> Sparse 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
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue()
  2020-03-11  1:09   ` [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue() Jules Irenge
  2020-03-11  3:19     ` Takashi Sakamoto
@ 2020-03-11  6:56     ` Takashi Iwai
  1 sibling, 0 replies; 23+ messages in thread
From: Takashi Iwai @ 2020-03-11  6:56 UTC (permalink / raw)
  To: Jules Irenge
  Cc: boqun.feng, linux-kernel, bpf, netdev, Clemens Ladisch,
	Takashi Sakamoto, Jaroslav Kysela, Takashi Iwai, Alexios Zavras,
	Greg Kroah-Hartman, Allison Randal, Thomas Gleixner,
	moderated list:FIREWIRE AUDIO DRIVERS and IEC 61883-1/6 PACKET...

On Wed, 11 Mar 2020 02:09:07 +0100,
Jules Irenge wrote:
> 
> Sparse 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
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop()
  2020-03-11  1:09   ` [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop() Jules Irenge
  2020-03-11  1:15     ` Eric Dumazet
@ 2020-03-12  6:20     ` David Miller
  1 sibling, 0 replies; 23+ messages in thread
From: David Miller @ 2020-03-12  6:20 UTC (permalink / raw)
  To: jbi.octave; +Cc: boqun.feng, linux-kernel, bpf, netdev, kuznet, yoshfuji, kuba

From: Jules Irenge <jbi.octave@gmail.com>
Date: Wed, 11 Mar 2020 01:09:02 +0000

> 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
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 3/8] tcp: Add missing annotation for tcp_child_process()
  2020-03-11  1:09   ` [PATCH 3/8] tcp: Add missing annotation for tcp_child_process() Jules Irenge
  2020-03-11  1:14     ` Eric Dumazet
@ 2020-03-12  6:20     ` David Miller
  1 sibling, 0 replies; 23+ messages in thread
From: David Miller @ 2020-03-12  6:20 UTC (permalink / raw)
  To: jbi.octave
  Cc: boqun.feng, linux-kernel, bpf, netdev, edumazet, kuznet, yoshfuji, kuba

From: Jules Irenge <jbi.octave@gmail.com>
Date: Wed, 11 Mar 2020 01:09:03 +0000

> Sparse 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
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 6/8] net: Add missing annotation for *netlink_seq_start()
  2020-03-11  1:09   ` [PATCH 6/8] net: Add missing annotation for *netlink_seq_start() Jules Irenge
@ 2020-03-12  6:20     ` David Miller
  0 siblings, 0 replies; 23+ messages in thread
From: David Miller @ 2020-03-12  6:20 UTC (permalink / raw)
  To: jbi.octave
  Cc: boqun.feng, linux-kernel, bpf, netdev, kuba, allison,
	pankaj.laxminarayan.bharadiya, ptalbert, ap420073, lirongqing,
	tglx, penguin-kernel

From: Jules Irenge <jbi.octave@gmail.com>
Date: Wed, 11 Mar 2020 01:09:06 +0000

> 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 at netlink_seq_start()
> Add the missing  __acquires(RCU) annotation
> 
> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit()
  2020-03-11  1:09   ` [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit() Jules Irenge
@ 2020-03-13 19:49     ` Daniel Borkmann
  0 siblings, 0 replies; 23+ messages in thread
From: Daniel Borkmann @ 2020-03-13 19:49 UTC (permalink / raw)
  To: Jules Irenge, boqun.feng
  Cc: linux-kernel, bpf, netdev, Alexei Starovoitov, Martin KaFai Lau,
	Song Liu, Yonghong Song, Andrii Nakryiko

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 <jbi.octave@gmail.com>

Applied this one to bpf-next, thanks!

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/8] netfilter: Add missing annotation for ctnetlink_parse_nat_setup()
  2020-03-11  1:09   ` [PATCH 4/8] netfilter: Add missing annotation for ctnetlink_parse_nat_setup() Jules Irenge
@ 2020-03-27 17:22     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 23+ messages in thread
From: Pablo Neira Ayuso @ 2020-03-27 17:22 UTC (permalink / raw)
  To: Jules Irenge
  Cc: boqun.feng, linux-kernel, bpf, netdev, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, Jakub Kicinski,
	open list:NETFILTER, open list:NETFILTER

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.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/8] netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock()
  2020-03-11  1:09   ` [PATCH 5/8] netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock() Jules Irenge
@ 2020-03-27 17:22     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 23+ messages in thread
From: Pablo Neira Ayuso @ 2020-03-27 17:22 UTC (permalink / raw)
  To: Jules Irenge
  Cc: boqun.feng, linux-kernel, bpf, netdev, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, Jakub Kicinski,
	open list:NETFILTER, open list:NETFILTER

On Wed, Mar 11, 2020 at 01:09:05AM +0000, Jules Irenge wrote:
> Sparse 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)

Also applied, thanks.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2020-03-27 17:22 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <0/8>
2020-03-11  1:09 ` [PATCH 0/8] Lock warning cleanups Jules Irenge
2020-03-11  1:09   ` [PATCH 1/8] bpf: Add missing annotations for __bpf_prog_enter() and __bpf_prog_exit() Jules Irenge
2020-03-13 19:49     ` Daniel Borkmann
2020-03-11  1:09   ` [PATCH 2/8] raw: Add missing annotations to raw_seq_start() and raw_seq_stop() Jules Irenge
2020-03-11  1:15     ` Eric Dumazet
2020-03-11  1:40       ` Jules Irenge
2020-03-12  6:20     ` David Miller
2020-03-11  1:09   ` [PATCH 3/8] tcp: Add missing annotation for tcp_child_process() Jules Irenge
2020-03-11  1:14     ` Eric Dumazet
2020-03-11  1:28       ` Jules Irenge
2020-03-12  6:20     ` David Miller
2020-03-11  1:09   ` [PATCH 4/8] netfilter: Add missing annotation for ctnetlink_parse_nat_setup() Jules Irenge
2020-03-27 17:22     ` Pablo Neira Ayuso
2020-03-11  1:09   ` [PATCH 5/8] netfilter: conntrack: Add missing annotations for nf_conntrack_all_lock() and nf_conntrack_all_unlock() Jules Irenge
2020-03-27 17:22     ` Pablo Neira Ayuso
2020-03-11  1:09   ` [PATCH 6/8] net: Add missing annotation for *netlink_seq_start() Jules Irenge
2020-03-12  6:20     ` David Miller
2020-03-11  1:09   ` [PATCH 7/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_queue() Jules Irenge
2020-03-11  3:19     ` Takashi Sakamoto
2020-03-11  6:56     ` Takashi Iwai
2020-03-11  1:09   ` [PATCH 8/8] ALSA: firewire-tascam: Add missing annotation for tscm_hwdep_read_locked() Jules Irenge
2020-03-11  3:18     ` Takashi Sakamoto
2020-03-11  6:56     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).