Received: by 10.223.176.5 with SMTP id f5csp544785wra; Fri, 9 Feb 2018 03:19:41 -0800 (PST) X-Google-Smtp-Source: AH8x224NdaLwplPkQBAXXqx7xjwFSISXtKej4pEt3YRieK83Tn2aKN2tdl0mrPpyd8d3ZZDa45uS X-Received: by 10.99.132.74 with SMTP id k71mr2126993pgd.4.1518175181778; Fri, 09 Feb 2018 03:19:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518175181; cv=none; d=google.com; s=arc-20160816; b=UKQHKL4h3SeuCfm1x/uAnWK15WbEEn/0+CinyliiRWz0oEFKxbHKfnx6V0tUSm+CIc duKm9adZS8t5rK90iIjmq1Q5YguPOSTIVaNv3JO30uvFYmzKzYDU1M0wj6lPgxhujuhL Yjk5D2ZHBeQGOPFTuLqWKQH54jmTW4Ev+ZmJRRnRP9paqo7gz674JE+POlpHJyRhQuk5 /G/PXXO7meA9rBJhoGIUxqpQ3AaYJ+eJ01dgDH5qhHrojorImg3HX4RlDMzofiWjUTVK 0R1mB7lQOEpaikE838MBN+VaVyuMPQ/qprhUs25ky5SQ6Jx4U0ddI/lztzdm7lfA0ry+ H9Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=PtKCdjezdS7D1o/3dQdqe06HUK6rSSKXb18otnQFOlM=; b=ROhqwluFH9w4ZbrqfXfRo+zF6mhInXuuF7rpdUDyiVGZ2VvNKFhUCZa2fxEETxORAv QxY+1o/VcgIXE1s8PVu1JOPenlGMYW2ydu8x5IMVCc31FF4xwDnPuhIwXj8lsg6wnji3 AkFVXsxfzUDIqLCrUzDcGj9ZaZO/L/SRT3dJ+1a/g0Ubsj+ZTPT+jsoqFjYn7IpEDmNT M0f7q1F+HdFyq4SvCF8Se4lCBZXLxV8DELMEHaXg66VCII+d+sTvto4A4kpOO7ftD74C 5ZsfQ+mZeLs06vYfX6obSn6cA0oEaGB5ImnS7S/jo+b1tbaNhcmvxNG86dgTkzycoXY8 mYfA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11si1248994pgo.794.2018.02.09.03.19.27; Fri, 09 Feb 2018 03:19:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751201AbeBILSJ (ORCPT + 99 others); Fri, 9 Feb 2018 06:18:09 -0500 Received: from lhrrgout.huawei.com ([194.213.3.17]:26008 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751087AbeBILSG (ORCPT ); Fri, 9 Feb 2018 06:18:06 -0500 Received: from LHREML714-CAH.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id A950F318C600E; Fri, 9 Feb 2018 11:18:02 +0000 (GMT) Received: from [10.122.225.51] (10.122.225.51) by smtpsuk.huawei.com (10.201.108.37) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 9 Feb 2018 11:18:01 +0000 Subject: Re: [kernel-hardening] [PATCH 4/6] Protectable Memory To: Christopher Lameter CC: Matthew Wilcox , Boris Lukashev , Jann Horn , , Kees Cook , Michal Hocko , Laura Abbott , Christoph Hellwig , , , kernel list , "Kernel Hardening" References: <20180124175631.22925-1-igor.stoppa@huawei.com> <20180124175631.22925-5-igor.stoppa@huawei.com> <20180126053542.GA30189@bombadil.infradead.org> From: Igor Stoppa Message-ID: <4e113814-7d24-b48c-993f-46d5aee1755d@huawei.com> Date: Fri, 9 Feb 2018 13:17:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.122.225.51] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/02/18 17:40, Christopher Lameter wrote: > On Sat, 3 Feb 2018, Igor Stoppa wrote: > >>> We could even do this in a more thorough way. Can we use a ring 1 / 2 >>> distinction to create a hardened OS core that policies the rest of >>> the ever expanding kernel with all its modules and this and that feature? >> >> What would be the differentiating criteria? Furthermore, what are the >> chances >> of invalidating the entire concept, because there is already an >> hypervisor using >> the higher level features? >> That is what you are proposing, if I understand correctly. > > Were there not 4 rings as well as methods by the processor vendors to > virtualize them as well? I think you are talking x86, mostly. On ARM there are ELx and they are often (typically?) already used. For x86 I cannot comment. >>> I think that will long term be a better approach and allow more than the >>> current hardening approaches can get you. It seems that we are willing to >>> tolerate significant performance regressions now. So lets use the >>> protection mechanisms that the hardware offers. >> >> I would rather *not* propose significant performance regression :-P > > But we already have implemented significant kernel hardening which causes > performance regressions. Using hardware capabilities allows the processor > vendor to further optimize these mechanisms whereas the software > preventative measures are eating up more and more performance as the pile > them on. Plus these are methods that can be worked around. Restrictions > implemented in a higher ring can be enforced and are much better than > just "hardening" (which is making life difficult for the hackers and > throwing away performannce for the average user). What you are proposing requires major restructuring of the memory management - at the very least - provided that it doesn't cause the conflicts I mentioned above. Even after you do that, the system will still be working with memory pages, there will be still a need to segregate data within certain pages, or pay the penalty of handling exceptions, when data with different permissions coexist within the same page. The way the pmalloc API is designed is meant to facilitate the segregation and to actually improve performance, by grouping types of data with same scope and permission. WRT the implementation, there is a minimal exposure to the memory provider, both for allocation and release. Same goes for the protection mechanism. It's a single call to the function which makes pages read only. It would be trivial to swap it out with a call to whatever framework you want to come up with, for implementing ring/EL based protection. From this perspective, you can easily provide patches that implement what you are proposing, against pmalloc, if you really think that it's the way to go. I'll be happy to use them, if they provide improved performance and same or better protection. The way I designed pmalloc was really to be able to switch to some alternate memory provider and/or protection mechanism, should a better one arise. But it can be done in a separate step, I think, since you are not proposing to just change pmalloc, you are proposing to re-design how the overall kernel memory hardening works (including executable pages, const data, __ro_after_init, etc.) -- igor