From 94749fd6ba48a09cd664f42a470b6113caa844d8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 3 Jun 2019 11:53:34 +0200 Subject: [PATCH] 4.14-stable patches added patches: revert-tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch --- ...-switch-order-of-device-registration.patch | 78 +++++++++ queue-4.14/series | 2 + ...-switch-order-of-device-registration.patch | 161 ++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 queue-4.14/revert-tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch create mode 100644 queue-4.14/tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch diff --git a/queue-4.14/revert-tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch b/queue-4.14/revert-tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch new file mode 100644 index 0000000000..e1974d1cf0 --- /dev/null +++ b/queue-4.14/revert-tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch @@ -0,0 +1,78 @@ +From 5593530e56943182ebb6d81eca8a3be6db6dbba4 Mon Sep 17 00:00:00 2001 +From: "David S. Miller" +Date: Fri, 17 May 2019 12:15:05 -0700 +Subject: Revert "tipc: fix modprobe tipc failed after switch order of device registration" + +From: David S. Miller + +commit 5593530e56943182ebb6d81eca8a3be6db6dbba4 upstream. + +This reverts commit 532b0f7ece4cb2ffd24dc723ddf55242d1188e5e. + +More revisions coming up. + +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman + +--- + net/tipc/core.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +--- a/net/tipc/core.c ++++ b/net/tipc/core.c +@@ -62,10 +62,6 @@ static int __net_init tipc_init_net(stru + INIT_LIST_HEAD(&tn->node_list); + spin_lock_init(&tn->node_list_lock); + +- err = tipc_socket_init(); +- if (err) +- goto out_socket; +- + err = tipc_sk_rht_init(net); + if (err) + goto out_sk_rht; +@@ -92,8 +88,6 @@ out_subscr: + out_nametbl: + tipc_sk_rht_destroy(net); + out_sk_rht: +- tipc_socket_stop(); +-out_socket: + return err; + } + +@@ -104,7 +98,6 @@ static void __net_exit tipc_exit_net(str + tipc_bcast_stop(net); + tipc_nametbl_stop(net); + tipc_sk_rht_destroy(net); +- tipc_socket_stop(); + } + + static struct pernet_operations tipc_net_ops = { +@@ -140,6 +133,10 @@ static int __init tipc_init(void) + if (err) + goto out_pernet; + ++ err = tipc_socket_init(); ++ if (err) ++ goto out_socket; ++ + err = tipc_bearer_setup(); + if (err) + goto out_bearer; +@@ -147,6 +144,8 @@ static int __init tipc_init(void) + pr_info("Started in single node mode\n"); + return 0; + out_bearer: ++ tipc_socket_stop(); ++out_socket: + unregister_pernet_subsys(&tipc_net_ops); + out_pernet: + tipc_unregister_sysctl(); +@@ -162,6 +161,7 @@ out_netlink: + static void __exit tipc_exit(void) + { + tipc_bearer_cleanup(); ++ tipc_socket_stop(); + unregister_pernet_subsys(&tipc_net_ops); + tipc_netlink_stop(); + tipc_netlink_compat_stop(); diff --git a/queue-4.14/series b/queue-4.14/series index 99ebabfb66..a928282835 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -16,3 +16,5 @@ net-mvpp2-fix-bad-mvpp2_txq_sched_token_cntr_reg-queue-value.patch net-phy-marvell10g-report-if-the-phy-fails-to-boot-firmware.patch crypto-vmx-ghash-do-nosimd-fallback-manually.patch xen-pciback-don-t-disable-pci_command-on-pci-device-reset.patch +revert-tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch +tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch diff --git a/queue-4.14/tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch b/queue-4.14/tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch new file mode 100644 index 0000000000..8b1c2e3fdc --- /dev/null +++ b/queue-4.14/tipc-fix-modprobe-tipc-failed-after-switch-order-of-device-registration.patch @@ -0,0 +1,161 @@ +From 526f5b851a96566803ee4bee60d0a34df56c77f8 Mon Sep 17 00:00:00 2001 +From: Junwei Hu +Date: Mon, 20 May 2019 14:43:59 +0800 +Subject: tipc: fix modprobe tipc failed after switch order of device registration + +From: Junwei Hu + +commit 526f5b851a96566803ee4bee60d0a34df56c77f8 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 7e27e8d6130c +("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: 7e27e8d6130c ("tipc: switch order of device registration to fix a crash") +Signed-off-by: Junwei Hu +Reported-by: Wang Wang +Reported-by: syzbot+1e8114b61079bfe9cbc5@syzkaller.appspotmail.com +Reviewed-by: Kang Zhou +Reviewed-by: Suanming Mou +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman + +--- + net/tipc/core.c | 18 ++++++++++++------ + net/tipc/subscr.c | 14 ++++++++++++-- + net/tipc/subscr.h | 5 +++-- + 3 files changed, 27 insertions(+), 10 deletions(-) + +--- a/net/tipc/core.c ++++ b/net/tipc/core.c +@@ -71,9 +71,6 @@ static int __net_init tipc_init_net(stru + goto out_nametbl; + + INIT_LIST_HEAD(&tn->dist_queue); +- err = tipc_topsrv_start(net); +- if (err) +- goto out_subscr; + + err = tipc_bcast_init(net); + if (err) +@@ -82,8 +79,6 @@ static int __net_init tipc_init_net(stru + return 0; + + out_bclink: +- tipc_bcast_stop(net); +-out_subscr: + tipc_nametbl_stop(net); + out_nametbl: + tipc_sk_rht_destroy(net); +@@ -93,7 +88,6 @@ out_sk_rht: + + static void __net_exit tipc_exit_net(struct net *net) + { +- tipc_topsrv_stop(net); + tipc_net_stop(net); + tipc_bcast_stop(net); + tipc_nametbl_stop(net); +@@ -107,6 +101,11 @@ static struct pernet_operations tipc_net + .size = sizeof(struct tipc_net), + }; + ++static struct pernet_operations tipc_topsrv_net_ops = { ++ .init = tipc_topsrv_init_net, ++ .exit = tipc_topsrv_exit_net, ++}; ++ + static int __init tipc_init(void) + { + int err; +@@ -137,6 +136,10 @@ static int __init tipc_init(void) + if (err) + goto out_socket; + ++ err = register_pernet_subsys(&tipc_topsrv_net_ops); ++ if (err) ++ goto out_pernet_topsrv; ++ + err = tipc_bearer_setup(); + if (err) + goto out_bearer; +@@ -144,6 +147,8 @@ static int __init tipc_init(void) + pr_info("Started in single node mode\n"); + return 0; + out_bearer: ++ unregister_pernet_subsys(&tipc_topsrv_net_ops); ++out_pernet_topsrv: + tipc_socket_stop(); + out_socket: + unregister_pernet_subsys(&tipc_net_ops); +@@ -161,6 +166,7 @@ out_netlink: + static void __exit tipc_exit(void) + { + tipc_bearer_cleanup(); ++ unregister_pernet_subsys(&tipc_topsrv_net_ops); + tipc_socket_stop(); + unregister_pernet_subsys(&tipc_net_ops); + tipc_netlink_stop(); +--- a/net/tipc/subscr.c ++++ b/net/tipc/subscr.c +@@ -344,7 +344,7 @@ static void *tipc_subscrb_connect_cb(int + return (void *)tipc_subscrb_create(conid); + } + +-int tipc_topsrv_start(struct net *net) ++static int tipc_topsrv_start(struct net *net) + { + struct tipc_net *tn = net_generic(net, tipc_net_id); + const char name[] = "topology_server"; +@@ -382,7 +382,7 @@ int tipc_topsrv_start(struct net *net) + return tipc_server_start(topsrv); + } + +-void tipc_topsrv_stop(struct net *net) ++static void tipc_topsrv_stop(struct net *net) + { + struct tipc_net *tn = net_generic(net, tipc_net_id); + struct tipc_server *topsrv = tn->topsrv; +@@ -391,3 +391,13 @@ void tipc_topsrv_stop(struct net *net) + kfree(topsrv->saddr); + kfree(topsrv); + } ++ ++int __net_init tipc_topsrv_init_net(struct net *net) ++{ ++ return tipc_topsrv_start(net); ++} ++ ++void __net_exit tipc_topsrv_exit_net(struct net *net) ++{ ++ tipc_topsrv_stop(net); ++} +--- a/net/tipc/subscr.h ++++ b/net/tipc/subscr.h +@@ -75,8 +75,9 @@ void tipc_subscrp_report_overlap(struct + void tipc_subscrp_convert_seq(struct tipc_name_seq *in, int swap, + struct tipc_name_seq *out); + u32 tipc_subscrp_convert_seq_type(u32 type, int swap); +-int tipc_topsrv_start(struct net *net); +-void tipc_topsrv_stop(struct net *net); ++ ++int __net_init tipc_topsrv_init_net(struct net *net); ++void __net_exit tipc_topsrv_exit_net(struct net *net); + + void tipc_subscrp_put(struct tipc_subscription *subscription); + void tipc_subscrp_get(struct tipc_subscription *subscription); -- 2.39.2