From owner-freebsd-current@freebsd.org Thu Feb 11 10:14:25 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55AA0A9FAEE for ; Thu, 11 Feb 2016 10:14:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C921B174 for ; Thu, 11 Feb 2016 10:14:24 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u1BAEIGa050442 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 11 Feb 2016 12:14:19 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u1BAEIGa050442 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u1BAEIl1050441; Thu, 11 Feb 2016 12:14:18 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 11 Feb 2016 12:14:18 +0200 From: Konstantin Belousov To: Hans Petter Selasky Cc: Greg Quinlan , "freebsd-current@freebsd.org" Subject: Re: Open Sound System - OSS "soundon" command causes KERNEL PANIC FreeBSD-11 Message-ID: <20160211101418.GO91220@kib.kiev.ua> References: <56BB0BDB.2090203@selasky.org> <872763758.2494245.1455156152295.JavaMail.yahoo@mail.yahoo.com> <56BC3041.7050203@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56BC3041.7050203@selasky.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Feb 2016 10:14:25 -0000 On Thu, Feb 11, 2016 at 07:54:57AM +0100, Hans Petter Selasky wrote: > On 02/11/16 03:02, Greg Quinlan wrote: > > Hi HPS, > > Note: Does not happen on FreeBSD 10.1-Stable! > > > > Yes, that's because WITNESS is off in 10.x by default. > > Does the attached patch solve your problem? No, the patch below does not solve the issue, it only papers over it. I object against committing this change. Issue is that, if called unlocked, the result from module_lookupbyname() could become invalid right after receiving. It is the duty of the caller of the function to ensure that the result is still valid, and the only way to achieve it is to own the lock around the whole code region which calls the function and utilizes its result. A bug is in the OSS code. > > --HPS > > Index: sys/kern/kern_module.c > =================================================================== > --- sys/kern/kern_module.c (revision 295464) > +++ sys/kern/kern_module.c (working copy) > @@ -214,16 +214,24 @@ > module_lookupbyname(const char *name) > { > module_t mod; > + int xlocked; > int err; > > - MOD_LOCK_ASSERT; > - > + /* > + * If the context is not properly locked, apply the proper > + * locks here: > + */ > + xlocked = sx_xlocked(&modules_sx); > + if (!xlocked) > + MOD_SLOCK; > TAILQ_FOREACH(mod, &modules, link) { > err = strcmp(mod->name, name); > if (err == 0) > - return (mod); > + break; > } > - return (NULL); > + if (!xlocked) > + MOD_SUNLOCK; > + return (mod); > } > > module_t > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"