From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbbCZPGP (ORCPT ); Thu, 26 Mar 2015 11:06:15 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:44281 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751840AbbCZPGM (ORCPT ); Thu, 26 Mar 2015 11:06:12 -0400 Date: Thu, 26 Mar 2015 15:05:58 +0000 From: Russell King - ARM Linux To: Andrey Ryabinin Cc: Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Maria Guseva , Yury Gribov , stable@vger.kernel.org Subject: Re: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE Message-ID: <20150326150558.GK8656@n2100.arm.linux.org.uk> References: <1426849972-19606-1-git-send-email-a.ryabinin@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426849972-19606-1-git-send-email-a.ryabinin@samsung.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 20, 2015 at 02:12:52PM +0300, Andrey Ryabinin wrote: > Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel > split this is not so, because 2*TASK_SIZE overflows 32 bits, > so the actual value of ELF_ET_DYN_BASE is: > (2 * TASK_SIZE / 3) = 0x2a000000 > > When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address. > On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000] > for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled > as it fails to map shadow memory. > Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries > has a high chance of loading somewhere in between [0x2a000000 - 0x40000000] > even if ASLR enabled. This makes ASan with PIE absolutely incompatible. > > Fix overflow by dividing TASK_SIZE prior to multiplying. > After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y): > (TASK_SIZE / 3 * 2) = 0x7f555554 > > [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping > > Signed-off-by: Andrey Ryabinin > Reported-by: Maria Guseva > Cc: stable@vger.kernel.org Who's handling this patch? I'm guessing it should be me, so if it could find its way into my patch system for when I next apply a bunch of patches, that'd be good. Thanks. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. From mboxrd@z Thu Jan 1 00:00:00 1970 From: linux@arm.linux.org.uk (Russell King - ARM Linux) Date: Thu, 26 Mar 2015 15:05:58 +0000 Subject: [PATCH] arm: fix integer overflow in ELF_ET_DYN_BASE In-Reply-To: <1426849972-19606-1-git-send-email-a.ryabinin@samsung.com> References: <1426849972-19606-1-git-send-email-a.ryabinin@samsung.com> Message-ID: <20150326150558.GK8656@n2100.arm.linux.org.uk> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, Mar 20, 2015 at 02:12:52PM +0300, Andrey Ryabinin wrote: > Usually ELF_ET_DYN_BASE is 2/3 of TASK_SIZE. With 3G/1G user/kernel > split this is not so, because 2*TASK_SIZE overflows 32 bits, > so the actual value of ELF_ET_DYN_BASE is: > (2 * TASK_SIZE / 3) = 0x2a000000 > > When ASLR is disabled PIE binaries will load at ELF_ET_DYN_BASE address. > On 32bit platforms AddressSanitzer uses addresses [0x20000000 - 0x40000000] > for shadow memory [1]. So ASan doesn't work for PIE binaries when ASLR disabled > as it fails to map shadow memory. > Also after Kees's 'split ET_DYN ASLR from mmap ASLR' patchset PIE binaries > has a high chance of loading somewhere in between [0x2a000000 - 0x40000000] > even if ASLR enabled. This makes ASan with PIE absolutely incompatible. > > Fix overflow by dividing TASK_SIZE prior to multiplying. > After this patch ELF_ET_DYN_BASE equals to (for CONFIG_VMSPLIT_3G=y): > (TASK_SIZE / 3 * 2) = 0x7f555554 > > [1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerAlgorithm#Mapping > > Signed-off-by: Andrey Ryabinin > Reported-by: Maria Guseva > Cc: stable at vger.kernel.org Who's handling this patch? I'm guessing it should be me, so if it could find its way into my patch system for when I next apply a bunch of patches, that'd be good. Thanks. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.