[PATCHv3] malloc: Make sure tcache_key is odd enough
Cupertino Miranda
cupertino.miranda@oracle.com
Mon Aug 4 11:30:39 GMT 2025
On 04-08-2025 12:28, Cupertino Miranda wrote:
> Hi Wilco,
>
>
> On 04-08-2025 11:12, Wilco Dijkstra wrote:
>> Hi Cupertino,
>>
>>> In order to avoid having tcache_key repeated through memory, why don't
>>> we mangle it as well with, maybe not exactly as in PROTECT_PTR, however
>>> using the location of chunk. A XOR perhaps ?
>>>
>>> I don't think it would have such a huge performance impact on the
>>> overhaul execution time.
>>
>> What problem would that solve?
> Patch commit message says:
> "We want tcache_key not to be a commonly-occurring value in memory"
>
> The detection of double-free in tcache is
>> already quite limited. Using many different "keys" would only increase
>> collisions with user data (which is what we are trying to avoid with
>> this patch).
> Probability of collision even mangling the value does not change.
Please notice I did not proposed multiple keys.
>
> Anyway, I thought the purpose was to make it harder to identify where
> the linked lists are in memory, reducing the number of repeated
> occurrences of the key.
>
> Cheers,
> Cupertino
>
>>
>> Cheers,
>> Wilco
>
More information about the Libc-alpha
mailing list