Date: Tue, 3 Dec 2013 20:55:37 +0000 (UTC) From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r258890 - stable/10/sys/netinet Message-ID: <201312032055.rB3KtbKT087672@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tuexen Date: Tue Dec 3 20:55:37 2013 New Revision: 258890 URL: http://svnweb.freebsd.org/changeset/base/258890 Log: MFC r258574: Only initialize some mutexes for the default VNET. In r208160, sctp_it_ctl was made a global variable, across all VNETs. However, sctp_init() is called for every VNET that is created. This results in the same global mutexes which are part of sctp_it_ctl being initialized. This can result in crashes if many jails are created. To reproduce the problem: (1) Take a GENERIC kernel config, and add options for: VIMAGE, WITNESS, INVARIANTS. (2) Run this command in a loop: jail -l -u root -c path=/ name=foo persist vnet && jexec foo ifconfig lo0 127.0.0.1/8 && jail -r foo (see http://lists.freebsd.org/pipermail/freebsd-current/2010-November/021280.html ) Witness will warn about the same mutex being initialized. Fix the problem by only initializing these mutexes in the default VNET. MFC r258765: In http://svnweb.freebsd.org/changeset/base/258221 I introduced a bug which initialized global locks whenever the SCTP stack initialized. This was fixed in http://svnweb.freebsd.org/changeset/base/258574 by rodrigc@. He just initialized the locks for the default vnet. This fix reverts to the old behaviour before r258221, which explicitly makes sure it is only called once, because this works also on other platforms. Approved by: re@ (gjb) Modified: stable/10/sys/netinet/sctp_bsd_addr.c stable/10/sys/netinet/sctp_pcb.c Directory Properties: stable/10/sys/ (props changed) Modified: stable/10/sys/netinet/sctp_bsd_addr.c ============================================================================== --- stable/10/sys/netinet/sctp_bsd_addr.c Tue Dec 3 20:06:58 2013 (r258889) +++ stable/10/sys/netinet/sctp_bsd_addr.c Tue Dec 3 20:55:37 2013 (r258890) @@ -100,6 +100,9 @@ sctp_startup_iterator(void) /* You only get one */ return; } + /* Initialize global locks here, thus only once. */ + SCTP_ITERATOR_LOCK_INIT(); + SCTP_IPI_ITERATOR_WQ_INIT(); TAILQ_INIT(&sctp_it_ctl.iteratorhead); kproc_create(sctp_iterator_thread, (void *)NULL, Modified: stable/10/sys/netinet/sctp_pcb.c ============================================================================== --- stable/10/sys/netinet/sctp_pcb.c Tue Dec 3 20:06:58 2013 (r258889) +++ stable/10/sys/netinet/sctp_pcb.c Tue Dec 3 20:55:37 2013 (r258890) @@ -5864,8 +5864,6 @@ sctp_pcb_init() for (i = 0; i < SCTP_STACK_VTAG_HASH_SIZE; i++) { LIST_INIT(&SCTP_BASE_INFO(vtag_timewait)[i]); } - SCTP_ITERATOR_LOCK_INIT(); - SCTP_IPI_ITERATOR_WQ_INIT(); sctp_startup_iterator(); #if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312032055.rB3KtbKT087672>