Received: by 10.213.65.68 with SMTP id h4csp736822imn; Wed, 28 Mar 2018 11:48:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ECtc2sF7L6jVfLJuDqXTqGAYgoOG6LgN5RUcBwZPMuTXB8p7IgWYohWy9vWiGVnKOA9iG X-Received: by 10.101.70.132 with SMTP id h4mr3285428pgr.155.1522262928480; Wed, 28 Mar 2018 11:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522262928; cv=none; d=google.com; s=arc-20160816; b=B75y9KxFYwuH2V4KcTVmCKNzhd5GAophzv33C0U2g9vKuY60zcdrBQTDkOpr6Lqb4Y p3OfHuaG+QNp4sbD+SuXGytAJz1qy2Qpx5A+lowWepQomS/r4ReE20ygqKSWGldP+BFW IOa+iFnz3cCvnKynTJik4tn/M6Ie2/VphkIdFqORaplHe5OxDvPQzrxRKmtaaY4Np88e RMEZAL+XuBUmopxJQy01bhUHp/3iovTp9ZVJo8FQwHyq8eARNLBn3jHGZB1LZUgHoZPg T23gSqp+yeFsNB6/P4P7ZDs0YZlfJe0kpWxYaKVcQxK4z39/qB/HgIwJtkyAFomVd+Ti tI1A== 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=egK4Hy+FSMVRapLItJLtWI4tYDufyZsulm/WqkNWwpk=; b=lAZBcOTwKjfGMb0tMzOHF6esLTp6MG23dDU6lxVCN+R+9/0X/MbRG4L0/cjt8QhI8J VoWVT9WhgosmTZH13+nro5ksyU8VPMNuHD+1/QCSME6nzx8DTq07zZHqtFE+JwpzE8Yn QtOAIl8xdJSI1Z1A0rj6iZp2gakosgrn+LEbWdccQRdhS8hID4AREMyM4+1YRdCMx0t3 wWBAPD9KteNGc4eUHiPtj31hVuy4o5iEuzoSh+BXp2ePN8z/aNhXX4X4swAW/EWnew+1 nbW4hfmjRz/4jGy559e5ycwjwZvty/2ASTZSYJvx/8xuaWKgnInYAsVXdnmG8EqfjFUa Ds4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rho/w/Gd; 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 u8-v6si4022494plm.407.2018.03.28.11.48.33; Wed, 28 Mar 2018 11:48:48 -0700 (PDT) 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=rho/w/Gd; 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 S1753243AbeC1Sr2 (ORCPT + 99 others); Wed, 28 Mar 2018 14:47:28 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:36795 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434AbeC1SrW (ORCPT ); Wed, 28 Mar 2018 14:47:22 -0400 Received: by mail-lf0-f67.google.com with SMTP id z143-v6so4947947lff.3; Wed, 28 Mar 2018 11:47:20 -0700 (PDT) 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=egK4Hy+FSMVRapLItJLtWI4tYDufyZsulm/WqkNWwpk=; b=rho/w/GdqJxAuE5Zb9qX5hYgtEFMkl+4bKPLAesLv2h23Ls1RLt2o7h9vigxREBmwW oJc7zB8l7tTWE6vnFnZ8UOaCDrPTjbNu0wNyvPwnIr/izGzSQFKnQ/ckivvAckB3neM/ wIaE4MNMjW8NN7Nn78+B6nial1Me7lo+tjQ/cRNntsYuZCe96d14RdObNEQYOkNV9ico cLJNsqGKNH/fgq6/ECk8h6q5oxnM3KJKWpIpLI27yQ978Q6hcrQdC1pnmBQprMfZfIWL Tsq/fhuvpSPik66hB7ybw8drTgKHhl3sfCUmh3OESwX8ZD15e6cKCwWXZL0q1JsfS9/k Kp6w== 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=egK4Hy+FSMVRapLItJLtWI4tYDufyZsulm/WqkNWwpk=; b=S75rpMNMUsoU6TlZbmX7sPK10JKUE8pxYPMSrGN9Y9Iximy0jAJOyBKCcGKJdlxM26 9QpV2FStg2nLx8bMcAnODjhbLuO9A9QMsdhRFgmmgBK7GsrwGUTxu9x/ev/BC7duXx/Q IBsq3BF50OThopl1EVNr+BXvidoQsZzzVX+YES8mgySLllRPTi2yKZwk6suCOov3J+Ut BCp2Fxaewq16RyEGWkhXUvZ8xU4GuX9vL6BZuvYMqOraZhO73ahJ8LihYM+BLE4arFPu ViiBX5KYNO05e6fpiyZ1AZUJWtQY/kkaH0GeykOAb2d5RdhfwdHU4eTD2V3kqbz0Bf2A fB6g== X-Gm-Message-State: AElRT7HkQVia1TI/efkv8DX7erZHCnT7xp2PiVaUi1jwSNN7pLl68aLC 5kUYOx70Zu/sJ7maO1qXAMY= X-Received: by 10.46.151.213 with SMTP id m21mr3169611ljj.31.1522262839209; Wed, 28 Mar 2018 11:47:19 -0700 (PDT) Received: from [192.168.1.3] (broadband-188-255-70-164.moscow.rt.ru. [188.255.70.164]) by smtp.gmail.com with ESMTPSA id x22sm715106ljj.74.2018.03.28.11.47.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 11:47:17 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: [RFC PATCH v2 0/2] Randomization of address chosen by mmap. From: Ilya Smith In-Reply-To: <20180327143820.GH5652@dhcp22.suse.cz> Date: Wed, 28 Mar 2018 21:47:15 +0300 Cc: Matthew Wilcox , rth@twiddle.net, ink@jurassic.park.msu.ru, mattst88@gmail.com, vgupta@synopsys.com, linux@armlinux.org.uk, tony.luck@intel.com, fenghua.yu@intel.com, ralf@linux-mips.org, jejb@parisc-linux.org, Helge Deller , benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, ysato@users.sourceforge.jp, dalias@libc.org, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, nyc@holomorphy.com, viro@zeniv.linux.org.uk, arnd@arndb.de, gregkh@linuxfoundation.org, deepa.kernel@gmail.com, Hugh Dickins , kstewart@linuxfoundation.org, pombredanne@nexb.com, Andrew Morton , steve.capper@arm.com, punit.agrawal@arm.com, aneesh.kumar@linux.vnet.ibm.com, npiggin@gmail.com, Kees Cook , bhsharma@redhat.com, riel@redhat.com, nitin.m.gupta@oracle.com, "Kirill A. Shutemov" , Dan Williams , Jan Kara , ross.zwisler@linux.intel.com, Jerome Glisse , Andrea Arcangeli , Oleg Nesterov , linux-alpha@vger.kernel.org, LKML , linux-snps-arc@lists.infradead.org, linux-ia64@vger.kernel.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, Linux-MM Content-Transfer-Encoding: quoted-printable Message-Id: References: <1521736598-12812-1-git-send-email-blackzert@gmail.com> <20180323124806.GA5624@bombadil.infradead.org> <651E0DB6-4507-4DA1-AD46-9C26ED9792A8@gmail.com> <20180326084650.GC5652@dhcp22.suse.cz> <01A133F4-27DF-4AE2-80D6-B0368BF758CD@gmail.com> <20180327072432.GY5652@dhcp22.suse.cz> <0549F29C-12FC-4401-9E85-A430BC11DA78@gmail.com> <20180327143820.GH5652@dhcp22.suse.cz> To: Michal Hocko 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 27 Mar 2018, at 17:38, Michal Hocko wrote: >=20 > On Tue 27-03-18 16:51:08, Ilya Smith wrote: >>=20 >>> On 27 Mar 2018, at 10:24, Michal Hocko wrote: >>>=20 >>> On Mon 26-03-18 22:45:31, Ilya Smith wrote: >>>>=20 >>>>> On 26 Mar 2018, at 11:46, Michal Hocko wrote: >>>>>=20 >>>>> On Fri 23-03-18 20:55:49, Ilya Smith wrote: >>>>>>=20 >>>>>>> On 23 Mar 2018, at 15:48, Matthew Wilcox = wrote: >>>>>>>=20 >>>>>>> On Thu, Mar 22, 2018 at 07:36:36PM +0300, Ilya Smith wrote: >>>>>>>> Current implementation doesn't randomize address returned by = mmap. >>>>>>>> All the entropy ends with choosing mmap_base_addr at the = process >>>>>>>> creation. After that mmap build very predictable layout of = address >>>>>>>> space. It allows to bypass ASLR in many cases. This patch make >>>>>>>> randomization of address on any mmap call. >>>>>>>=20 >>>>>>> Why should this be done in the kernel rather than libc? libc is = perfectly >>>>>>> capable of specifying random numbers in the first argument of = mmap. >>>>>> Well, there is following reasons: >>>>>> 1. It should be done in any libc implementation, what is not = possible IMO; >>>>>=20 >>>>> Is this really so helpful? >>>>=20 >>>> Yes, ASLR is one of very important mitigation techniques which are = really used=20 >>>> to protect applications. If there is no ASLR, it is very easy to = exploit=20 >>>> vulnerable application and compromise the system. We can=E2=80=99t = just fix all the=20 >>>> vulnerabilities right now, thats why we have mitigations - = techniques which are=20 >>>> makes exploitation more hard or impossible in some cases. >>>>=20 >>>> Thats why it is helpful. >>>=20 >>> I am not questioning ASLR in general. I am asking whether we really = need >>> per mmap ASLR in general. I can imagine that some environments want = to >>> pay the additional price and other side effects, but considering = this >>> can be achieved by libc, why to add more code to the kernel? >>=20 >> I believe this is the only one right place for it. Adding these 200+ = lines of=20 >> code we give this feature for any user - on desktop, on server, on = IoT device,=20 >> on SCADA, etc. But if only glibc will implement =E2=80=98user-mode-aslr= =E2=80=99 IoT and SCADA=20 >> devices will never get it. >=20 > I guess it would really help if you could be more specific about the > class of security issues this would help to mitigate. My first > understanding was that we we need some randomization between program > executable segments to reduce the attack space when a single address > leaks and you know the segments layout (ordering). But why do we need > _all_ mmaps to be randomized. Because that complicates the > implementation consirably for different reasons you have mentioned > earlier. >=20 There are following reasons: 1) To protect layout if one region was leaked (as you said).=20 2) To protect against exploitation of Out-of-bounds vulnerabilities in = some=20 cases (CWE-125 , CWE-787) 3) To protect against exploitation of Buffer Overflows in some cases = (CWE-120) 4) To protect application in cases when attacker need to guess the = address=20 (paper ASLR-NG by Hector Marco-Gisbert and Ismael Ripoll-Ripoll) And may be more cases. > Do you have any specific CVE that would be mitigated by this > randomization approach? > I am sorry, I am not a security expert to see all the cosequences but = a > vague - the more randomization the better - sounds rather weak to me. It is hard to name concrete CVE number, sorry. Mitigations are made to = prevent=20 exploitation but not to fix vulnerabilities. It means good mitigation = will make=20 vulnerable application crash but not been compromised in most cases. = This means=20 the better randomization, the less successful exploitation rate. Thanks, Ilya