tech-kern archive

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

Re: kmem_alloc(0, f)



> Date: Sun, 30 Jul 2017 19:50:41 +0200
> From: Martin Husemann <martin%duskware.de@localhost>
> 
> On Sun, Jul 30, 2017 at 03:23:50PM -0000, Michael van Elst wrote:
> > So what does kmem_alloc(0, KM_SLEEP) do? fail where KM_SLEEP says it
> > cannot fail? I don't think that it can return a zero sized allocation
> > (i.e. ptr != NULL that cannot be dereferenced).
> 
> Sure it could, return a pointer inside some red zone unmapped (but reserved
> kva) page. On typical setups and modulo syscctl vm.user_va0_disable
> e.g. "return (void*)16;" just as a simple example.

It's slightly trickier than that because we expect that successful
kmem_alloc yields distinct results each time.  If we really wanted
this, we could, say, use vmem(9) to allocate distinct bytes within
these pages.


Home | Main Index | Thread Index | Old Index