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 X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2D8AC63777 for ; Thu, 3 Dec 2020 09:48:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5FAD721527 for ; Thu, 3 Dec 2020 09:48:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FAD721527 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7BDB76B005D; Thu, 3 Dec 2020 04:48:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76E326B0068; Thu, 3 Dec 2020 04:48:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6830E6B006C; Thu, 3 Dec 2020 04:48:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id 539256B005D for ; Thu, 3 Dec 2020 04:48:00 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 118F9181AEF21 for ; Thu, 3 Dec 2020 09:48:00 +0000 (UTC) X-FDA: 77551494720.01.unit66_2003521273ba Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id E94C910045BF2 for ; Thu, 3 Dec 2020 09:47:59 +0000 (UTC) X-HE-Tag: unit66_2003521273ba X-Filterd-Recvd-Size: 4023 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Dec 2020 09:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606988878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IMWz2J6ee0z3Goxs//cxHMcur+NB7NXymG3FsD4KqVk=; b=fcjzlOtGdc9fRqOp1YliWTQGSLHGBiQhNP91z5F+2GEQDLAi9aFkGoSE5xtTM9gbA5w7RE M4rrWfrDnnYMaqVwkVjNscaUWa7iD/NV1dqqTPJrdemU8e9X+Qt6w8Fof/EViikaE1g9aM XssaiDB3qiLt3TAJupeQKhX4J/IlwVY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-427-KooIkbC-OxyfPReSet9BCw-1; Thu, 03 Dec 2020 04:47:56 -0500 X-MC-Unique: KooIkbC-OxyfPReSet9BCw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C7315708A; Thu, 3 Dec 2020 09:47:55 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07E505D75F; Thu, 3 Dec 2020 09:47:52 +0000 (UTC) From: Florian Weimer To: Topi Miettinen Cc: linux-hardening@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jann Horn , Kees Cook , Matthew Wilcox , Mike Rapoport , Linux API Subject: Re: [PATCH v5] mm: Optional full ASLR for mmap(), mremap(), vdso and stack References: <20201129211517.2208-1-toiwoton@gmail.com> Date: Thu, 03 Dec 2020 10:47:51 +0100 In-Reply-To: <20201129211517.2208-1-toiwoton@gmail.com> (Topi Miettinen's message of "Sun, 29 Nov 2020 23:15:17 +0200") Message-ID: <87im9j2pbs.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: * Topi Miettinen: > +3 Additionally enable full randomization of memory mappings created > + with mmap(NULL, ...). With 2, the base of the VMA used for such > + mappings is random, but the mappings are created in predictable > + places within the VMA and in sequential order. With 3, new VMAs > + are created to fully randomize the mappings. > + > + Also mremap(..., MREMAP_MAYMOVE) will move the mappings even if > + not necessary and the location of stack and vdso are also > + randomized. > + > + On 32 bit systems this may cause problems due to increased VM > + fragmentation if the address space gets crowded. Isn't this a bit of an understatement? I think you'll have to restrict this randomization to a subregion of the entire address space, otherwise the reduction in maximum mapping size due to fragmentation will be a problem on 64-bit architectures as well (which generally do not support the full 64 bits for user-space addresses). > + On all systems, it will reduce performance and increase memory > + usage due to less efficient use of page tables and inability to > + merge adjacent VMAs with compatible attributes. In the worst case, > + additional page table entries of up to 4 pages are created for > + each mapping, so with small mappings there's considerable penalty. The number 4 is architecture-specific, right? Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill