From edwin@mavetju.org  Tue Sep 30 10:30:30 2008
Return-Path: <edwin@mavetju.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1E862106568F
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 2008 10:30:30 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: from mail5out.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	by mx1.freebsd.org (Postfix) with ESMTP id D47E98FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 2008 10:30:29 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: by mail5out.barnet.com.au (Postfix, from userid 1001)
	id 6ED5A2218B9E; Tue, 30 Sep 2008 20:30:28 +1000 (EST)
Received: from mail5auth.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail5auth.barnet.com.au", Issuer "*.barnet.com.au" (verified OK))
	by mail5.barnet.com.au (Postfix) with ESMTP id C9CFB21B6635
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 2008 20:30:26 +1000 (EST)
Received: from k7.mavetju (ppp121-44-153-110.lns10.syd7.internode.on.net [121.44.153.110])
	by mail5auth.barnet.com.au (Postfix) with ESMTP id 0730D2218951
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 Sep 2008 20:30:26 +1000 (EST)
Received: by k7.mavetju (Postfix, from userid 1001)
	id EB92A798; Tue, 30 Sep 2008 20:29:56 +1000 (EST)
Message-Id: <20080930102956.EB92A798@k7.mavetju>
Date: Tue, 30 Sep 2008 20:29:56 +1000 (EST)
From: Edwin Groothuis <edwin@mavetju.org>
Reply-To: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] unbreak kldstat on releng_7
X-Send-Pr-Version: 3.113
X-GNATS-Notify: jh@saunalahti.fi

>Number:         127745
>Category:       bin
>Synopsis:       [patch] unbreak kldstat(8) on releng_7
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gavin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 30 10:40:03 UTC 2008
>Closed-Date:    Thu Nov 06 11:26:57 UTC 2008
>Last-Modified:  Thu Nov 06 11:26:57 UTC 2008
>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@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:
Responsible-Changed-From-To: freebsd-bugs->jb 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Sep 30 10:43:10 UTC 2008 
Responsible-Changed-Why:  
Over to person who implemented it initially. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=127745 
State-Changed-From-To: open->closed 
State-Changed-By: gavin 
State-Changed-When: Thu Nov 6 11:26:00 UTC 2008 
State-Changed-Why:  
Close, this was fixed in SVN r183500. 
(Thanks to Jaakko Heinonen for pointing this out) 


Responsible-Changed-From-To: jb->gavin 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Thu Nov 6 11:26:00 UTC 2008 
Responsible-Changed-Why:  
Track 

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