From: Marcelo Ricardo Leitner <marcelo.leitner@xxxxxxxxx> Date: Thu, 10 Sep 2015 17:31:15 -0300 > Consider sctp module is unloaded and is being requested because an user > is creating a sctp socket. > > During initialization, sctp will add the new protocol type and then > initialize pernet subsys: ... > The problem is that after those calls to sctp_v{4,6}_protosw_init(), it > is possible for userspace to create SCTP sockets like if the module is > already fully loaded. If that happens, one of the possible effects is > that we will have readers for net->sctp.local_addr_list list earlier > than expected and sctp_net_init() does not take precautions while > dealing with that list, leading to a potential panic but not limited to > that, as sctp_sock_init() will copy a bunch of blank/partially > initialized values from net->sctp. > > The race happens like this: ... > Simply inverting the initialization order between > register_pernet_subsys() and sctp_v4_protosw_init() is not possible > because register_pernet_subsys() will create a control sctp socket, so > the protocol must be already visible by then. Deferring the socket > creation to a work-queue is not good specially because we loose the > ability to handle its errors. > > So, as suggested by Vlad, the fix is to split netns initialization in > two moments: defaults and control socket, so that the defaults are > already loaded by when we register the protocol, while control socket > initialization is kept at the same moment it is today. > > Fixes: 4db67e808640 ("sctp: Make the address lists per network namespace") > Signed-off-by: Vlad Yasevich <vyasevich@xxxxxxxxx> > Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@xxxxxxxxx> Applied and queued up for -stable, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html