NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/49695: Panic on modunload dtrace during running dtrace command



The following reply was made to PR kern/49695; it has been noted by GNATS.

From: Ryota Ozaki <ozaki-r%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/49695: Panic on modunload dtrace during running dtrace command
Date: Wed, 25 Feb 2015 17:48:30 +0900

 On Wed, Feb 25, 2015 at 5:20 PM,  <ozaki-r%netbsd.org@localhost> wrote:
 >>Number:         49695
 >>Category:       kern
 >>Synopsis:       Panic on modunload dtrace during running dtrace command
 >>Confidential:   no
 >>Severity:       serious
 >>Priority:       medium
 >>Responsible:    kern-bug-people
 >>State:          open
 >>Class:          sw-bug
 >>Submitter-Id:   net
 >>Arrival-Date:   Wed Feb 25 08:20:00 +0000 2015
 >>Originator:     Ryota Ozaki
 >>Release:        current (7.99.5)
 >>Organization:
 >>Environment:
 > NetBSD kvm 7.99.5 NetBSD 7.99.5 (KVM) #122: Wed Feb 25 11:52:26 JST 2015  ozaki-r@(hidden)
 >>Description:
 > dtrace.kmod doesn't take care of its module unloading. It tries to unload itself regardless of dtrace users and easily causes a panic. Additionally dtrace.kmod has to handle auto-unloading.
 >
 > This problem is reported by B Harder.
 >>How-To-Repeat:
 > modload dtrace
 > dtrace -n BEGIN &
 > modunload dtrace
 >>Fix:
 > This patch includes two fixes. One is to abandon unloading by checking if there are users of dtrace (/dev/dtrace/dtrace). The other is to forbid auto-unloading that isn't supported for now.
 >
 > diff --git a/external/cddl/osnet/dev/dtrace/dtrace_modevent.c b/external/cddl/osnet/dev/dtrace/dtrace_modevent.c
 > index 9df0cd1..30e6b0c 100644
 > --- a/external/cddl/osnet/dev/dtrace/dtrace_modevent.c
 > +++ b/external/cddl/osnet/dev/dtrace/dtrace_modevent.c
 > @@ -29,6 +29,7 @@ static int
 >  dtrace_modcmd(modcmd_t cmd, void *data)
 >  {
 >         int bmajor = -1, cmajor = -1;
 > +       int error;
 >
 >         switch (cmd) {
 >         case MODULE_CMD_INIT:
 > @@ -36,8 +37,12 @@ dtrace_modcmd(modcmd_t cmd, void *data)
 >                 return devsw_attach("dtrace", NULL, &bmajor,
 >                     &dtrace_cdevsw, &cmajor);
 >         case MODULE_CMD_FINI:
 > -               dtrace_unload();
 > +               error = dtrace_unload();
 > +               if (error != 0)
 > +                       return error;
 >                 return devsw_detach(NULL, &dtrace_cdevsw);
 > +       case MODULE_CMD_AUTOUNLOAD:
 > +               return EBUSY;
 >         default:
 >                 return ENOTTY;
 >         }
 
 A similar handling should be required by sdt.kmod and fbt.kmod.
 
   ozaki-r
 
 > diff --git a/external/cddl/osnet/dev/dtrace/dtrace_unload.c b/external/cddl/osnet/dev/dtrace/dtrace_unload.c
 > index 0d9f9fa..87b7a8e 100644
 > --- a/external/cddl/osnet/dev/dtrace/dtrace_unload.c
 > +++ b/external/cddl/osnet/dev/dtrace/dtrace_unload.c
 > @@ -37,9 +37,7 @@ dtrace_unload()
 >         mutex_enter(&dtrace_lock);
 >         mutex_enter(&cpu_lock);
 >
 > -       ASSERT(dtrace_opens == 0);
 > -
 > -       if (dtrace_helpers > 0) {
 > +       if (dtrace_opens > 0 || dtrace_helpers > 0) {
 >                 mutex_exit(&cpu_lock);
 >                 mutex_exit(&dtrace_lock);
 >                 mutex_exit(&dtrace_provider_lock);
 >
 


Home | Main Index | Thread Index | Old Index