From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 22 20:58:23 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 67F5116A41C for ; Wed, 22 Jun 2005 20:58:23 +0000 (GMT) (envelope-from maslanbsd@gmail.com) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1685843D49 for ; Wed, 22 Jun 2005 20:58:22 +0000 (GMT) (envelope-from maslanbsd@gmail.com) Received: by wproxy.gmail.com with SMTP id 57so504578wri for ; Wed, 22 Jun 2005 13:58:22 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=q5S++blN8BzZ6nSlvVqEq7eiAl3T44KoO6QjYyBYXmd+DoDLifj8lWZLA3d8nydw0gt2aGGQUTc/fSjzvrHckb0hDS+6vvKOdjtmv0ZdqUVUrjg+jQ4CiyPNWbQLOTYwkiSh1W1NzCRFu+08KTMSi1MQLjHWf8b+GowG2WLd/7A= Received: by 10.54.76.6 with SMTP id y6mr697624wra; Wed, 22 Jun 2005 13:58:22 -0700 (PDT) Received: by 10.54.102.4 with HTTP; Wed, 22 Jun 2005 13:58:21 -0700 (PDT) Message-ID: <319cceca05062213587952cd42@mail.gmail.com> Date: Wed, 22 Jun 2005 23:58:22 +0300 From: Maslan To: Mauser In-Reply-To: <20050622192127.05bff1b8.mauser@poczta.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050622192127.05bff1b8.mauser@poczta.fm> Cc: freebsd-hackers@freebsd.org Subject: Re: kld problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Maslan List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2005 20:58:23 -0000 i don't know if kld should check if the module is used or not before unloading it. but i should. On 6/22/05, Mauser wrote: > Unloading syscall kernel module can cause a system crash. It occurs when = we > unload the module while a process is executing our syscall. Example: >=20 > $ cat kldtest.c >=20 > #include > #include > #include > #include > #include > #include > #include > #include > #include >=20 > static int test_nw; >=20 > static int test_syscall(struct thread *td, void *arg) { > struct timeval tv; > tv.tv_sec =3D 15; > tv.tv_usec =3D 0; > tsleep(&test_nw,PWAIT,"test",tvtohz(&tv)); > return 0; > } >=20 > static int test_offset =3D NO_SYSCALL; >=20 > static struct sysent test_sysent =3D { > 0, test_syscall > }; >=20 > static int test_load(struct module *mod, int cmd, void *arg) { > if(cmd !=3D MOD_LOAD && cmd !=3D MOD_UNLOAD) > return EOPNOTSUPP; > return 0; > } >=20 > SYSCALL_MODULE(test,&test_offset,&test_sysent,test_load,NULL); >=20 > $ cat calltest.c >=20 > #include > #include > #include > #include >=20 > int main() { > struct module_stat stat; > stat.version =3D sizeof(stat); > modstat(modfind("test"),&stat); > return syscall(stat.data.intval); > } >=20 > We load the module, execute calltest, and within 15 seconds unload the > module. We get a kernel panic, because we removed the memory where our > test_syscall was located. >=20 > Currently I don't have any idea how to fix it, but it would be nice to > inform about this issue in manual. >=20 > Maciek >=20 > ------------------------------------------------------------------ > Kwiaty dla Taty.. > Wyslij bukiet na Dzien Ojca.. >> http://link.interia.pl/f1897 << >=20 > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org= " >=20 --=20 I'm Searching For Perfection, So Even If U Need Portability U've To Use Assembly ;-) http://www.maslanlab.org