From owner-freebsd-stable@FreeBSD.ORG Tue Sep 30 10:16:05 2008 Return-Path: Delivered-To: stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 20210106568B for ; Tue, 30 Sep 2008 10:16:05 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from emh03.mail.saunalahti.fi (emh03.mail.saunalahti.fi [62.142.5.109]) by mx1.freebsd.org (Postfix) with ESMTP id D162D8FC27 for ; Tue, 30 Sep 2008 10:16:04 +0000 (UTC) (envelope-from jh@saunalahti.fi) Received: from saunalahti-vams (vs3-10.mail.saunalahti.fi [62.142.5.94]) by emh03-2.mail.saunalahti.fi (Postfix) with SMTP id ACC62EBC9C; Tue, 30 Sep 2008 13:16:03 +0300 (EEST) Received: from emh03.mail.saunalahti.fi ([62.142.5.109]) by vs3-10.mail.saunalahti.fi ([62.142.5.94]) with SMTP (gateway) id A00727A06B0; Tue, 30 Sep 2008 13:16:03 +0300 Received: from a91-153-122-179.elisa-laajakaista.fi (a91-153-122-179.elisa-laajakaista.fi [91.153.122.179]) by emh03.mail.saunalahti.fi (Postfix) with SMTP id 3D639158AFA; Tue, 30 Sep 2008 13:16:00 +0300 (EEST) Date: Tue, 30 Sep 2008 13:15:59 +0300 From: Jaakko Heinonen To: jb@FreeBSD.org Message-ID: <20080930101559.GA810@a91-153-122-179.elisa-laajakaista.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Antivirus: VAMS Cc: mgass@unix.csbsju.edu, stable@FreeBSD.org Subject: DTrace MFC broke kldstat(2) on RELENG_7 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2008 10:16:05 -0000 Hi, 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 I used this patch to fix the problem: %%% 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 %%% -- Jaakko