login
Header Space

 
 

Re: [PATCH 3/14][TUN]: Introduce the tun_net structure.

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <paulmck@...>
Cc: Linux Netdev List <netdev@...>, Daniel Lezcano <dlezcano@...>, Denis Lunev <den@...>, Linux Containers <containers@...>, Benjamin Thery <benjamin.thery@...>
Date: Friday, April 11, 2008 - 11:45 am

Paul E. McKenney wrote:

No.


tun_net_exit is called only when a struct net is no longer referenced
and is going to be kfree-ed itself, so it's impossible (or BUGy by its
own) that someone still has a pointer on this net.

Providing the struct net is alive (!), the net->gen array is alive (or
is scheduled for kfree after RCU grace period). Thus, if your code 
holds the net and uses the net_generic() call, then it will get alive 
net->gen array and alive tun_net pointer.

Next, what happens after net_generic() completes and leaves the RCU-read 
section? Simple - the struct net is (should be) still referenced, so the
tun_net_exit cannot yet be called and thus the tun_net pointer obtained
earlier is alive. Unlike the (possibly) former instance of the net_generic
array, but nobody references this one in my code (and should not do so,
hm... I think I'll add this rule to the comments).


They are protected by struct net reference counting.


If this task dereferences a "held" struct net, then should be OK. If 
this task does not, this will OOPs in any case.

Consider the struct net to look like

struct net {
	...
	void *ptrs[N];
}

and the net_generic to be just

static inline void net_generic(struct net *net, int id)
{
	BUG_ON(id >= N);
	return net->ptrs[id - 1];
}

That's the same to what I propose, except for the ptrs array is on the
RCU protected memory.


Thanks,
Pavel
--
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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 12/14][VLAN]: Make vlan_name_type per-net., Pavel Emelyanov, (Thu Apr 10, 11:20 am)
[PATCH 10/14][VLAN]: Create proc files in proper net., Pavel Emelyanov, (Thu Apr 10, 11:18 am)
[PATCH 8/14][VLAN]: Introduce the vlan_net structure., Pavel Emelyanov, (Thu Apr 10, 11:14 am)
[PATCH 7/14][VLAN]: Tag vlan_group with device, not ifindex., Pavel Emelyanov, (Thu Apr 10, 11:13 am)
[PATCH 6/14][RTNL]: Introduce the rtnl_kill_links call., Pavel Emelyanov, (Thu Apr 10, 11:10 am)
Re: [PATCH 6/14][RTNL]: Introduce the rtnl_kill_links call., Daniel Hokka Zakrisson, (Thu Apr 10, 6:09 pm)
Re: [PATCH 6/14][RTNL]: Introduce the rtnl_kill_links call., Pavel Emelyanov, (Fri Apr 11, 4:01 am)
Re: [PATCH 6/14][RTNL]: Introduce the rtnl_kill_links call., Patrick McHardy, (Fri Apr 11, 8:48 am)
[PATCH 4/14][TUN]: Actually make the tun_dev_list per-net., Pavel Emelyanov, (Thu Apr 10, 11:07 am)
[PATCH 3/14][TUN]: Introduce the tun_net structure., Pavel Emelyanov, (Thu Apr 10, 11:06 am)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., David Miller, (Tue Apr 15, 3:44 am)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., Pavel Emelyanov, (Tue Apr 15, 6:31 am)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., David Miller, (Tue Apr 15, 6:06 am)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., Paul E. McKenney, (Thu Apr 10, 9:01 pm)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., Pavel Emelyanov, (Fri Apr 11, 3:55 am)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., Paul E. McKenney, (Fri Apr 11, 11:04 am)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., Pavel Emelyanov, (Fri Apr 11, 11:45 am)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., Paul E. McKenney, (Fri Apr 11, 12:27 pm)
Re: [PATCH 3/14][TUN]: Introduce the tun_net structure., Pavel Emelyanov, (Sat Apr 12, 4:44 am)
[PATCH 2/14][NETNS]: Generic per-net pointers., Pavel Emelyanov, (Thu Apr 10, 11:04 am)
Re: [PATCH 2/14][NETNS]: Generic per-net pointers., Daniel Lezcano, (Fri Apr 11, 9:43 am)
Re: [PATCH 2/14][NETNS]: Generic per-net pointers., Pavel Emelyanov, (Fri Apr 11, 10:29 am)
[PATCH 1/14][NETNS]: Introduce the net-subsys id generator., Pavel Emelyanov, (Thu Apr 10, 11:01 am)
speck-geostationary