linux/net/tipc
Junwei Hu ca75a9fc5b tipc: fix modprobe tipc failed after switch order of device registration
commit 526f5b851a upstream.

Error message printed:
modprobe: ERROR: could not insert 'tipc': Address family not
supported by protocol.
when modprobe tipc after the following patch: switch order of
device registration, commit 7e27e8d613
("tipc: switch order of device registration to fix a crash")

Because sock_create_kern(net, AF_TIPC, ...) called by
tipc_topsrv_create_listener() in the initialization process
of tipc_init_net(), so tipc_socket_init() must be execute before that.
Meanwhile, tipc_net_id need to be initialized when sock_create()
called, and tipc_socket_init() is no need to be called for each namespace.

I add a variable tipc_topsrv_net_ops, and split the
register_pernet_subsys() of tipc into two parts, and split
tipc_socket_init() with initialization of pernet params.

By the way, I fixed resources rollback error when tipc_bcast_init()
failed in tipc_init_net().

Fixes: 7e27e8d613 ("tipc: switch order of device registration to fix a crash")
Signed-off-by: Junwei Hu <hujunwei4@huawei.com>
Reported-by: Wang Wang <wangwang2@huawei.com>
Reported-by: syzbot+1e8114b61079bfe9cbc5@syzkaller.appspotmail.com
Reviewed-by: Kang Zhou <zhoukang7@huawei.com>
Reviewed-by: Suanming Mou <mousuanming@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-04 08:02:34 +02:00
..
addr.c
addr.h
bcast.c
bcast.h
bearer.c tipc: fix a double free in tipc_enable_bearer() 2019-01-09 17:38:34 +01:00
bearer.h
core.c tipc: fix modprobe tipc failed after switch order of device registration 2019-06-04 08:02:34 +02:00
core.h
diag.c
discover.c
discover.h
eth_media.c
group.c
group.h
ib_media.c
Kconfig
link.c tipc: fix link re-establish failure 2018-11-23 08:17:04 +01:00
link.h
Makefile
monitor.c
monitor.h
msg.c
msg.h
name_distr.c
name_distr.h
name_table.c tipc: missing entries in name table of publications 2019-04-27 09:36:31 +02:00
name_table.h
net.c tipc: change to check tipc_own_id to return in tipc_net_stop 2019-04-03 06:26:18 +02:00
net.h
netlink_compat.c tipc: check link name with right length in tipc_nl_compat_link_set 2019-05-02 09:58:57 +02:00
netlink.c
netlink.h
node.c tipc: fix node keep alive interval calculation 2019-02-12 19:47:06 +01:00
node.h
socket.c tipc: fix hanging clients using poll with EPOLLOUT flag 2019-05-16 19:41:31 +02:00
socket.h
subscr.c
subscr.h tipc: fix modprobe tipc failed after switch order of device registration 2019-06-04 08:02:34 +02:00
sysctl.c
topsrv.c tipc: fix modprobe tipc failed after switch order of device registration 2019-06-04 08:02:34 +02:00
topsrv.h
udp_media.c tipc: fix a double kfree_skb() 2019-01-09 17:38:34 +01:00
udp_media.h