Received: by 10.223.185.116 with SMTP id b49csp2631473wrg; Mon, 5 Mar 2018 06:18:46 -0800 (PST) X-Google-Smtp-Source: AG47ELtjOO53eeF3fq2FWB8mylWPzZdPwWQgtat/3bjx4CX68fk2R5m0TFVW8pAk2mSsmRq7aLCL X-Received: by 10.99.147.11 with SMTP id b11mr209698pge.379.1520259526553; Mon, 05 Mar 2018 06:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520259526; cv=none; d=google.com; s=arc-20160816; b=aLNJ2JkPmvVjNbeDne/IU7UNls8TbVUBPjHSritDF8zR/P16tuhBlh1IuLuwQMcMs8 TmTeheC6wYKVd/FxC7FRRTRkbYRKWvqccOF/mQy7+FVVSrEjY7ExdHIZboNN9znwpmwT ig0ENOjzRy1GqCMPpCOR/Q6oaZSctyxVGY5UNOKLZ8kyBq4lAi3em/vivYo1H/bH2dGo RKGnQblzbcIv7PQUlXXiiLFmSaUOq+FKphM7ehRfPSw4fxHR02BDHiIf6QjFvoTR/ixt D+ollpBYO9a6uprfwWUyOYgibLL9BadARIEeAVKhyMaGs8zOak0geWSU0qju5rOD3wqF yWLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=/yfKakyszuF+TfANNAVGz1ibNZJ2iYTesgxA6QSGURw=; b=Rw8RwpaGXRmEHBg4j+9JFLCnGXx3mZopYq6XG/QzfZ67g4hLyN83N3RUMkwYfJTGQD rapJrYLMx+VC3e0D9KM4PwQpDI0ynlAa9sGuOSVnwmjhE6sYenJpdXem42hiaZgAn4K3 RPdoXadbaq2w4GVaKvKHIGc7aCuz1iQdW1l8gBfiyoM8veJ+eEa1F9uGb/oAnA2gqKqV b88RO32gS2OZX3VK8iN5GyfZVbtOf5diAtKkUeZrq/hsl+oJK+SgOkpVTVzUpavkU4Oj QNB7TqeOvEFOVmmb8lwq/Oa+cHKBMtxmw7+2aEzmi5iHz/dgizL0puHXaL5CwlWOl0SC nbbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R69I3bP/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si5316606plz.763.2018.03.05.06.18.32; Mon, 05 Mar 2018 06:18:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R69I3bP/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934985AbeCENJw (ORCPT + 99 others); Mon, 5 Mar 2018 08:09:52 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34076 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964852AbeCENJf (ORCPT ); Mon, 5 Mar 2018 08:09:35 -0500 Received: by mail-lf0-f66.google.com with SMTP id l191so22971109lfe.1 for ; Mon, 05 Mar 2018 05:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=/yfKakyszuF+TfANNAVGz1ibNZJ2iYTesgxA6QSGURw=; b=R69I3bP/l6Up8qK3/fOXBISnkoCOFZPDoLDajrRs+j91vkEpRQt79heSrBchOBtwnQ Il6Cby/E700aRmf+gsPK/f0YIMtJe0ILrUxlULJ3cYVxu2StRIGWoQNgp7DpJSooocTw sGB7phLh6tK19jg2ijDGkN82tHBK2XNMbkR5lJrEux+wli34i/+Rx1+LCPafvwqb1KwV q9M+LspLPNL6sfz2ddVlFwplszTpnF/RcFZWxinhwTAnayReCaIq6aQmRUKPEb68Vgnc hC4arQV3QDQjM+GX/GZRPQ6+/lfhPKCMrm/k08BbeOxfDcK8rM5RrlIpsTvs+0JBMsAP cU0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=/yfKakyszuF+TfANNAVGz1ibNZJ2iYTesgxA6QSGURw=; b=iBmBhCWBPC2tlWLIt1kBIMjhoUno/Xz2g4msik8eW5vEKa2xEfoQm659G6H4wy5fZl 8/C4pPGDUZmb9zAPWQY7XjzhpgLmFWswDfc3ub8KD5Rg3Mxe5/goSYyAFT4XFyOyOmkN dOWNZZyFFEyHwPc+05Hhl/4JeHa5DHqP9i01jh3+xDM3bKpa4q/CtJyqnP2zrNnGbv76 M4n5gRzDVPAHmxLDAkOgBN4LKKKosU1+LB8I0cUofhjZJ1TDkW+aW0Nf5z4I3zExiILJ k3G3c00+Ru8hQ1t9TP3iArgnECBm0zXtLRdVFbWVH7ZXYiX0ub1GhWmJDRbFYdGPOIVo 6jAQ== X-Gm-Message-State: AElRT7H1ikndIamrlVbmfFcBMgwLirA0qxEKIc/0cJQ6w89atDDqKPYh lIY14nGc6NyGO7CTZjRXWY4= X-Received: by 10.25.145.19 with SMTP id t19mr10183844lfd.91.1520255374233; Mon, 05 Mar 2018 05:09:34 -0800 (PST) Received: from [10.0.36.141] ([31.44.93.2]) by smtp.gmail.com with ESMTPSA id x13sm2692122ljd.6.2018.03.05.05.09.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 05:09:32 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: [RFC PATCH] Randomization of address chosen by mmap. From: Ilya Smith In-Reply-To: <20180304205614.GC23816@bombadil.infradead.org> Date: Mon, 5 Mar 2018 16:09:31 +0300 Cc: Daniel Micay , Kees Cook , Andrew Morton , Dan Williams , Michal Hocko , "Kirill A. Shutemov" , Jan Kara , Jerome Glisse , Hugh Dickins , Helge Deller , Andrea Arcangeli , Oleg Nesterov , Linux-MM , LKML , Kernel Hardening Content-Transfer-Encoding: quoted-printable Message-Id: <7FA6631B-951F-42F4-A7BF-8E5BB734D709@gmail.com> References: <20180227131338.3699-1-blackzert@gmail.com> <55C92196-5398-4C19-B7A7-6C122CD78F32@gmail.com> <20180228183349.GA16336@bombadil.infradead.org> <2CF957C6-53F2-4B00-920F-245BEF3CA1F6@gmail.com> <20180304034704.GB20725@bombadil.infradead.org> <20180304205614.GC23816@bombadil.infradead.org> To: Matthew Wilcox X-Mailer: Apple Mail (2.3445.5.20) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 4 Mar 2018, at 23:56, Matthew Wilcox wrote: > Thinking about this more ... >=20 > - When you call munmap, if you pass in the same (addr, length) that = were > used for mmap, then it should unmap the guard pages as well (that > wasn't part of the patch, so it would have to be added) > - If 'addr' is higher than the mapped address, and length at least > reaches the end of the mapping, then I would expect the guard pages = to > "move down" and be after the end of the newly-shortened mapping. > - If 'addr' is higher than the mapped address, and the length doesn't > reach the end of the old mapping, we split the old mapping into two. > I would expect the guard pages to apply to both mappings, insofar as > they'll fit. For an example, suppose we have a five-page mapping = with > two guard pages (MMMMMGG), and then we unmap the fourth page. Now = we > have a three-page mapping with one guard page followed immediately > by a one-page mapping with two guard pages (MMMGMGG). I=E2=80=99m analysing that approach and see much more problems: - each time you call mmap like this, you still increase count of vmas = as my=20 patch did - now feature vma_merge shouldn=E2=80=99t work at all, until MAP_FIXED = is set or PROT_GUARD(0) - the entropy you provide is like 16 bit, that is really not so hard to = brute - in your patch you don=E2=80=99t use vm_guard at address searching, I = see many roots=20 of bugs here - if you unmap/remap one page inside region, field vma_guard will show = head=20 or tail pages for vma, not both; kernel don=E2=80=99t know how to handle = it - user mode now choose entropy with PROT_GUARD macro, where did he gets = it?=20 User mode shouldn=E2=80=99t be responsible for entropy at all I can=E2=80=99t understand what direction this conversation is going to. = I was talking=20 about weak implementation in Linux kernel but got many comments about = ASLR=20 should be implemented in user mode what is really weird to me. I think it is possible to add GUARD pages into my implementations, but = initially=20 problem was about entropy of address choosing. I would like to resolve = it step by step. Thanks, Ilya=