Date: Tue, 30 Sep 2008 10:50:40 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-stable@freebsd.org Cc: mgass@unix.csbsju.edu, jb@freebsd.org, Jaakko Heinonen <jh@saunalahti.fi>, stable@freebsd.org Subject: Re: DTrace MFC broke kldstat(2) on RELENG_7 Message-ID: <200809301050.40828.jhb@freebsd.org> In-Reply-To: <20080930101559.GA810@a91-153-122-179.elisa-laajakaista.fi> References: <20080930101559.GA810@a91-153-122-179.elisa-laajakaista.fi>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 30 September 2008 06:15:59 am Jaakko Heinonen wrote: > > 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 > %%% This is what is in HEAD and should fix it: Index: kern_linker.c =================================================================== --- kern_linker.c (revision 183497) +++ kern_linker.c (working copy) @@ -1199,7 +1199,7 @@ td->td_retval[0] = 0; - return (copyout(&stat, uap->stat, sizeof(struct kld_file_stat))); + return (copyout(&stat, uap->stat, version)); } I will send in a request to MFC it in a second. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809301050.40828.jhb>