netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: marcelo.leitner@gmail.com
Cc: netdev@vger.kernel.org, vyasevich@gmail.com,
	nhorman@tuxdriver.com, linux-sctp@vger.kernel.org,
	David.Laight@ACULAB.COM
Subject: Re: [PATCH net v2] sctp: fix race on protocol/netns initialization
Date: Fri, 11 Sep 2015 15:00:42 -0700 (PDT)	[thread overview]
Message-ID: <20150911.150042.103516475042652216.davem@davemloft.net> (raw)
In-Reply-To: <d4d786dc6ae30a18e80435ffdee55f8c9582c3dc.1441916456.git.marcelo.leitner@gmail.com>

From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
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@gmail.com>
> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

Applied and queued up for -stable, thanks.

  reply	other threads:[~2015-09-11 22:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-09 20:03 [PATCH net] sctp: fix race on protocol/netns initialization Marcelo Ricardo Leitner
2015-09-09 20:30 ` Vlad Yasevich
2015-09-09 21:06   ` Marcelo Ricardo Leitner
2015-09-10 13:24     ` Vlad Yasevich
2015-09-10 14:22       ` Marcelo Ricardo Leitner
2015-09-10 15:50         ` Vlad Yasevich
2015-09-10 16:24           ` Marcelo Ricardo Leitner
2015-09-10 18:35             ` Marcelo Ricardo Leitner
2015-09-10 18:47               ` Marcelo Ricardo Leitner
2015-09-10 19:14               ` Vlad Yasevich
2015-09-10 19:42                 ` Marcelo Ricardo Leitner
2015-09-10 20:31                   ` [PATCH net v2] " Marcelo Ricardo Leitner
2015-09-11 22:00                     ` David Miller [this message]
2015-09-10  0:16 ` [PATCH net] " David Miller
2015-09-10 12:54   ` Marcelo Ricardo Leitner
2015-09-10 13:02     ` David Laight
2015-09-10 14:36       ` Marcelo Ricardo Leitner
2015-09-10 15:03         ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150911.150042.103516475042652216.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=David.Laight@ACULAB.COM \
    --cc=linux-sctp@vger.kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=vyasevich@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).