netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gao feng <gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
To: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org,
	herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org
Subject: Re: [PATCH net-next v2 1/2] inetpeer: add namespace support for inetpeer
Date: Tue, 05 Jun 2012 20:29:35 +0800	[thread overview]
Message-ID: <4FCDFBAF.1090404@cn.fujitsu.com> (raw)
In-Reply-To: <1338886626.2760.2109.camel@edumazet-glaptop>

于 2012年06月05日 16:57, Eric Dumazet 写道:
> On Tue, 2012-06-05 at 15:52 +0800, Gao feng wrote:
> 
>> +static void __net_exit inetpeer_net_exit(struct net *net)
>> +{
>> +	inetpeer_invalidate_tree(net, AF_INET);
>> +	kfree(net->ipv4.peers);
>> +
>> +	inetpeer_invalidate_tree(net, AF_INET6);
>> +	kfree(net->ipv6.peers);
>> +}
>> +
> 
> Are we 1000% sure no code ever run in inetpeer land after this call ?

I am not sure,I need more time to research it.
I just do kfree peers here without set NULL pointer is
beacuse there is the same code with fib6_main_tbl in fib6_net_exit
and it seems work well.

Anyway, I will research it.

> 
> I would add
> 	net->ipv4.peers = NULL;
> 	net->ipv6.peers = NULL;
> 
> to catch NULL deref instead of strange errors, just in case.
> 
> By the way, I think we have a bug in inetpeer_gc_worker()
> 
> Steffen ?
> 
> We have no rcu grace period to make sure the following is safe :
> 
> if (!atomic_read(&p->refcnt)) {
> 	list_del(&p->gc_list);
> 	kmem_cache_free(peer_cachep, p);
> }
> 
> I'll post a fix like :
> 
> diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
> index d4d61b6..07731b5 100644
> --- a/net/ipv4/inetpeer.c
> +++ b/net/ipv4/inetpeer.c
> @@ -137,7 +137,7 @@ static void inetpeer_gc_worker(struct work_struct *work)
>  
>  		n = list_entry(p->gc_list.next, struct inet_peer, gc_list);
>  
> -		if (!atomic_read(&p->refcnt)) {
> +		if (atomic_cmpxchg(&p->refcnt, 0, -1) == 0) {
>  			list_del(&p->gc_list);
>  			kmem_cache_free(peer_cachep, p);
>  		}
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/containers

  parent reply	other threads:[~2012-06-05 12:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05  7:52 [PATCH net-next v2 1/2] inetpeer: add namespace support for inetpeer Gao feng
     [not found] ` <1338882737-11914-1-git-send-email-gaofeng-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2012-06-05  7:52   ` [PATCH net-next v2 2/2] inetpeer: add parameter net for inet_getpeer_v4, v6 Gao feng
2012-06-05  8:57 ` [PATCH net-next v2 1/2] inetpeer: add namespace support for inetpeer Eric Dumazet
2012-06-05 11:27   ` Steffen Klassert
2012-06-05 12:00     ` Eric Dumazet
2012-06-05 12:15       ` Steffen Klassert
     [not found]         ` <20120605121510.GD27795-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org>
2012-06-05 12:18           ` Eric Dumazet
2012-06-05 12:29   ` Gao feng [this message]
2012-06-06 17:43 ` David Miller
     [not found]   ` <20120606.104323.1698446129331745479.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-06-07 21:43     ` David Miller
     [not found]       ` <20120607.144301.1259354794384347085.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-06-08  1:44         ` Gao feng
2012-06-08  3:53           ` David Miller
     [not found]             ` <20120607.205348.913373847915721607.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-06-08  5:27               ` Gao feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FCDFBAF.1090404@cn.fujitsu.com \
    --to=gaofeng-bthxqxjhjhxqfuhtdcdx3a@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
    --cc=eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).