Received: by 10.223.185.116 with SMTP id b49csp3816230wrg; Tue, 13 Feb 2018 08:11:11 -0800 (PST) X-Google-Smtp-Source: AH8x22498OsB1QfqlHaHA901qZCmZHZd+WiLYUE/HdgOd8/q024sKzYlJR8q0IXm4dqipjNw7AoI X-Received: by 10.99.125.25 with SMTP id y25mr1385908pgc.227.1518538270898; Tue, 13 Feb 2018 08:11:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518538270; cv=none; d=google.com; s=arc-20160816; b=m4nmldD9zpji0+jEt9shixkkeQ+SPBVjSMNgU8aOR57A8zSpu99Ua5KILakMWH5Pib zRAdeCs7YQTU7dKs2syBlZSKRsWmBWCZOvBHiAjzMv+rjtZyfeUDyIdOWr5uzXHt+Y1K VLaNCw/QOaZ/4kRy7AuUubVTI9daNVmeFhCtobUwNrLmqZoKB3F+jkEJ4ZYax+YutXs1 4BIuUi36XrdkPSJbR6wW0/ytMxhv7ysITS+IfgQE1CGzY0QifgFag6S9lWBlx0JcZb/A jy9owfl7N1k/A5FriLE3UwruMpUKHTtAFwXNKm8CHuEM1eSWvI4AtZqlQt/hw1JI9fke a3cQ== 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=zWmmnH/pXWbb+Ryii0d2IoQHFjuBmnfzEpsHL90b0Y0=; b=MJJ2hwMSoHZfABD7E/PI9iOOnz9qIsfQLN9dlodmBEDgPKlxA0IAYqtMgArrNVFAyg AdIJdcFY6ixw8YxKXCYEe2izDN5ea+4jgjL/3/5A05iq8WjosevJIljehGVwyl7Uc3F5 0bsInp+OugrsY0f8G47+IO/9/LuaVeiAZwO0/4q0CDg2Z/hvvQniTTTgsYiIAysQvijj sWv44JMnqwhdvAbvUxRaZc0ff1EHr4wk3yLUZskKpqdd/Zg/vZSDMH2egFcp1cWItK4c QN+lrx7qPPkRBApPOwzCJ1YNFbu9Qyjw3+l05720Rc0F/wrcY2y1sAqYFCprVurNJYA5 Iq2A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z67si569736pfb.223.2018.02.13.08.10.55; Tue, 13 Feb 2018 08:11:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934512AbeBMQJl (ORCPT + 99 others); Tue, 13 Feb 2018 11:09:41 -0500 Received: from mail-oi0-f44.google.com ([209.85.218.44]:34677 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933764AbeBMQJj (ORCPT ); Tue, 13 Feb 2018 11:09:39 -0500 Received: by mail-oi0-f44.google.com with SMTP id k15so14252301oib.1 for ; Tue, 13 Feb 2018 08:09:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zWmmnH/pXWbb+Ryii0d2IoQHFjuBmnfzEpsHL90b0Y0=; b=BvHCkj5iRvfyxJKS2TsnUA9hpX4Fe54bGXOMzaBLy3XR+p6LP7g+MVKRGymMQF7tmG EJA677umksnbduCU32ozT6OPJXnT0P6GrUsvEh5P/m16jSB5seldQ7eUHkA+V+RsY973 aPehLPN8PldbTiv+MUssakjxg3jKa4SoEGaokCa5Ys1Ci6S2FZwq/HzM0voy8VCKHgjS zgZyWVPhPgVWa7PbWkTAuwp1ui1xecM6PwcQuRnLlMlM5XxSaLsCecswTKazipLtD+cj oyuEW/ez5UgGKI9H6i77gMqSQBrnxIy2MbnIiwx80/eKws7URNFjRX7+/O0O+x9WxY1U zC7A== X-Gm-Message-State: APf1xPAwkCIVFO7uwEV+CXCg0JlI6BouKiu0Z+jW/uUXIyUg98hrXpgc RQNY0z/MoDomdjmgKewgCvAdIQ== X-Received: by 10.202.207.20 with SMTP id f20mr1210656oig.21.1518538178600; Tue, 13 Feb 2018 08:09:38 -0800 (PST) Received: from ?IPv6:2601:602:9802:a8dc::f21a? ([2601:602:9802:a8dc::f21a]) by smtp.gmail.com with ESMTPSA id e94sm1115427ote.74.2018.02.13.08.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 08:09:37 -0800 (PST) Subject: Re: [kernel-hardening] [PATCH 4/6] Protectable Memory To: Jann Horn , Kees Cook Cc: Igor Stoppa , Boris Lukashev , Christopher Lameter , Matthew Wilcox , Jerome Glisse , Michal Hocko , Christoph Hellwig , linux-security-module , Linux-MM , kernel list , Kernel Hardening References: <20180124175631.22925-1-igor.stoppa@huawei.com> <20180124175631.22925-5-igor.stoppa@huawei.com> <20180126053542.GA30189@bombadil.infradead.org> <8818bfd4-dd9f-f279-0432-69b59531bd41@huawei.com> <17e5b515-84c8-dca2-1695-cdf819834ea2@huawei.com> <414027d3-dd73-cf11-dc2a-e8c124591646@redhat.com> From: Laura Abbott Message-ID: Date: Tue, 13 Feb 2018 08:09:35 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/12/2018 07:39 PM, Jann Horn wrote: > On Tue, Feb 13, 2018 at 2:25 AM, Kees Cook wrote: >> On Mon, Feb 12, 2018 at 4:40 PM, Laura Abbott wrote: >>> On 02/12/2018 03:27 PM, Kees Cook wrote: >>>> >>>> On Sun, Feb 4, 2018 at 7:05 AM, Igor Stoppa >>>> wrote: >>>>> >>>>> On 04/02/18 00:29, Boris Lukashev wrote: >>>>>> >>>>>> On Sat, Feb 3, 2018 at 3:32 PM, Igor Stoppa >>>>>> wrote: >>>>> >>>>> >>>>> [...] >>>>> >>>>>>> What you are suggesting, if I have understood it correctly, is that, >>>>>>> when the pool is protected, the addresses already given out, will >>>>>>> become >>>>>>> traps that get resolved through a lookup table that is built based on >>>>>>> the content of each allocation. >>>>>>> >>>>>>> That seems to generate a lot of overhead, not to mention the fact that >>>>>>> it might not play very well with the MMU. >>>>>> >>>>>> >>>>>> That is effectively what i'm suggesting - as a form of protection for >>>>>> consumers against direct reads of data which may have been corrupted >>>>>> by some irrelevant means. In the context of pmalloc, it would probably >>>>>> be a separate type of ro+verified pool >>>>> >>>>> ok, that seems more like an extension though. >>>>> >>>>> ATM I am having problems gaining traction to get even the basic merged >>>>> :-) >>>>> >>>>> I would consider this as a possibility for future work, unless it is >>>>> said that it's necessary for pmalloc to be accepted ... >>>> >>>> >>>> I would agree: let's get basic functionality in first. Both >>>> verification and the physmap part can be done separately, IMO. >>> >>> >>> Skipping over physmap leaves a pretty big area of exposure that could >>> be difficult to solve later. I appreciate this might block basic >>> functionality but I don't think we should just gloss over it without >>> at least some idea of what we would do. >> >> What's our exposure on physmap for other regions? e.g. things that are >> executable, or made read-only later (like __ro_after_init)? > > I just checked on a system with a 4.9 kernel, and there seems to be no > physical memory that is mapped as writable in the init PGD and > executable elsewhere. > > Ah, I think I missed something. At least on X86, set_memory_ro, > set_memory_rw, set_memory_nx and set_memory_x all use > change_page_attr_clear/change_page_attr_set, which use > change_page_attr_set_clr, which calls __change_page_attr_set_clr() > with a second parameter "checkalias" that is set to 1 unless the bit > being changed is the NX bit, and that parameter causes the invocation > of cpa_process_alias(), which will, for mapped ranges, also change the > attributes of physmap ranges. set_memory_ro() and so on are also used > by the module loading code. > > But in the ARM64 code, I don't see anything similar. Does anyone with > a better understanding of ARM64 want to check whether I missed > something? Or maybe, with a recent kernel, check whether executable > module pages show up with a second writable mapping in the > "kernel_page_tables" file in debugfs? > No, arm64 doesn't fixup the aliases, mostly because arm64 uses larger page sizes which can't be broken down at runtime. CONFIG_PAGE_POISONING does use 4K pages which could be adjusted at runtime. So yes, you are right we would have physmap exposure on arm64 as well. To the original question, it does sound like we are actually okay with the physmap. Thanks, Laura