public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "goldstein.w.n at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug string/28895] New: Wrong result in strncmp-avx2 and strncmp-evex Date: Tue, 15 Feb 2022 13:37:07 +0000 [thread overview] Message-ID: <bug-28895-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=28895 Bug ID: 28895 Summary: Wrong result in strncmp-avx2 and strncmp-evex Product: glibc Version: 2.36 Status: UNCONFIRMED Severity: normal Priority: P2 Component: string Assignee: unassigned at sourceware dot org Reporter: goldstein.w.n at gmail dot com Target Milestone: --- Wrong result for strncmp-avx2 and strncmp-evex when it hits the page cross case followed by the loop page cross case immediately afterwards with a short length. See following test case: ``` #include <assert.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> #include <wchar.h> #define PAGE_SIZE 4096 static void * make_buf(uint64_t sz) { void * p = mmap(NULL, 2 * PAGE_SIZE + sz, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); assert(p != NULL); assert(!mprotect(p + PAGE_SIZE, sz, PROT_READ | PROT_WRITE)); return p + PAGE_SIZE; } int main(int argc, char ** argv) { char * s1 = make_buf(0xd000 + 0x4000); char * s2 = make_buf(0xd000 + 0x4000); s1 += 0xffa; s2 += 0xfed; strcpy(s1, "tst-tlsmod%"); strcpy(s2, "tst-tls-manydynamic73mod"); if (strncmp(s1, s2, 10) != 0) { printf("Error!\n"); } } ``` Issue (for both evex and avx2) ``` .p2align 4,, 10 L(return_page_cross_end_check): tzcntl %ecx, %ecx ``` `ecx` can have garbabe in it from before the start of the string. Fix is to use the `r10` mask to and off these bad matches (strcmp was doing so. It was an oversight not to to do so in strncmp). -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2022-02-15 13:37 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-15 13:37 goldstein.w.n at gmail dot com [this message] 2022-02-15 13:56 ` [Bug string/28895] " fweimer at redhat dot com 2022-02-15 15:43 ` hjl.tools at gmail dot com 2022-02-15 15:43 ` hjl.tools at gmail dot com 2022-02-15 15:57 ` goldstein.w.n at gmail dot com 2022-02-16 10:41 ` goldstein.w.n at gmail dot com 2022-02-16 12:05 ` fweimer at redhat dot com 2022-02-16 12:24 ` goldstein.w.n at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-28895-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).