[musl] Re: realloci(): A realloc() variant that works in-place

Florian Weimer fweimer@redhat.com
Wed Nov 12 11:26:34 GMT 2025


* Brooks Davis:

>> > MTE is likely to have similar issues with pointer updates unless the
>> > implementer ensures that realloc returns pointers of the same color.
>> 
>> Only if pointer additions wrap around, but that would be a problem even
>> without MTE: ptrdiff_t cannot represent all potential pointer offsets
>> anyway.
>
> The issues is that if new and old are different colors, you must derive
> the updates from new and not old or you'll have the wrong color.  

The tag change would end up in ptrdiff_t.  I think MTE still uses 64-bit
arithmetic for pointers.

(And what I wrote above is wrong for most (all?) Linux 64-bit
architectures: offsets between object pointers are always representable
in ptrdiff_t.)

Thanks,
Florian



More information about the Libc-alpha mailing list