From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B5DF53858C74; Tue, 15 Feb 2022 13:37:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5DF53858C74 From: "goldstein.w.n at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: string X-Bugzilla-Version: 2.36 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: goldstein.w.n at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2022 13:37:07 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28895 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 #include #include #include #include #include #include #define PAGE_SIZE 4096 static void * make_buf(uint64_t sz) { void * p =3D mmap(NULL, 2 * PAGE_SIZE + sz, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); assert(p !=3D NULL); assert(!mprotect(p + PAGE_SIZE, sz, PROT_READ | PROT_WRITE)); return p + PAGE_SIZE; } int main(int argc, char ** argv) { char * s1 =3D make_buf(0xd000 + 0x4000); char * s2 =3D make_buf(0xd000 + 0x4000); s1 +=3D 0xffa; s2 +=3D 0xfed; strcpy(s1, "tst-tlsmod%"); strcpy(s2, "tst-tls-manydynamic73mod"); if (strncmp(s1, s2, 10) !=3D 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). --=20 You are receiving this mail because: You are on the CC list for the bug.=