From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5E1263839D07; Tue, 13 Dec 2022 20:09:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E1263839D07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670962191; bh=LDJBisxYXyk4rj+2nNSPC0G6Xlhwc9moRD1Aa++1bWs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wEfb+fWSdHFitfV43Z21q/HX7jB3YGCSXhhHCEKQ1m3cJP6cWltL4CAeTUBO9bQz5 GrhEJAnnrsrq43LlMjMaTUtRyzy0qOtC7tj4TS8LREpp8DIaRv4pbtqd0aQbUbu5dH 5tM207e24Mesx/WFfYF+/jonmVtkmSvkDsPzJ7os= From: "goldstein.w.n at gmail dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/29863] Segmentation fault in memcmp-sse2.S if memory contents can concurrently change Date: Tue, 13 Dec 2022 20:09:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc 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: Message-ID: In-Reply-To: References: 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29863 --- Comment #9 from Noah Goldstein --- (In reply to K.S. Bhaskar from comment #8) > (In reply to Andrew Pinski from comment #6) > > (In reply to Narayanan Iyer from comment #5)=20 > > > Seems to me you are saying that `memcmp()` can only be called on memo= ry that > > > is guaranteed to be never changing. And that it should never be calle= d on a > > > shared memory buffer whose contents could be concurrently changing as= it > > > goes into undefined behavior territory. That does not sound right to = me as > > > we have been using `memcmp()` with shared memory (where multiple proc= esses > > > write to that memory buffer all the time) for the past 25+ years on a > > > variety of architectures and operating systems and have never once se= en a > > > SIG-11 in memcmp(). > >=20 > > That does not mean it is correctly well defined code. > > memcmp cannot be used on memory which is going to be changed under its = back. > > since it is not atomic. >=20 > Since memcmp() is not atomic, it is of course appropriate for the the > results of the comparison to have a race condition. However, since the > addresses by which a process has that memory mapped don't change, a SIG-11 > should never occur. Even if all other processes which have that memory > mapped terminate while the memcmp() is running in a process, that process > will not unmap the memory and it will remain valid (assuming it was valid= to > start with). memcmp() is incorrect if the values change from under it. How that incorrectness will manifest is completely undefined. --=20 You are receiving this mail because: You are on the CC list for the bug.=