glibc/sysdeps
Noah Goldstein 49953727d1 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 13:26:05 -07:00
..
aarch64 elf: Only process multiple tunable once (BZ 31686) 2024-05-07 14:06:56 -03:00
alpha Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
arc login: Check default sizes of structs utmp, utmpx, lastlog 2024-05-02 13:20:27 +02:00
arm login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-05-02 13:20:27 +02:00
csky login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-05-02 13:20:27 +02:00
generic Add mremap tests 2024-08-01 14:21:57 +02:00
gnu Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
hppa login: Check default sizes of structs utmp, utmpx, lastlog 2024-05-02 13:20:27 +02:00
htl Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
hurd Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
i386 math: Fix i386 and m68k exp10 on static build (BZ 31775) 2024-07-02 14:25:56 +02:00
ieee754 math: Provide missing math symbols on libc.a (BZ 31781) 2024-07-02 14:37:44 +02:00
loongarch LoongArch: Fix undefined __memset_aligned reference in ld.so linking. 2024-05-15 09:08:10 +08:00
m68k math: Fix i386 and m68k exp10 on static build (BZ 31775) 2024-07-02 14:25:56 +02:00
mach socket: Use may_alias on sockaddr structs (bug 19622) 2024-05-27 17:25:13 +02:00
microblaze login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-05-02 13:20:27 +02:00
mips login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-05-02 13:20:27 +02:00
nios2 login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-05-02 13:20:27 +02:00
nptl Linux: Make __rseq_size useful for feature detection (bug 31965) 2024-07-16 16:35:29 +02:00
or1k login: Check default sizes of structs utmp, utmpx, lastlog 2024-05-02 13:20:27 +02:00
posix Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
powerpc login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-05-02 13:20:27 +02:00
pthread Always define __USE_TIME_BITS64 when 64 bit time_t is used 2024-05-28 07:30:07 +02:00
riscv login: Check default sizes of structs utmp, utmpx, lastlog 2024-05-02 13:20:27 +02:00
s390 s390x: Fix segfault in wcsncmp [BZ #31934] 2024-07-16 10:25:35 +02:00
sh login: structs utmp, utmpx, lastlog _TIME_BITS independence (bug 30701) 2024-05-02 13:20:27 +02:00
sparc elf: Only process multiple tunable once (BZ 31686) 2024-05-07 14:06:56 -03:00
unix x32/cet: Support shadow stack during startup for Linux 6.10 2024-08-12 10:54:17 -07:00
wordsize-32 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
wordsize-64 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
x86 x86: Properly set x86 minimum ISA level [BZ #31883] 2024-06-15 11:13:10 +01:00
x86_64 x86: Fix bug in strchrnul-evex512 [BZ #32078] 2024-08-15 13:26:05 -07:00