From owner-svn-src-head@FreeBSD.ORG Wed Jan 5 09:58:41 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 802C8106564A; Wed, 5 Jan 2011 09:58:41 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 54D568FC12; Wed, 5 Jan 2011 09:58:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p059wf0l072210; Wed, 5 Jan 2011 09:58:41 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p059wfTN072208; Wed, 5 Jan 2011 09:58:41 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201101050958.p059wfTN072208@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 5 Jan 2011 09:58:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216988 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jan 2011 09:58:41 -0000 Author: trasz Date: Wed Jan 5 09:58:41 2011 New Revision: 216988 URL: http://svn.freebsd.org/changeset/base/216988 Log: Fix page fault that occurred when trying to initialize preloaded kernel module, the dependency of which was preloaded, but failed to initialize. Previously, kernel dereferenced NULL pointer returned by modlist_lookup2(); now, when this happens, we unload the dependent module. Since the depended_files list is sorted in dependency order, this properly propagates, unloading modules that depend on failed ones. From the user point of view, this prevents the kernel from panicing when trying to boot kernel compiled without KDTRACE_HOOKS with dtraceall_load="YES" in /boot/loader.conf. Reviewed by: kib Modified: head/sys/kern/kern_linker.c Modified: head/sys/kern/kern_linker.c ============================================================================== --- head/sys/kern/kern_linker.c Wed Jan 5 09:45:20 2011 (r216987) +++ head/sys/kern/kern_linker.c Wed Jan 5 09:58:41 2011 (r216988) @@ -1584,6 +1584,12 @@ restart: modname = mp->md_cval; verinfo = mp->md_data; mod = modlist_lookup2(modname, verinfo); + if (mod == NULL) { + printf("KLD file %s - cannot find " + "dependency \"%s\"\n", + lf->filename, modname); + goto fail; + } /* Don't count self-dependencies */ if (lf == mod->container) continue; @@ -1600,11 +1606,9 @@ restart: */ error = LINKER_LINK_PRELOAD_FINISH(lf); if (error) { - TAILQ_REMOVE(&depended_files, lf, loaded); printf("KLD file %s - could not finalize loading\n", lf->filename); - linker_file_unload(lf, LINKER_UNLOAD_FORCE); - continue; + goto fail; } linker_file_register_modules(lf); if (linker_file_lookup_set(lf, "sysinit_set", &si_start, @@ -1612,6 +1616,10 @@ restart: sysinit_add(si_start, si_stop); linker_file_register_sysctls(lf); lf->flags |= LINKER_FILE_LINKED; + continue; +fail: + TAILQ_REMOVE(&depended_files, lf, loaded); + linker_file_unload(lf, LINKER_UNLOAD_FORCE); } /* woohoo! we made it! */ }