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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 D2ED1C433FE for ; Thu, 3 Dec 2020 17:42:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5701E206F0 for ; Thu, 3 Dec 2020 17:42:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5701E206F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5B5818D0006; Thu, 3 Dec 2020 12:42:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 541168D0005; Thu, 3 Dec 2020 12:42:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BA358D0006; Thu, 3 Dec 2020 12:42:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 1CE418D0005 for ; Thu, 3 Dec 2020 12:42:58 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D61B7181AEF23 for ; Thu, 3 Dec 2020 17:42:57 +0000 (UTC) X-FDA: 77552691594.21.coil64_0a0c68d273bd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id ACAEB180442C3 for ; Thu, 3 Dec 2020 17:42:57 +0000 (UTC) X-HE-Tag: coil64_0a0c68d273bd X-Filterd-Recvd-Size: 4645 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Dec 2020 17:42:57 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id v3so1526878plz.13 for ; Thu, 03 Dec 2020 09:42:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=ewjsiW9xOOWwJ7Vn/ikJbHYwHfnQIPjHGmHGP7oi6BE=; b=O5IvV2/Vubx9BfUcRWT56D/4/JIWhi2M8/1ywP+fGkSzRHslO0wfwe5e4AJ20Fh8o2 ZA2L7P1NHqA9iifsGKNv9sCbPp1F8AstH9lDyxvpAR1A5yyA8wnjVphnmkjfrkCLGoss gaU7CyuMjRpNB6n727nzPwwvdMJ/8ysb9w4X2H7kY+mjl4D3NcDTQ1FgQY2xRKkTYUle KIHSm8/RIpmAJTPsNZE2wXzuzgpkgowncocmXUFidgDul2mI5+Mj9Z2g1fXa2FjAGyPH kSfsJh5orSF+cvzkyIuSWOLcYWAkPpUEdJCWwP6mAqgeTwXUzrjumKm0iCHDkePCxP/U AtVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=ewjsiW9xOOWwJ7Vn/ikJbHYwHfnQIPjHGmHGP7oi6BE=; b=oRDB2XNjg5KeviJiQDPQTqXASX86NA/wuAF+L6soxUrbY3sRzqxkvJb+FzHCmJsRiv Z2fM+F/FrsIymOjyQapJJcbuFqwyoTZbZ+ad/ax0X7LFACG2Eq0JkULy8yUlJ/2Zb2HX /TiAKbP2GOBJUoVdi6zxF9NiWSzliul0P9vwgcD9jl/HPZsvpNPzzb8RAV8wy8nVRtda +znJGr1/+4zO3eBu8bh1YugSEI1I5HC+lWfIY61p25soRzvHNCKjJ3JyD4zrcAp1v/LN GTEbAkf9Pf02rKdTe8zOy40TBtSlHymGKa5ptRa2usQ2V+XSaMzEL4jD3AVUDmn+Ymk+ 3GGg== X-Gm-Message-State: AOAM531UjPtFMjAYXapPG8B++Hx/GPs6apNJnyN86C+K/jEoo+JHX1Q2 Otz/vFnngJWJZ6PT5t4aKWx6ew== X-Google-Smtp-Source: ABdhPJzTpCbbRfGOWHG7m+mZZhYM+XYEslxM55n+IwQtflCINDXZDUjStV6j4JnVJwJcZsivKclnxQ== X-Received: by 2002:a17:90b:50e:: with SMTP id r14mr237250pjz.90.1607017376213; Thu, 03 Dec 2020 09:42:56 -0800 (PST) Received: from ?IPv6:2601:646:c200:1ef2:8949:f4fe:cc16:86da? ([2601:646:c200:1ef2:8949:f4fe:cc16:86da]) by smtp.gmail.com with ESMTPSA id j11sm1655038pgp.82.2020.12.03.09.42.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2020 09:42:55 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v5] mm: Optional full ASLR for mmap(), mremap(), vdso and stack Date: Thu, 3 Dec 2020 09:42:54 -0800 Message-Id: <1CB9B4D1-1E32-42DC-A4E9-6E53C85365BF@amacapital.net> References: <871rg6yf1i.fsf@oldenburg2.str.redhat.com> Cc: Topi Miettinen , 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 In-Reply-To: <871rg6yf1i.fsf@oldenburg2.str.redhat.com> To: Florian Weimer X-Mailer: iPhone Mail (18B121) 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: > On Dec 3, 2020, at 9:29 AM, Florian Weimer wrote: >=20 > =EF=BB=BF* Andy Lutomirski: >=20 >> If you want a 4GB allocation to succeed, you can only divide the >> address space into 32k fragments. Or, a little more precisely, if you >> want a randomly selected 4GB region to be empty, any other allocation >> has a 1/32k chance of being in the way. (Rough numbers =E2=80=94 I=E2=80= =99m ignoring >> effects of the beginning and end of the address space, and I=E2=80=99m >> ignoring the size of a potential conflicting allocation.). >=20 > I think the probability distribution is way more advantageous than that > because it is unlikely that 32K allocations are all exactly spaced 4 GB > apart. (And with 32K allocations, you are close to the VMA limit anyway.)= I=E2=80=99m assuming the naive algorithm of choosing an address and trying i= t. Actually looking for a big enough gap would be more reliable. I suspect that something much more clever could be done in which the heap is= divided up into a few independently randomized sections and heap pages are r= andomized within the sections might do much better. There should certainly b= e a lot of room for something between what we have now and a fully randomize= d scheme. It might also be worth looking at what other OSes do.=