linux/net/core
Eric Dumazet 073862ba5d netns: fix net_alloc_generic()
When a new net namespace is created, we should attach to it a "struct
net_generic" with enough slots (even empty), or we can hit the following
BUG_ON() :

[  200.752016] kernel BUG at include/net/netns/generic.h:40!
...
[  200.752016]  [<ffffffff825c3cea>] ? get_cfcnfg+0x3a/0x180
[  200.752016]  [<ffffffff821cf0b0>] ? lockdep_rtnl_is_held+0x10/0x20
[  200.752016]  [<ffffffff825c41be>] caif_device_notify+0x2e/0x530
[  200.752016]  [<ffffffff810d61b7>] notifier_call_chain+0x67/0x110
[  200.752016]  [<ffffffff810d67c1>] raw_notifier_call_chain+0x11/0x20
[  200.752016]  [<ffffffff821bae82>] call_netdevice_notifiers+0x32/0x60
[  200.752016]  [<ffffffff821c2b26>] register_netdevice+0x196/0x300
[  200.752016]  [<ffffffff821c2ca9>] register_netdev+0x19/0x30
[  200.752016]  [<ffffffff81c1c67a>] loopback_net_init+0x4a/0xa0
[  200.752016]  [<ffffffff821b5e62>] ops_init+0x42/0x180
[  200.752016]  [<ffffffff821b600b>] setup_net+0x6b/0x100
[  200.752016]  [<ffffffff821b6466>] copy_net_ns+0x86/0x110
[  200.752016]  [<ffffffff810d5789>] create_new_namespaces+0xd9/0x190

net_alloc_generic() should take into account the maximum index into the
ptr array, as a subsystem might use net_generic() anytime.

This also reduces number of reallocations in net_assign_generic()

Reported-by: Sasha Levin <levinsasha928@gmail.com>
Tested-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Sjur Brændeland <sjur.brandeland@stericsson.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-01-26 13:36:19 -05:00
..
datagram.c
dev.c net: fix NULL-deref in WARN() in skb_gso_segment() 2012-01-17 15:51:23 -05:00
dev_addr_lists.c net: introduce netif_addr_lock_nested() and call if when appropriate 2012-01-09 12:46:58 -08:00
drop_monitor.c
dst.c
ethtool.c ethtool: allow ETHTOOL_GSSET_INFO for users 2012-01-22 23:41:05 -05:00
fib_rules.c
filter.c
flow.c
flow_dissector.c net: flow_dissector.c missing include linux/export.h 2012-01-24 16:03:33 -05:00
gen_estimator.c
gen_stats.c
iovec.c
kmap_skb.h
link_watch.c
Makefile
neighbour.c
net-sysfs.c bql: Fix inconsistency between file mode and attr method. 2012-01-17 10:05:55 -05:00
net-sysfs.h
net-traces.c
net_namespace.c netns: fix net_alloc_generic() 2012-01-26 13:36:19 -05:00
netevent.c
netpoll.c net: reintroduce missing rcu_assign_pointer() calls 2012-01-12 12:26:56 -08:00
netprio_cgroup.c
pktgen.c pktgen: Fix unsigned function that is returning negative vals 2012-01-22 15:08:44 -05:00
request_sock.c
rtnetlink.c Merge branch 'for-linus' of git://selinuxproject.org/~jmorris/linux-security 2012-01-14 18:36:33 -08:00
scm.c
secure_seq.c net: fix some sparse errors 2012-01-17 10:31:12 -05:00
skbuff.c
sock.c net: introduce res_counter_charge_nofail() for socket allocations 2012-01-22 15:08:46 -05:00
sock_diag.c sock_diag: Introduce the meminfo nla core (v2) 2011-12-30 16:42:19 -05:00
stream.c
sysctl_net_core.c
timestamping.c
user_dma.c
utils.c