Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp354069pxu; Thu, 3 Dec 2020 01:51:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBYeOIlDIdShQ41bMYBQssKduaqM6SsRu9guPMwMnvY8fGf/P1HUN80FJ0slOUkkm0OePt X-Received: by 2002:a17:906:40c1:: with SMTP id a1mr1741144ejk.520.1606989099765; Thu, 03 Dec 2020 01:51:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606989099; cv=none; d=google.com; s=arc-20160816; b=RGm31WBjwFcjOaWkqF3JApIQJ+DeFKZIj8aS9ga1AOCM58FK09HjTOQBwYcwcwrc6K /iAwrdi3i3PyqNevEr3DocHixoX2Swq4qDBLGv4yYOk8ywN3Nb9npvTjokY04UwEG1tR P+dgHimv36MU0SZvsbqqi8wQKW1DL5O+jo2ZiXWETyE/JZdQWMglZCWg5PBSBQHmmFCU WwoA4zjyEbPjHIIZZ6wrzu1P0OCFx/r/Av1gU9vBVK6LwfzQ3NxQWSEl/YMt0FwNCg46 E/SAX4scwZY6qSb4tscgyx3CHVtT22KLWKkwXs6MT0WCvCD8oKulbxqOwE4z/1HjPYo9 DKSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=IMWz2J6ee0z3Goxs//cxHMcur+NB7NXymG3FsD4KqVk=; b=Ior6I5BM7r8OxD916davgzDVmUe4Vn+byl8gDaNBLZI+u2u91r8SD/rXYj7oOSQueU d8HiAvKtcFllNgu86CKVQzb8vQv5PimOErhiUf2JnSs1y3KDIuHIe4ak/2j4i3fxguIH PDGn+kKAtOLbfWbZDuLgRIeSB0jasuoWXLrSdWo1/D1i4DBZ/TsG+YC2br4gj+hWXQ5j 5s5BlluHAx4E2P+AUdDT56Vus6ehOu6nhLPXPwfJXnsjh5A9s8f/yznzbuWFU4mXh5QY Gd6hwefR/TsPbhlR2DRn2HkiZSiWBzGuuR1QnFfajh9hE4S49yk2+ipRzfqWutBi/nG4 aTsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SFn3gr20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si760396eja.497.2020.12.03.01.51.16; Thu, 03 Dec 2020 01:51:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SFn3gr20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730185AbgLCJt1 (ORCPT + 99 others); Thu, 3 Dec 2020 04:49:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54703 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730180AbgLCJt0 (ORCPT ); Thu, 3 Dec 2020 04:49:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606988880; 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=SFn3gr204Ehl5xY6H0alRjOYuRZgSJihU6EkjbhSdxRVaHKTBd165rU1RSlJzoseUpppc7 HkRLvS7HOWyPHEgm0RTkZf5zIm+duL1+45sEBof4GUdDK++uODisI8auUmQ28/Gvb1woAT XLHf1UiG4qMDi8rxuPvKUuvZ3OKDcQk= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * 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