From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9D29D387702E; Thu, 12 Mar 2020 21:59:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D29D387702E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584050374; bh=aRg29XcNG3MnH/CfAcMglNBfhHHF7BLyEg9pNtHEFxM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZM66F0J19aLTNoo59JRSELc92qx7MWNVKM84m0I6CqX6J7cl4s7hwKpRQmNsVDVVZ yha1BP5hMmEgbTO+QF4DsiqA5SCG+yWndUvJ1iyZMW+0jAC65Jor8CaguxhHCMEYyw /ss12BbVkxH5ljcfTxgl7Ab2uYub5THU6bKCIgIQ= From: "parker@cyber-itl.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94158] Expanded strlen causes out-of-bounds read on AMD64 target Date: Thu, 12 Mar 2020 21:59:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 9.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: parker@cyber-itl.org X-Bugzilla-Status: WAITING 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: 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: Thu, 12 Mar 2020 21:59:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94158 --- Comment #3 from Parker Thompson --- (In reply to Andrew Pinski from comment #2) > Also aligned_alloc normally does not allow alignment of 1. >=20 > So GCC is doing the correct thing. The replacement of strdup here is just to illustrate the issue with expansi= on alignment of strlen() by forcing a crash. I encountered this issue when working with a custom malloc replacement that would enforce out-of-bounds read checks. Using the same reproduction with c= lang did not produce a crash / oob-read. As for alloc alignment, glibc strdup() does not use aligned_alloc, just mal= loc. Which by my read of the spec does not guarantee alignment.=