From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A03BB389247F; Mon, 1 Feb 2021 16:42:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A03BB389247F From: "doko at debian dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/98920] New: [10/11 Regression] uses regexec without support for REG_STARTEND with -fsanitize=address Date: Mon, 01 Feb 2021 16:42:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: doko at debian dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.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 cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Feb 2021 16:42:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98920 Bug ID: 98920 Summary: [10/11 Regression] uses regexec without support for REG_STARTEND with -fsanitize=3Daddress Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: doko at debian dot org CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxi= n at gcc dot gnu.org Target Milestone: --- [forwarded from https://bugs.debian.org/949192] When gcc-10 compiles with -fsanitize=3Daddress, it substitutes any calls to regexec with a version that does not support REG_STARTEND. This makes code that is compiled fail unexpectedly or even produce spurious sanitization errors, since with that option the buffer need not be NUL-terminated. While REG_STARTEND is not in POSIX, it is found on the BSDs and Linux and users may reasonably rely on the fact that it is present on those systems. This issue has caused a bug in the Git testsuite as seen at https://lore.kernel.org/git/20200117174931.GA8958@coredump.intra.peff.net/T= /#t. I've attached a testcase. Without -fsanitize=3Daddress, it succeeds silently. With -fsanitize=3Daddress, it fails and prints an error. Please either fix the regexec implementation such that it is fully functional compared to the version in glibc or disable the sanitization of regexec until it has feature parity. $ cat test.c=20 #include #include #include int main(void) { regex_t r; const char s[] =3D "ban\0ana"; regmatch_t pmatch[10]; pmatch[0].rm_so =3D 0; pmatch[0].rm_eo =3D sizeof(s); if (regcomp(&r, "ana", 0)) return 2; if (regexec(&r, s, sizeof(pmatch)/sizeof(pmatch[0]), pmatch, REG_STARTE= ND)) { fprintf(stderr, "failed to match\n"); regfree(&r); return 3; } regfree(&r); return 0; } $ gcc-9 -fsanitize=3Daddress test.c && ./a.out=20 $ gcc-10 -fsanitize=3Daddress test.c && ./a.out=20 failed to match $ gcc-11 -fsanitize=3Daddress test.c && ./a.out=20 failed to match=