Subject: Re: malloc_type_{attach|detach}
To: Bill Studenmund <>
From: Jaromir Dolecek <>
List: tech-kern
Date: 04/07/2003 13:26:22
Bill Studenmund wrote:
> On Fri, 4 Apr 2003, Jaromir Dolecek wrote:
> > even through I've modified smbfs LKM code to call the malloc type
> > attach/detach function, I still occassionally see a kernel panic
> > from unrelated malloc call when I try to load/unload the smbfs LKM.
> I don't think splhigh() is the right one. But we already have an slp that
> protects memory allocation, and we should be using it. From looking at man
> 9 spl (thanks Allen!), it's splvm() (its name used to be different).

Actually it doesn't seem to be a race per se. Even if I call
malloc_type_{attach|detach) on splvm() or splhigh(), I get repeatable
panic by

1. modunload smbfs.o
2. ... do some stuff which needs to allocate anons, like make
3. panic in malloc

It seems it's not safe to detach malloc type at all. How exactly
is it used? I think a stale pointer migh be left behind in some
malloc bucket, making system panic once something would attempt
to use memory from that bucket later.

Jaromir Dolecek <>  
-=- We should be mindful of the potential goal, but as the tantric    -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow.   Do not let this distract you.''     -=-