Bug 29863 - Segmentation fault in memcmp-sse2.S if memory contents can concurrently change
Florian Weimer
fweimer@redhat.com
Tue Dec 13 21:20:02 GMT 2022
* Noah Goldstein via Libc-alpha:
> Is this something we have to support? I believe other functions /
> implementations of memcmp will suffer from a similar bug.
Of course the crash is by no means deterministic, so I'm not sure how
useful it is to detect application bugs. Maybe papering over the
application bug is the right approach here.
On the other hand, I really don't see how such a racing memcmp call
could deliver any useful information whatsoever. The result will always
be arbitrary in practice. So I hope such application bugs are really
rare.
> The fix:
> https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86_64/multiarch/memcmp-sse2.S;h=afd450d0206d6633da9fbc4607a7fa6aeb4e137c;hb=HEAD#l46
> ```
> -# define SIZE_OFFSET (CHAR_PER_VEC * 2)
> +# define SIZE_OFFSET 0
> ```
How costly is this change? I would have thought about ANDing the offset
so that it is always in range (but maybe it will stil result in a page
crossing, I don't really know how this works).
Thanks,
Florian
More information about the Libc-alpha
mailing list