glibc/0001-s390x-Fix-segfault-in-wcsncmp-BZ-31934.patch
liqingqing_1229 8ead2a5406 sync from glibc upstream 2.38 branch.
here are the patches:
9184c13681 resolv: Fix tst-resolv-short-response for older GCC (bug 32042)
3ac7ba61d2 Update syscall lists for Linux 6.5
6bb75212e6 Add mremap tests
f0e2114535 mremap: Update manual entry
0301637b99 linux: Update the mremap C implementation [BZ #31968]
1bed6acf50 resolv: Track single-request fallback via _res._flags (bug 31476)
6cad0f543c resolv: Do not wait for non-existing second DNS response after error (bug 30081)
dc512364e8 resolv: Allow short error responses to match any query (bug 31890)
bb30bd2162 Linux: Make __rseq_size useful for feature detection (bug 31965)
d9d019d674 elf: Make dl-rseq-symbols Linux only
7bfc35959d nptl: fix potential merge of __rseq_* relro symbols
712453634c s390x: Fix segfault in wcsncmp [BZ #31934]

(cherry picked from commit bfffcbf6ae59fd90403d1a40103b2a61ba4aaf6b)
2024-08-06 19:37:39 +08:00

59 lines
2.1 KiB
Diff

From 712453634c8efd71a9b3ff0122145a9e90e9955c Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 11 Jul 2024 11:28:53 +0200
Subject: [PATCH 01/12] s390x: Fix segfault in wcsncmp [BZ #31934]
The z13/vector-optimized wcsncmp implementation segfaults if n=1
and there is only one character (equal on both strings) before
the page end. Then it loads and compares one character and misses
to check n again. The following load fails.
This patch removes the extra load and compare of the first character
and just start with the loop which uses vector-load-to-block-boundary.
This code-path also checks n.
With this patch both tests are passing:
- the simplified one mentioned in the bugzilla 31934
- the full one in Florian Weimer's patch:
"manual: Document a GNU extension for strncmp/wcsncmp"
(https://patchwork.sourceware.org/project/glibc/patch/874j9eml6y.fsf@oldenburg.str.redhat.com/):
On s390x-linux-gnu (z16), the new wcsncmp test fails due to bug 31934.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 9b7651410375ec8848a1944992d663d514db4ba7)
---
sysdeps/s390/wcsncmp-vx.S | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/sysdeps/s390/wcsncmp-vx.S b/sysdeps/s390/wcsncmp-vx.S
index 1bf769b870..4028d1e624 100644
--- a/sysdeps/s390/wcsncmp-vx.S
+++ b/sysdeps/s390/wcsncmp-vx.S
@@ -59,14 +59,7 @@ ENTRY(WCSNCMP_Z13)
sllg %r4,%r4,2 /* Convert character-count to byte-count. */
locgrne %r4,%r1 /* Use max byte-count, if bit 0/1 was one. */
- /* Check first character without vector load. */
- lghi %r5,4 /* current_len = 4 bytes. */
- /* Check s1/2[0]. */
- lt %r0,0(%r2)
- l %r1,0(%r3)
- je .Lend_cmp_one_char
- crjne %r0,%r1,.Lend_cmp_one_char
-
+ lghi %r5,0 /* current_len = 0 bytes. */
.Lloop:
vlbb %v17,0(%r5,%r3),6 /* Load s2 to block boundary. */
vlbb %v16,0(%r5,%r2),6 /* Load s1 to block boundary. */
@@ -167,7 +160,6 @@ ENTRY(WCSNCMP_Z13)
srl %r4,2 /* And convert it to character-index. */
vlgvf %r0,%v16,0(%r4) /* Load character-values. */
vlgvf %r1,%v17,0(%r4)
-.Lend_cmp_one_char:
cr %r0,%r1
je .Lend_equal
lghi %r2,1
--
2.33.0