Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Jul 2010 08:48:25 -0700
From:      Matthew Fleming <mdf356@gmail.com>
To:        Ivan Voras <ivoras@freebsd.org>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: Multi-zone malloc(9)
Message-ID:  <AANLkTikqf7HtCiGsZ6YwuONYUR6tHu7jqXNPhgSHWVd9@mail.gmail.com>
In-Reply-To: <i2c6h5$3cv$1@dough.gmane.org>
References:  <AANLkTikoY8CuAF3DThBAXH_mu1QAuUWyRMtkaIomaoi7@mail.gmail.com> <i2c6h5$3cv$1@dough.gmane.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jul 23, 2010 at 6:47 AM, Ivan Voras <ivoras@freebsd.org> wrote:
> On 07/22/10 18:54, mdf@FreeBSD.org wrote:
>> Occasionally we run into use-after-free and malloc'd buffer overrun
>> scenarios. =A0When this happens it can be rather difficult to determine
>> what code is at fault, since e.g. every 64 byte allocation, regardless
>> of malloc type, comes from the same UMA zone. =A0This means that an
>> overflow in M_TEMP will affect M_DEVBUF, etc. =A0Adding multiple uma
>> zones for each bucket size means that we can hash on the malloc type's
>> shortdesc field so that there are fewer collisions and misused memory
>> from one malloc type only affects a subset of other malloc types.
>
> To what extent does something like this help? As I read it, you still
> have the problem of overflows from one allocation trashing data in some
> other random allocation, but now you also have to track which hash
> bucket is it in while debugging?

It helps in that, with several repros on different hash functions, you
now can know exactly which malloc type was doing the trashing, because
it's the intersection of all the hash classes from each instance.
Assuming you have a core dump, the hash class is listed in the
malloc_type_internal hanging off the malloc type, so it's easy to
correlate.  There's a ddb function in the patch to print all the
matching types, and a gdb script would be easy to write as well.

> And would this interfere with possible NUMA efforts? (because it sort of
> looks similar - hashing allocations to "zones", which in NUMA case would
> be per-CPU).

The NUMA effort with malloc/uma is still theoretical so I can't say
for sure, but I believe these two issues are orthogonal.

Thanks,
matthew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikqf7HtCiGsZ6YwuONYUR6tHu7jqXNPhgSHWVd9>