tech-kern archive

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

Re: Brainy: bug in x86/cpu_ucode_intel.c



Le 03/10/2015 15:45, Joerg Sonnenberger a écrit :
> On Sat, Oct 03, 2015 at 02:46:26PM +0200, Maxime Villard wrote:
>> You can see that the pointer given to kmem_free() is not the one kmem_alloc
>> returned. Actually, I don't understand at all what this code is supposed to
>> do. Found by Brainy.
> 
> It tries to make sure the pointer has a certain alignment. ...which
> likely is something we do by default, so this is not really visible.

Regarding kmem_alloc(9) this is not necessarily true, the allocator
"steals" the first few bytes of the allocation to store the requested
size (see the KMEM_SIZE option in [1] which is enabled under DIAGNOSTIC).

The only way I know of to guarantee alignement on a specific boundary is
through uvm_km_alloc or pool_cache.

[1] http://nxr.netbsd.org/xref/src/sys/kern/subr_kmem.c#63

-- 
Jean-Yves Migeon


Home | Main Index | Thread Index | Old Index