glibc/string
Noah Goldstein 7da0886247 x86: Fix bug in strchrnul-evex512 [BZ #32078]
Issue was we were expecting not matches with CHAR before the start of
the string in the page cross case.

The check code in the page cross case:
```
    and    $0xffffffffffffffc0,%rax
    vmovdqa64 (%rax),%zmm17
    vpcmpneqb %zmm17,%zmm16,%k1
    vptestmb %zmm17,%zmm17,%k0{%k1}
    kmovq  %k0,%rax
    inc    %rax
    shr    %cl,%rax
    je     L(continue)
```

expects that all characters that neither match null nor CHAR will be
1s in `rax` prior to the `inc`. Then the `inc` will overflow all of
the 1s where no relevant match was found.

This is incorrect in the page-cross case, as the
`vmovdqa64 (%rax),%zmm17` loads from before the start of the input
string.

If there are matches with CHAR before the start of the string, `rax`
won't properly overflow.

The fix is quite simple. Just replace:

```
    inc    %rax
    shr    %cl,%rax
```
With:
```
    sar    %cl,%rax
    inc    %rax
```

The arithmetic shift will clear any matches prior to the start of the
string while maintaining the signbit so the 1s can properly overflow
to zero in the case of no matches.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-15 08:11:33 -07:00
..
bits
_strerror.c
argz-addsep.c
argz-append.c
argz-count.c
argz-create.c
argz-ctsep.c
argz-delete.c
argz-extract.c
argz-insert.c
argz-next.c
argz-replace.c
argz-stringify.c
argz.h
basename.c
bcopy.c
bug-envz1.c
bug-strcoll1.c
bug-strcoll2.c
bug-strncat1.c
bug-strpbrk1.c
bug-strspn1.c
bug-strtok1.c
byteswap.h
bzero.c
Depend
endian.h
envz.c
envz.h
explicit_bzero.c
ffs.c
ffsll.c
inl-tester.c
Makefile Enhanced test coverage for strncmp, wcsncmp 2024-08-01 09:08:32 +02:00
memccpy.c
memchr.c
memcmp.c
memcmpeq.c
memcpy.c
memfrob.c
memmem.c
memmove.c
memory.h
mempcpy.c
memrchr.c
memset.c
noinl-tester.c
rawmemchr.c
sigabbrev_np.c
sigdescr_np.c
stpcpy.c
stpncpy.c
str-two-way.h
stratcliff.c
strcasecmp_l.c
strcasecmp.c
strcasestr.c
strcat.c
strchr.c
strchrnul.c
strcmp.c
strcoll_l.c
strcoll.c
strcpy.c
strcspn.c
strdup.c
strerror_l.c
strerror.c
strerrordesc_np.c
strerrorname_np.c
strfry.c
string-inlines.c
string.h
strings.h
strlcat.c
strlcpy.c
strlen.c
strncase_l.c
strncase.c
strncat.c
strncmp.c
strncpy.c
strndup.c
strnlen.c
strpbrk.c
strrchr.c
strsep.c
strsignal.c
strspn.c
strstr.c
strtok_r.c
strtok.c
strverscmp.c
strxfrm_l.c
strxfrm.c
swab.c
test-bcopy.c
test-bzero.c
test-endian-file-scope.c
test-endian-sign-conversion.c
test-endian-types.c
test-explicit_bzero.c
test-ffs.c
test-memccpy.c
test-memchr.c
test-memcmp.c
test-memcmpeq.c
test-memcpy-large.c
test-memcpy-support.h
test-memcpy.c
test-memmem.c
test-memmove.c
test-mempcpy.c
test-memrchr.c
test-memset.c
test-memswap.c
test-rawmemchr.c
test-sig_np.c
test-stpcpy.c
test-stpncpy.c
test-strcasecmp.c
test-strcasestr.c
test-strcat.c
test-strchr.c x86: Fix bug in strchrnul-evex512 [BZ #32078] 2024-08-15 08:11:33 -07:00
test-strchrnul.c
test-strcmp.c
test-strcpy.c
test-strcspn.c
test-strdup.c
test-strerror-errno.c
test-string.h
test-strlen.c
test-strncasecmp.c
test-strncat.c
test-strncmp-nonarray.c Enhanced test coverage for strncmp, wcsncmp 2024-08-01 09:08:32 +02:00
test-strncmp.c
test-strncpy.c
test-strndup.c
test-strnlen-nonarray.c Enhance test coverage for strnlen, wcsnlen 2024-08-01 09:07:34 +02:00
test-strnlen.c
test-strpbrk.c
test-strrchr.c
test-strspn.c
test-strstr.c wcsmbs: Ensure wcstr worst-case linear execution time (BZ 23865) 2024-04-11 14:21:32 -03:00
test-Xncmp-nonarray.c Enhanced test coverage for strncmp, wcsncmp 2024-08-01 09:08:32 +02:00
test-Xnlen-nonarray.c Enhance test coverage for strnlen, wcsnlen 2024-08-01 09:07:34 +02:00
testcopy.c
tester.c
tst-bswap.c
tst-cmp.c
tst-endian.c
tst-inlcall.c
tst-memmove-overflow.c
tst-strcoll-overflow.c
tst-strerror-fail.c
tst-strerror.c
tst-strfry.c
tst-strlcat2.c
tst-strlcat.c
tst-strlcpy2.c
tst-strlcpy.c
tst-strlen.c
tst-strsignal.c
tst-strtok_r.c
tst-strtok.c
tst-strxfrm2.c
tst-strxfrm.c
tst-svc2.c
tst-svc.c
tst-svc.expect
tst-svc.input
tst-xbzero-opt.c
Versions
wordcopy.c
xpg-strerror.c