[PATCH] Fix alignment bug in Safe-Linking

Eyal Itkin eyal.itkin@gmail.com
Mon Mar 30 17:18:37 GMT 2020


1. Alignment checks should be performed on the user's buffer and NOT
on the mchunkptr as was done before. This caused bugs in 32 bit
versions.
2. Improved the testing and fixed the check for the tcache case.
3. Removed unneeded '\' chars from end of lines.

This fixes the bugs on 32 bit archs as were found by Andreas.
I confused the alignments and initially checked the mchunkptr instead
of the user's buffer. On 64 bit binaries they are both aligned to
0x10, but on 32 bit binaries malloc still expects alignment of 0x10,
and the delta between the user's buffer to mchunkptr was 8 bytes and
this is why it failed the checks. Now I checked it on a 32 bit intel
machine and a 64 bit intel machine, and they both pass the tests.

It is important to note that the tcache works on the user's buffer,
while the fastbins use the mchunkptr type. This means I had to adjust
the alignment checks accordingly to use aligned_OK() and
misaligned_chunk().

Now that this is over, I will format my tests to match glibc's tests
and submit them as well.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-alignment-bug-in-Safe-Linking.patch
Type: application/octet-stream
Size: 4535 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20200330/7a0087a6/attachment.obj>


More information about the Libc-alpha mailing list