glibc/sysdeps
Noah Goldstein c005d1bd6f 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>

(cherry picked from commit 7da0886247)
2024-08-15 14:41:17 -07:00
..
aarch64
alpha
arc
arm login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
csky login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
generic Add mremap tests 2024-08-01 14:42:07 +02:00
gnu
hppa
htl
hurd
i386 i386: ulp update for SSE2 --disable-multi-arch configurations 2024-04-25 13:07:19 +02:00
ia64
ieee754
loongarch
m68k login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
mach
microblaze login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
mips login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
nios2 login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
nptl Linux: Make __rseq_size useful for feature detection (bug 31965) 2024-07-16 16:37:38 +02:00
or1k
posix
powerpc login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
pthread nptl: Fix tst-cancel30 on kernels without ppoll_time64 support 2024-04-23 21:18:04 +02:00
riscv
s390 s390x: Fix segfault in wcsncmp [BZ #31934] 2024-07-16 10:26:44 +02:00
sh login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
sparc login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-04-19 18:38:24 +02:00
unix Update syscall lists for Linux 6.5 2024-08-01 15:06:23 +02:00
wordsize-32
wordsize-64
x86 i386: Disable Intel Xeon Phi tests for GCC 15 and above (BZ 31782) 2024-05-28 09:33:22 -07:00
x86_64 x86: Fix bug in strchrnul-evex512 [BZ #32078] 2024-08-15 14:41:17 -07:00