Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp671962pxu; Thu, 3 Dec 2020 09:45:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwU3I6UStpBPgYsTtYpfZK4eX7S8mAg0l/9o2uaM0hBwAAlu47Io/pTlfnVuihwLQY7OAlQ X-Received: by 2002:a50:f089:: with SMTP id v9mr3967125edl.353.1607017531817; Thu, 03 Dec 2020 09:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607017531; cv=none; d=google.com; s=arc-20160816; b=Sah2ppvki9aqSpyuj4q3D+QVFTR+Z5swfrRRhyFVNqsCQ5vcMhNodchX+9m+yJdgsi vmvQWPHvBv3NroI8McdV7ZQX3IU6eWa6/I5hfK8cct66iLh+mMvzhcI5f9DwxtN0IHsT ZVXxJT20nZFdiO4rjDYManEJetRJeIlu1InOhPdk+g2k0Jz22PF5cEJV2q6dY8AoPozF bgp89HeoaSd+U9WehI6C2N7LyADdezrPhJgVB0C40PBHFUOAZnZAZC96qoKR2yMDaaSX azJu6flm4K/9HaDw8JHud8D4z1Kb3A/alP7NGrLa9qkWh3Y+NKRuACoRgXzW9iozP/ch pu7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=ewjsiW9xOOWwJ7Vn/ikJbHYwHfnQIPjHGmHGP7oi6BE=; b=B68IottbjhlYvN7W4qt5a4B/VgC2NYB/1dFFKgHFv9eTd92wDv3JhQI4/z3I4y3KPU Rq44ypQLlWMnWYdpfvgXubPkcjLsg2vxJU2JMlbBcx9TRIP2ihpWv1AD+O3AsZLmsJ8W EpV9mwceDgz/+yvkEcugTi6/UG2GSyeHw5j41aed206KE+J+zR5GdVqCJb4fTkwOwZgc pJObUYMV/PbAIlcF4sxA7NHTodMpa7v0qkoXrHXkuJX9uOWXiW1yPRA+GOF9ALy1yZv7 tr+JotnoO/VuQimcqUgmpIQU7JN2LoNe6KY2xiYmvHZZ9obnbjds4BJVbZe+1rx89gpt mPmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="O5IvV2/V"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si1677760ejq.721.2020.12.03.09.45.07; Thu, 03 Dec 2020 09:45:31 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="O5IvV2/V"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729367AbgLCRnh (ORCPT + 99 others); Thu, 3 Dec 2020 12:43:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727835AbgLCRng (ORCPT ); Thu, 3 Dec 2020 12:43:36 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A68C3C061A52 for ; Thu, 3 Dec 2020 09:42:56 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id l11so1558448plt.1 for ; Thu, 03 Dec 2020 09:42:56 -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=pJhAKmNsRYdfO8BFWcBK+EpR9u9JlTlVLI7WcfO9n2PwyHFe1VWr3/gyykbvAxkI7e hPOA++74SMpuwin5F2GqLQel77LzklDqEUvu1M/RlEkGO07aXBQgn05iAqNl6s+bNOuG aWcN55lPfX8RUHXMgAjDeD4T/Ih5eNkzgqabn4JOeHO2zbO8zN9Ci8NUDFyMhf0lo9Q0 XP4dZpCgtvrz7tqa+rJG0NHGsZrKPeRSXQDri1Whmaxvq8U6fLue92HWpwdHpOi2k4ms ugWccOYtGPlMtw0724tc4x1yn4fZmgrsS0sPMCx4iQLpDofRqjBlYlYg+Ve74OHn/Aom R6Pg== X-Gm-Message-State: AOAM532GiQPApJgRqja1qRT7RqcEoFBgkSn8sKpDLzgXcdr1vT1nUut/ tb2569roWpV9cOPGVY9fW8syBNun3NOnbw== 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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.=