From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75434 invoked by alias); 21 Oct 2015 02:09:25 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 75259 invoked by uid 48); 21 Oct 2015 02:09:20 -0000 From: "ch3root at openwall dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/67999] Wrong optimization of pointer comparisons Date: Wed, 21 Oct 2015 02:09:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 5.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ch3root at openwall dot com 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg01688.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67999 --- Comment #18 from Alexander Cherepanov --- I guess nobody doubts that the current situation in gcc+glibc (and clang+glibc) should be fixed as valid programs are miscompiled. And it's easy to imagine security consequences of this when buffers have sizes controlled by attackers. The problem is not limited to the comparisons of the form 'p + a < p', all comparison of the form 'p + a < p + b' are probably miscompiled. And subtraction of pointers is problematic too: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45779 The issue affects not only all 32-bit platforms (i386, x32, arm, etc.) but also 16-bit ones, right? Or all of them are dead? Recently even 18-bit one was mentioned... Whether gcc violates C11 or not is not clear. The standard mostly speaks about compiler+library. OTOH gcc can be used as a freestanding implementation and even in a hosted environment, in practice, AIUI there could be external objects, not from compiler or libc. Hence IMHO this limitation should at least be documented in a user-visible place. (The same for libc's: if they cannot deal with huge objects it should be documented even if they cannot create them.)