From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C7C9C54798 for ; Sat, 24 Feb 2024 01:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e74pT1gfqjSEBsU8H8aXWIwBN0L91p+VfG4X27a+ZCU=; b=yo4iH8nylu/6eN h4CLI66a5gRnI7HvO5MuYd9EuFiCS+q5GMh941b9KQKgIYzlIZJjHTXm8CEpXEpblnwimckAv7I06 +3DRYhH7m+DRQcErXNV2EN5lwRPwCJ7lLCudXcAbml3zwl/XnKO8EqtMLpjMSaEHZLpF281YLyKsk wnbPJA262ozuf7eRB6cHnC6U5+m8yQj4ow9zBpOm8fygF0z+Nq7ulpYRaUGXTuJNa5GeI6t9OaLOI I5Rf9UEl6Va8U+NEWmfI+2IW733KCT/nRn9jVYlJec+ROuIBYEgjUfC09qf1UGgGkJReyXbvY4fg/ x7UaUy7NxfVcTMCPxn3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdgPx-0000000Bjfb-1mFK; Sat, 24 Feb 2024 01:01:29 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdgPt-0000000BjfD-4Akr for linux-arm-kernel@lists.infradead.org; Sat, 24 Feb 2024 01:01:27 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6e332bc65b3so882594b3a.3 for ; Fri, 23 Feb 2024 17:01:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708736484; x=1709341284; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DRLwM6QENBYo07bvqNRkIhBVin7jRxajehNcXch+bs4=; b=O36qBG10pPsR6/J0C65x4zLWLxTboNRq5bClLkK3q8l67Xf3A9Y0VRjkMAA/6nVXJt v12ODb/aU7+d8XEQ/vYZ2MwSy9pqPwU7LPu5LozPU+vJsm6kgsTNhrKMzxijsmctnEE3 a8qG/gedCamMRbjZdXANQcmupCw/sslRKpjbY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708736484; x=1709341284; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DRLwM6QENBYo07bvqNRkIhBVin7jRxajehNcXch+bs4=; b=ZCK2k9U6eeJ2CxZQLTZb3SGGhGaTIfN74DXfOBlHgEQxr1NxjOrPk5unjhVoV6C3kD nzbPUmAspksgNs60XDN9iP7yffgZWyTs/QvcumtrVnWbo3cYtcjSGQrbuIjbgssihkLY BfUrPao0fTRUYjHwZ0E15vTSo1+IyxI43OWR16Z+anNwXiS/O9+JIQFF6INfPHJtpcEh 0pknTNLqRidT3QNa0CClmxwgrAU5eAQmt0k+SUEIbiAxDdnKI5hUIEvpPTMYpJPlcBKV U/KYeqiXdYH8l2ejcqgy9KcZmw2e/INcarPi73a+civY7XKr3jXLQD/fNMre0tpn5ePq ksZg== X-Forwarded-Encrypted: i=1; AJvYcCXebn7m7jQeh3pOMvBkTEZd4Rh6pVOG0bLIzstQFnTgdwFGRZcUYKCHj2vXlycXulH+5m1C73y7LYSIBylQMQ6A8vR7jpOV2FKYPc7hWyn3Qve/MrI= X-Gm-Message-State: AOJu0YyRXSPn2+FWafInQ3CpCNyTSgDzvDEFLdy6Ra/oqTcBWtlRTEi0 t3ZlvmMvn6a/9vTR4JkTQyLhkZTUIvUqqGujnyJWtmL7Eskuug2UwrVZPrJnKQ== X-Google-Smtp-Source: AGHT+IEQ/boZR0NbbEtoiMOkLTe3Imh3KOI4GOUbKXTvlWKbMxa6XhC6hM+HIa944+irNktavkW2SA== X-Received: by 2002:a05:6a21:8ccc:b0:19e:c777:5c6c with SMTP id ta12-20020a056a218ccc00b0019ec7775c6cmr1727576pzb.19.1708736482583; Fri, 23 Feb 2024 17:01:22 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id y5-20020a62b505000000b006e0447d48b0sm90582pfe.23.2024.02.23.17.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 17:01:22 -0800 (PST) Date: Fri, 23 Feb 2024 17:01:21 -0800 From: Kees Cook To: Dmitry Vyukov Cc: Kostya Serebryany , Vitaly Buka , glider@google.com, Evgeniy Stepanov , Daniel Micay , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Pratyush Anand , Dong Bo , Dmitry Safonov , Rik van Riel , Andy Lutomirski , Grzegorz Andrejczuk , linux-arm-kernel@lists.infradead.org, Reid Kleckner , Andrew Morton , Peter Collingbourne , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, address-sanitizer@googlegroups.com Subject: Re: [PATCH] mm: Revert x86_64 and arm64 ELF_ET_DYN_BASE base Message-ID: <202402231649.086D1A3A@keescook> References: <20170807201542.GA21271@beast> <202402162238.E5D08F5968@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240223_170126_080614_A91AB769 X-CRM114-Status: GOOD ( 29.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Feb 20, 2024 at 08:47:09AM +0100, Dmitry Vyukov wrote: > On Sat, 17 Feb 2024 at 07:50, Kees Cook wrote: > > > > *extreme thread[1] necromancy* > > > > On Mon, Aug 07, 2017 at 01:15:42PM -0700, Kees Cook wrote: > > > Moving the x86_64 and arm64 PIE base from 0x555555554000 to 0x000100000000 > > > broke AddressSanitizer. This is a partial revert of: > > > > > > commit eab09532d400 ("binfmt_elf: use ELF_ET_DYN_BASE only for PIE") > > > commit 02445990a96e ("arm64: move ELF_ET_DYN_BASE to 4GB / 4MB") > > > > > > The AddressSanitizer tool has hard-coded expectations about where > > > executable mappings are loaded. The motivation for changing the PIE > > > base in the above commits was to avoid the Stack-Clash CVEs that > > > allowed executable mappings to get too close to heap and stack. This > > > was mainly a problem on 32-bit, but the 64-bit bases were moved too, > > > in an effort to proactively protect those systems (proofs of concept > > > do exist that show 64-bit collisions, but other recent changes to fix > > > stack accounting and setuid behaviors will minimize the impact). > > > > I happened to be looking at this again today, and wondered where things > > stood. It seems like ASan's mappings are documented here: > > https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm#64-bit > > > > This implies that it would be safe to move the ELF_ET_DYN_BASE from > > 0x555555554000 down to 0x200000000000, since the shadow map ends at > > 0x10007fff7fff. (Well, anything above there would work, I was just > > picking a "round" number above it. We could just as well use > > 0x100080000000, I think.) > > > > Is this correct? I'd like to open up some more room between mmap and > > stack... Thanks for the details! > Note that there is also TSAN and MSAN with their own mappings. > These are also different per-arch, e.g. TSAN/Linux/x86_64: > https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L48-L58 > Search "linux/" in that file for other arches, e.g.: > https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L156-L165 > https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L187-L196 > https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L218-L227 > https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/tsan/rtl/tsan_platform.h#L252-L263 Depending on VA size, these are effectively all below 0x3800 0000 0000. > > And MSAN mappings: > https://github.com/llvm/llvm-project/blob/d2a26a7bd5fc7cc5752337b7f4f999642feb37dc/compiler-rt/lib/msan/msan.h#L44-L61 These are all below 0x1000 0000 0000. So there probably isn't much benefit in reducing the PIE program position below the current 0x55.... Okay, thanks! -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel