bin/127745: [patch] unbreak kldstat on releng_7

Edwin Groothuis edwin at mavetju.org
Tue Sep 30 10:40:04 UTC 2008


>Number:         127745
>Category:       bin
>Synopsis:       [patch] unbreak kldstat on releng_7
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 30 10:40:03 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Edwin Groothuis
>Release:        FreeBSD 7.1-PRERELEASE i386
>Organization:
-
>Environment:
System: FreeBSD k7.mavetju 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0 r183246M: Mon Sep 22 15:32:35 EST 2008 edwin at k7.mavetju:/mnt/ad8/obj/usr/home/edwin/svn/stable-7/sys/GENERIC i386

>Description:

Found on -stable

I recently noticed that kldstat(8) started to dump core for me on
RELENG_7. I traced the problem down to kldstat(2). r182231 (DTrace
MFC) introduced a new version of kld_file_stat struct and added
some code to support the old version of the structure in kldstat().
In the new code the old structure is known as kld_file_stat_1.
Unfortunately there's a bug in this code: kldstat() copies always
sizeof(struct kld_file_stat) of data to user space while it should
copy sizeof(struct kld_file_stat_1) when the old struct is used.

This guy is probably suffering from this problem too:
http://lists.freebsd.org/pipermail/freebsd-questions/2008-September/182896.html

>How-To-Repeat:
>Fix:

%%%
Index: sys/kern/kern_linker.c
===================================================================
--- sys/kern/kern_linker.c      (revision 183486)
+++ sys/kern/kern_linker.c      (working copy)
@@ -1199,7 +1199,12 @@ kldstat(struct thread *td, struct kldsta

	td->td_retval[0] = 0;

-       return (copyout(&stat, uap->stat, sizeof(struct kld_file_stat)));
+       if (version_num == 1)
+               return (copyout(&stat, uap->stat,
+                   sizeof(struct kld_file_stat_1)));
+       else
+               return (copyout(&stat, uap->stat,
+                   sizeof(struct kld_file_stat)));
}

int
%%%
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list