From imura@ryu16.org  Mon Sep 15 10:25:34 2003
Return-Path: <imura@ryu16.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7269A16A4BF
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 15 Sep 2003 10:25:34 -0700 (PDT)
Received: from mail.ryu16.org (YahooBB219005044040.bbtec.net [219.5.44.40])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4E6AB43FDD
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 15 Sep 2003 10:25:32 -0700 (PDT)
	(envelope-from imura@ryu16.org)
Received: from redeye.xt.ryu16.org (localhost [127.0.0.1])
	by mail.ryu16.org (8.12.9/8.12.9) with ESMTP id h8FHPUCL052936
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Sep 2003 02:25:30 +0900 (JST)
	(envelope-from imura@redeye.xt.ryu16.org)
Received: (from imura@localhost)
	by redeye.xt.ryu16.org (8.12.9/8.12.9/Submit) id h8FHPUYE052935;
	Tue, 16 Sep 2003 02:25:30 +0900 (JST)
Message-Id: <200309151725.h8FHPUYE052935@redeye.xt.ryu16.org>
Date: Tue, 16 Sep 2003 02:25:30 +0900 (JST)
From: Ryuichiro Imura <imura@ryu16.org>
Reply-To: Ryuichiro Imura <imura@ryu16.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: kern_linker.c: prefversion != module's version causes panic
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         56897
>Category:       kern
>Synopsis:       kern_linker.c: prefversion != module's version causes panic
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 15 10:30:14 PDT 2003
>Closed-Date:    Tue Sep 16 01:01:23 PDT 2003
>Last-Modified:  Tue Sep 16 01:01:23 PDT 2003
>Originator:     Ryuichiro Imura
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD bluewind.xt.ryu16.org 5.1-CURRENT FreeBSD 5.1-CURRENT #1: Tue Sep 16 02:05:33 JST 2003     root@bluewind.xt.ryu16.org:/usr/src/sys/i386/compile/BLUE  i386


>Description:

In kern_linker.c, "bestmod" is initialized as NULL in
modlist_lookup2(), "ver > bestmod->version" causes
system panic, when md_ver_preferred != the module's version.


>How-To-Repeat:

Edit one of prefversion in MODULE_DEPEND() in the tree, and load it.


>Fix:

I don't know the case that found_modules has two modules
these name are the same, I just remove "ver > bestmod->version"...

Index: kern_linker.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_linker.c,v
retrieving revision 1.107
diff -u -u -9 -r1.107 kern_linker.c
--- kern_linker.c	27 Jul 2003 17:04:55 -0000	1.107
+++ kern_linker.c	15 Sep 2003 17:08:24 -0000
@@ -1079,20 +1079,19 @@
 	bestmod = NULL;
 	for (mod = TAILQ_FIRST(&found_modules); mod;
 	    mod = TAILQ_NEXT(mod, link)) {
 		if (strcmp(mod->name, name) != 0)
 			continue;
 		ver = mod->version;
 		if (ver == verinfo->md_ver_preferred)
 			return (mod);
 		if (ver >= verinfo->md_ver_minimum &&
-		    ver <= verinfo->md_ver_maximum &&
-		    ver > bestmod->version)
+		    ver <= verinfo->md_ver_maximum)
 			bestmod = mod;
 	}
 	return (bestmod);
 }
 
 static modlist_t
 modlist_newmodule(const char *modname, int version, linker_file_t container)
 {
 	modlist_t mod;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: roam 
State-Changed-When: Tue Sep 16 00:58:35 PDT 2003 
State-Changed-Why:  
This is almost a duplicate of PR kern/56570, although your patch 
is different.  Could you submit it as a followup to kern/56570, 
possibly using the GNATS web interface 
at http://www.FreeBSD.org/cgi/query-pr.cgi?pr=56570 if you are not 
subscribed to the -bugs mailing list? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=56897 
>Unformatted:
