netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: af_unix should disable preempt around sock_prot_inuse_add()
@ 2008-11-24 12:54 Alexander Beregalov
  2008-11-24 13:06 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Beregalov @ 2008-11-24 12:54 UTC (permalink / raw)
  To: netdev, dada1, davem



BUG: using smp_processor_id() in preemptible [00000000] code: ini

caller is sock_prot_inuse_add+0x24/0x42
Pid: 738, comm: init-early.sh Tainted: G        W  2.6.28-rc6-nex

Call Trace:
 [<ffffffff8037fb72>] debug_smp_processor_id+0xca/0xe0
 [<ffffffff8046afc9>] sock_prot_inuse_add+0x24/0x42
 [<ffffffff804baf2c>] unix_create1+0x161/0x176
 [<ffffffff804bb03d>] unix_stream_connect+0x94/0x3b0
 [<ffffffff80468a84>] sys_connect+0x68/0x8e
 [<ffffffff8020b75b>] system_call_fastpath+0x16/0x1b

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
---

 net/unix/af_unix.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index a9b3c90..f7a1d46 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -361,7 +361,9 @@ static void unix_sock_destructor(struct sock *sk)
 		unix_release_addr(u->addr);
 
 	atomic_dec(&unix_nr_socks);
+	preempt_disable();
 	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
+	preempt_enable();
 #ifdef UNIX_REFCNT_DEBUG
 	printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk,
 		atomic_read(&unix_nr_socks));
@@ -612,9 +614,11 @@ static struct sock *unix_create1(struct net *net, struct socket *sock)
 out:
 	if (sk == NULL)
 		atomic_dec(&unix_nr_socks);
-	else
+	else {
+		preempt_disable();
 		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
-
+		preempt_enable();
+	}
 	return sk;
 }
 

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

* Re: [PATCH] net: af_unix should disable preempt around sock_prot_inuse_add()
  2008-11-24 12:54 [PATCH] net: af_unix should disable preempt around sock_prot_inuse_add() Alexander Beregalov
@ 2008-11-24 13:06 ` Eric Dumazet
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2008-11-24 13:06 UTC (permalink / raw)
  To: Alexander Beregalov; +Cc: netdev, davem

Alexander Beregalov a écrit :
> 
> BUG: using smp_processor_id() in preemptible [00000000] code: ini
> 
> caller is sock_prot_inuse_add+0x24/0x42
> Pid: 738, comm: init-early.sh Tainted: G        W  2.6.28-rc6-nex
> 
> Call Trace:
>  [<ffffffff8037fb72>] debug_smp_processor_id+0xca/0xe0
>  [<ffffffff8046afc9>] sock_prot_inuse_add+0x24/0x42
>  [<ffffffff804baf2c>] unix_create1+0x161/0x176
>  [<ffffffff804bb03d>] unix_stream_connect+0x94/0x3b0
>  [<ffffffff80468a84>] sys_connect+0x68/0x8e
>  [<ffffffff8020b75b>] system_call_fastpath+0x16/0x1b
> 
> Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
> ---
> 
>  net/unix/af_unix.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index a9b3c90..f7a1d46 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -361,7 +361,9 @@ static void unix_sock_destructor(struct sock *sk)
>  		unix_release_addr(u->addr);
>  
>  	atomic_dec(&unix_nr_socks);
> +	preempt_disable();
>  	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
> +	preempt_enable();
>  #ifdef UNIX_REFCNT_DEBUG
>  	printk(KERN_DEBUG "UNIX %p is destroyed, %d are still alive.\n", sk,
>  		atomic_read(&unix_nr_socks));
> @@ -612,9 +614,11 @@ static struct sock *unix_create1(struct net *net, struct socket *sock)
>  out:
>  	if (sk == NULL)
>  		atomic_dec(&unix_nr_socks);
> -	else
> +	else {
> +		preempt_disable();
>  		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
> -
> +		preempt_enable();
> +	}
>  	return sk;
>  }
>  
> 
> 

Thanks Alexander, but this problem (and others) was fixed few
hours ago by two commits on net-next-2.6

commit 6f756a8c36bf54d0afb1d457082b3e3033d951a7

net: Make sure BHs are disabled in sock_prot_inuse_add()

The rule of calling sock_prot_inuse_add() is that BHs must
be disabled.  Some new calls were added where this was not
true and this tiggers warnings as reported by Ilpo.

Fix this by adding explicit BH disabling around those call sites.

Signed-off-by: David S. Miller <davem@davemloft.net>

commit 920de804bca61f88643bc9171bcd06f1a56c6258

net: Make sure BHs are disabled in sock_prot_inuse_add()

The rule of calling sock_prot_inuse_add() is that BHs must
be disabled.  Some new calls were added where this was not
true and this tiggers warnings as reported by Ilpo.

Fix this by adding explicit BH disabling around those call sites,
or moving sock_prot_inuse_add() call inside an existing BH disabled
section.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: David S. Miller <davem@davemloft.net>


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

end of thread, other threads:[~2008-11-24 13:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-24 12:54 [PATCH] net: af_unix should disable preempt around sock_prot_inuse_add() Alexander Beregalov
2008-11-24 13:06 ` Eric Dumazet

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