From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 30 10:40:03 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC26A1065739 for ; Tue, 30 Sep 2008 10:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C2D2A8FC13 for ; Tue, 30 Sep 2008 10:40:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m8UAe3vM099903 for ; Tue, 30 Sep 2008 10:40:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m8UAe3CP099902; Tue, 30 Sep 2008 10:40:03 GMT (envelope-from gnats) Resent-Date: Tue, 30 Sep 2008 10:40:03 GMT Resent-Message-Id: <200809301040.m8UAe3CP099902@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Edwin Groothuis Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E862106568F for ; 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 ; 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 ; 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 ; 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 To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/127745: [patch] unbreak kldstat on releng_7 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Edwin Groothuis List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2008 10:40:04 -0000 >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@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: