Eric W. Biederman 077130c0cf [NET]: Fix race when opening a proc file while a network namespace is exiting.
The problem:  proc_net files remember which network namespace the are
against but do not remember hold a reference count (as that would pin
the network namespace).   So we currently have a small window where
the reference count on a network namespace may be incremented when opening
a /proc file when it has already gone to zero.

To fix this introduce maybe_get_net and get_proc_net.

maybe_get_net increments the network namespace reference count only if it is
greater then zero, ensuring we don't increment a reference count after it
has gone to zero.

get_proc_net handles all of the magic to go from a proc inode to the network
namespace instance and call maybe_get_net on it.

PROC_NET the old accessor is removed so that we don't get confused and use
the wrong helper function.

Then I fix up the callers to use get_proc_net and handle the case case
where get_proc_net returns NULL.  In that case I return -ENXIO because
effectively the network namespace has already gone away so the files
we are trying to access don't exist anymore.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Acked-by: Paul E. McKenney <paulmck@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-10 16:49:22 -07:00
..
2007-08-22 19:52:46 -07:00
2007-05-08 11:14:59 -07:00
2007-09-28 15:36:42 -07:00
2007-07-16 09:05:52 -07:00
2007-07-31 15:39:36 -07:00
2007-09-11 17:21:19 -07:00
2007-09-25 08:51:04 -07:00
2007-10-08 12:58:14 -07:00
2007-07-21 17:49:14 -07:00
2006-10-04 06:51:26 -06:00
2007-07-20 08:44:19 -07:00
2007-07-19 10:04:43 -07:00
2007-07-19 10:04:45 -07:00
2007-07-29 17:09:29 -07:00
2007-05-18 13:09:34 -07:00
2007-09-20 13:19:59 -07:00
2007-05-21 09:18:19 -07:00
2007-05-08 11:15:01 -07:00
2007-05-08 11:15:09 -07:00
2007-07-16 09:05:48 -07:00
2007-09-11 11:38:25 -07:00
2007-05-09 06:44:57 +02:00
2007-09-11 17:21:27 -07:00
2007-05-11 08:29:36 -07:00
2007-07-19 10:04:45 -07:00
2007-07-19 10:04:45 -07:00
2007-07-27 08:08:51 +02:00
2006-10-01 00:39:19 -07:00
2007-07-27 15:40:13 -07:00
2007-07-10 08:04:15 +02:00
2007-09-20 13:19:59 -07:00
2007-07-16 09:05:46 -07:00