[PATCH v4 1/6] stdlib: Optimization qsort{_r} swap implementation (BZ 19305)

Alexander Monakov amonakov@ispras.ru
Thu Jul 13 13:13:53 GMT 2023


On Thu, 13 Jul 2023, Adhemerval Zanella Netto via Libc-alpha wrote:

> >> +  if (is_aligned (pbase, size, sizeof (uint64_t)))
> >> +    swap_func = SWAP_WORDS_64;
> > 
> > alignof not sizeof, in contexts like these that are talking about alignment not size.
> 
> Indeed, I will fix it.

Are you going to use GNU __alignof, or C11 _Alignof? One is safe. The other
makes the code go *boom* on 32-bit x86 when 'size' is 4 modulo 8, coming
this || close to a sneaky singular out-of-bounds write, saved only by the
fact that gcc doesn't (yet) do high-level transforms in swap_words_64.

(the code is not, in fact, talking solely about alignment there)

Alexander


More information about the Libc-alpha mailing list