x86: Fix bug in strncmp-evex and strncmp-avx2 [BZ #28895]
authorNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 16 Feb 2022 02:27:21 +0000 (20:27 -0600)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 16 Feb 2022 08:11:16 +0000 (02:11 -0600)
commite108c02a5e23c8c88ce66d8705d4a24bb6b9a8bf
treeaa7b3178016dfb0f5a270d900385d889016be1ee
parent0281c7a7ec8f3f46d8e6f5f3d7fca548946dbfce
x86: Fix bug in strncmp-evex and strncmp-avx2 [BZ #28895]

Logic can read before the start of `s1` / `s2` if both `s1` and `s2`
are near the start of a page. To avoid having the result contimated by
these comparisons the `strcmp` variants would mask off these
comparisons. This was missing in the `strncmp` variants causing
the bug. This commit adds the masking to `strncmp` so that out of
range comparisons don't affect the result.

test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass as
well a full xcheck on x86_64 linux.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
string/test-strncmp.c
sysdeps/x86_64/multiarch/strcmp-avx2.S
sysdeps/x86_64/multiarch/strcmp-evex.S