netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch net-next] audit: remove useless synchronize_net()
@ 2016-11-29 17:14 Cong Wang
  2016-11-30  9:16 ` Richard Guy Briggs
  2016-12-01 16:29 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Cong Wang @ 2016-11-29 17:14 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, Richard Guy Briggs

netlink kernel socket is protected by refcount, not RCU.
Its rcv path is neither protected by RCU. So the synchronize_net()
is just pointless.

Cc: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 kernel/audit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 92c463d..67b9fbd8 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1172,9 +1172,8 @@ static void __net_exit audit_net_exit(struct net *net)
 		audit_sock = NULL;
 	}
 
-	RCU_INIT_POINTER(aunet->nlsk, NULL);
-	synchronize_net();
 	netlink_kernel_release(sock);
+	aunet->nlsk = NULL;
 }
 
 static struct pernet_operations audit_net_ops __net_initdata = {
-- 
2.1.0

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

* Re: [Patch net-next] audit: remove useless synchronize_net()
  2016-11-29 17:14 [Patch net-next] audit: remove useless synchronize_net() Cong Wang
@ 2016-11-30  9:16 ` Richard Guy Briggs
  2016-11-30 17:20   ` Cong Wang
  2016-12-01 16:29 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Richard Guy Briggs @ 2016-11-30  9:16 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, linux-audit, pmoore

On 2016-11-29 09:14, Cong Wang wrote:
> netlink kernel socket is protected by refcount, not RCU.
> Its rcv path is neither protected by RCU. So the synchronize_net()
> is just pointless.

If I understand correctly, xfrm_user_net_exit() usage of
RCU_INIT_POINTER() and synchronize_net() is similarly pointless?  Also
net/phonet/socket.c?  I probably modelled things based on the former...

> Cc: Richard Guy Briggs <rgb@redhat.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
>  kernel/audit.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/audit.c b/kernel/audit.c
> index 92c463d..67b9fbd8 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -1172,9 +1172,8 @@ static void __net_exit audit_net_exit(struct net *net)
>  		audit_sock = NULL;
>  	}
>  
> -	RCU_INIT_POINTER(aunet->nlsk, NULL);
> -	synchronize_net();
>  	netlink_kernel_release(sock);
> +	aunet->nlsk = NULL;
>  }
>  
>  static struct pernet_operations audit_net_ops __net_initdata = {
> -- 
> 2.1.0
> 

- RGB

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

* Re: [Patch net-next] audit: remove useless synchronize_net()
  2016-11-30  9:16 ` Richard Guy Briggs
@ 2016-11-30 17:20   ` Cong Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2016-11-30 17:20 UTC (permalink / raw)
  To: Richard Guy Briggs
  Cc: Linux Kernel Network Developers, linux-audit, Paul Moore

On Wed, Nov 30, 2016 at 1:16 AM, Richard Guy Briggs <rgb@redhat.com> wrote:
> On 2016-11-29 09:14, Cong Wang wrote:
>> netlink kernel socket is protected by refcount, not RCU.
>> Its rcv path is neither protected by RCU. So the synchronize_net()
>> is just pointless.
>
> If I understand correctly, xfrm_user_net_exit() usage of
> RCU_INIT_POINTER() and synchronize_net() is similarly pointless?  Also
> net/phonet/socket.c?  I probably modelled things based on the former...

Possibly, but xfrm case is slightly different, it has two copies of the pointer
to the netlink socket, also it uses exit_batch(). I need to double check.

Take a look at better examples, fib_front, genetlink, rtnetlink.

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

* Re: [Patch net-next] audit: remove useless synchronize_net()
  2016-11-29 17:14 [Patch net-next] audit: remove useless synchronize_net() Cong Wang
  2016-11-30  9:16 ` Richard Guy Briggs
@ 2016-12-01 16:29 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-12-01 16:29 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, rgb

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Tue, 29 Nov 2016 09:14:56 -0800

> netlink kernel socket is protected by refcount, not RCU.
> Its rcv path is neither protected by RCU. So the synchronize_net()
> is just pointless.
> 
> Cc: Richard Guy Briggs <rgb@redhat.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2016-12-01 16:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-29 17:14 [Patch net-next] audit: remove useless synchronize_net() Cong Wang
2016-11-30  9:16 ` Richard Guy Briggs
2016-11-30 17:20   ` Cong Wang
2016-12-01 16:29 ` David Miller

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