[PATCH 5/8] Consolidate the C pointer guard implementation into the generic header

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Jun 11 18:59:34 GMT 2026



On 10/06/26 18:14, DJ Delorie wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>> All the per-architecture pointer_guard.h files implemented the same C
>> PTR_MANGLE/PTR_DEMANGLE (an exclusive-or by the guard followed by a
>> rotate) and only differed in the assembly macros, which now live in the
>> separate pointer_guard-asm.h headers.  Remove the redundant per-arch C
>> headers and keep a single implementation in sysdeps/generic/pointer_guard.h,
>> which includes <pointer_guard-asm.h> for the assembly definitions.
>>
>> The i386 and x86_64 assembly headers do not depend on the Linux ABI, so
>> move them out of sysdeps/unix/sysv/linux into the generic per-arch
>> directories alongside the other targets.
> 
> I noticed that some of the manglers had a "rot 9" included and others
> did not, but the generic one does for everyone (but pointer-size
> dependent).  Is there a security implication here?  Are mangled pointers
> ever stored in such a way that this change might break something?

It was an overlook from my part. I first consolidate the implementations, and
then enabled them for all ABIs. Later I figured out why x86 did the rotate (it 
is an security improvement, the rotate makes recover/guess harder); and decided
to make it the generic implementations. But I forgot to also update some assembly
macros.

But the C and asm PTR_MANGLE/PTR_DEMANGLE must agree at all times, because they 
interoperate. I will implement the rotate on all assemble macros.

> 
> Otherwise LGTM
> Reviewed-by: DJ Delorie <dj@redhat.com>
> 



More information about the Libc-alpha mailing list