Bug #174

Unloading md module causes a panic

Added by swildner over 8 years ago. Updated over 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:tuxillo% Done:

0%

Category:-
Target version:-

Description

Hi,

the following sequence of commands easily make my box (running HEAD) panic:

# kldload md
# kldunload md

Backtrace and dump available.

Sascha

md_module.jpg (118 KB) tuxillo, 01/22/2009 12:20 AM

History

#1 Updated by justin almost 8 years ago

Still present on 1.6.2-RELEASE, as I just found out.

#2 Updated by corecode almost 8 years ago

md does not have any means to be unloaded. we should either prevent that or add
unload code.

#3 Updated by aix-d over 7 years ago

how to reproduce kernel panic on 1.9.0-DEVEL:

cd /dev
sh MAKEDEV md0
disklabel md0

#4 Updated by tuxillo over 5 years ago

Still happening on 2.0.1
See attached image.

#5 Updated by nthery over 5 years ago

2009/1/22 Antonio Huete Jimenez (via DragonFly issue tracker)
<>:
>
> Antonio Huete Jimenez <> added the comment:
>
> Still happening on 2.0.1
> See attached image.

I can reproduce it if and only if md is already compiled in the kernel.

What happens is that when kldloading md, the kernel tries to register
the debug.mddebug sysctl a second time (as md is already in the
kernel). It complains (the "can't re-use a leaf" msg) and stops the
registration but carries on loading the module.

When kldunloading, the kernel tries to unregister the module instance
of debug.mddebug and panics because it was not registered in the first
place.

Is there a way to detect during kldload that the module is already
part of the kernel?

I propose to close this bug as it is caused by incorrect user manipulation.

#6 Updated by nthery over 5 years ago

Well, actually as Simon mentioned earlier, md has not been updated to
work as a module and it leaks memory when unloaded. I'm looking into
it.

#7 Updated by alexh almost 5 years ago

Any news about this? If not, disabling the option to unload should be trivial
and would offer a quick fix.

Cheers,
Alex Hornung

#8 Updated by tuxillo over 4 years ago

Hi,

I think what is happening here is , despite md is already included in the
kernel, the module is not registered and thus modlist_lookup2() doesn't find it,
so kldload() syscall succeeds instead of failing in EEXIST as it should be.

I'm going to try to provide a patch to fix this based on some recommendatiosn
given by Alex.

Cheers,
Antonio Huete

#9 Updated by tuxillo over 4 years ago

Committed a fix on 89adea1539ab67184124a82cc811031f3334024f

Also available in: Atom PDF