Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1102551rdb; Wed, 6 Dec 2023 08:37:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWdJAu3VHpDuhw+gvYhqg/1TEdO0kNLofFml9M0ETLVrQlf+BE8nsBZyj5TTcunrrq0+zM X-Received: by 2002:a05:6a20:8614:b0:18f:e27f:dd44 with SMTP id l20-20020a056a20861400b0018fe27fdd44mr799217pze.13.1701880676291; Wed, 06 Dec 2023 08:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701880676; cv=none; d=google.com; s=arc-20160816; b=WrI8mWxPqo0qscf5QB7t5o3jsJliahD0bg+C5b+FkXh6v0zv2B/cF2lYLEvMojgkxe Th0M+QFIt0kIaIm65y18RxhLrnyHBZOgXpKEL38Bv4W2MD5yLAko2G8OJuIuyopWfVGe mHiE8HdH5qpRs8jbFwn4fTPr1y09wFn1v/kIUKI1RrOfXrm9i2Phyi/ZIjG7LXBaEXlr 9gl3uJA0m3f2xfCXIIJVukdLCLJxZNJ3cn94hK6OH//5VWHKbhIjSHlMQPuThgbvR6Hr wFlXsLv3/HyPhTx3+Q/f8Nj2uwwKXPO061xdBUuVZzPV7rrTWOdzEuxKqgH4Omeq/1Ia uwiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=1wQFnh2bPx3Ra+HT0vuTvJh3mkp2WmHQjZ5XzPfzvKU=; fh=7QQYeez0EKwyH8cPgbsqkT1g+UsgK0BtM6soHMYdmaw=; b=lGhq/5Z/NyswRXilTP1oWrAEfWIfc95qfqRQa5RaYLCzegIdx5ldkEz6oPXD2b7hyK ZHKcYHqXZnySqsKODz2gPXLe0U1kSGE7lJQu3uc46IDWc/9VjwkAzSwcXFPZk/OBdU7K 3dBv5T0NOpEep/l0/kAFSylLKBRftgnIpMuL0UE+/owtBSWm7o2USBs9/9nH39gEZNgK eKMbE6JVHmj8HpVGNfqZMWF3Cz/iNUOa4YzMNJBgXaBxT06AjE7dW5Q4OVYzj0IA+lnd o49KIOnEBGSzzWGM/xBqMb0eltckaSeRl5STfomhZ+Da2x5kp/rk6V2nPFjSAgqcoCvB Ua2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=s6K+9Yl8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q9-20020a63f949000000b005c6634fa849si154777pgk.89.2023.12.06.08.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 08:37:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=s6K+9Yl8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 24D90802F203; Wed, 6 Dec 2023 08:37:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442563AbjLFQhh (ORCPT + 99 others); Wed, 6 Dec 2023 11:37:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379267AbjLFQhf (ORCPT ); Wed, 6 Dec 2023 11:37:35 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6C175D5A; Wed, 6 Dec 2023 08:37:37 -0800 (PST) Received: from [192.168.4.26] (unknown [47.186.13.91]) by linux.microsoft.com (Postfix) with ESMTPSA id 8823E20B74C0; Wed, 6 Dec 2023 08:37:34 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8823E20B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1701880656; bh=1wQFnh2bPx3Ra+HT0vuTvJh3mkp2WmHQjZ5XzPfzvKU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=s6K+9Yl89Z3KgwoiYSQZ2dvP0uHj6IpQUthOWrczE2xRQB83yQa/TT5PF6Hy3U1sa 8E05mbqFUb33ePDO+wVm37jwLQyxQau0SjCjOt7vH/QkttsTN3Z9GdmbJ5scmpsxun Ibo6TwIr6zVmB49da7xmGxwKzie0382EULwJL3Ko= Message-ID: <624a310b-c0d2-406c-a4a7-d851b3cc68f5@linux.microsoft.com> Date: Wed, 6 Dec 2023 10:37:33 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 17/19] heki: x86: Update permissions counters during text patching To: Peter Zijlstra Cc: =?UTF-8?Q?Micka=C3=ABl_Sala=C3=BCn?= , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Ingo Molnar , Kees Cook , Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Alexander Graf , Chao Peng , "Edgecombe, Rick P" , Forrest Yuan Yu , James Gowans , James Morris , John Andersen , Marian Rotariu , =?UTF-8?Q?Mihai_Don=C8=9Bu?= , =?UTF-8?B?TmljdciZb3IgQ8OuyJt1?= , Thara Gopinath , Trilok Soni , Wei Liu , Will Deacon , Yu Zhang , Zahra Tarkhani , =?UTF-8?Q?=C8=98tefan_=C8=98icleru?= , dev@lists.cloudhypervisor.org, kvm@vger.kernel.org, linux-hardening@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, x86@kernel.org, xen-devel@lists.xenproject.org References: <20231113022326.24388-1-mic@digikod.net> <20231113022326.24388-18-mic@digikod.net> <20231113081929.GA16138@noisy.programming.kicks-ass.net> <20231127200841.GZ3818@noisy.programming.kicks-ass.net> <20231130113315.GE20191@noisy.programming.kicks-ass.net> Content-Language: en-US From: "Madhavan T. Venkataraman" In-Reply-To: <20231130113315.GE20191@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 08:37:53 -0800 (PST) On 11/30/23 05:33, Peter Zijlstra wrote: > On Wed, Nov 29, 2023 at 03:07:15PM -0600, Madhavan T. Venkataraman wrote: > >> Kernel Lockdown >> --------------- >> >> But, we must provide at least some security in V2. Otherwise, it is useless. >> >> So, we have implemented what we call a kernel lockdown. At the end of kernel >> boot, Heki establishes permissions in the extended page table as mentioned >> before. Also, it adds an immutable attribute for kernel text and kernel RO data. >> Beyond that point, guest requests that attempt to modify permissions on any of >> the immutable pages will be denied. >> >> This means that features like FTrace and KProbes will not work on kernel text >> in V2. This is a temporary limitation. Once authentication is in place, the >> limitation will go away. > > So either you're saying your patch 17 / text_poke is broken (so why > include it ?!?) or your statement above is incorrect. Pick one. > It has been included so that people can be aware of the changes. I will remove the text_poke() changes from the patchset and send it later when I have some authentication in place. It will make sense then. > >> __text_poke() >> This function is called by various features to patch text. >> This calls heki_text_poke_start() and heki_text_poke_end(). >> >> heki_text_poke_start() is called to add write permissions to the >> extended page table so that text can be patched. heki_text_poke_end() >> is called to revert write permissions in the extended page table. > > This, if text_poke works, then static_call / jump_label / ftrace and > everything else should work, they all rely on this. > > >> Peter mentioned the following: >> >> "if you want to mirror the native PTEs why don't you hook into the >> paravirt page-table muck and get all that for free?" >> >> We did consider using a shadow page table kind of approach so that guest page table >> modifications can be intercepted and reflected in the page table entry. We did not >> do this for two reasons: >> >> - there are bits in the page table entry that are not permission bits. We would like >> the guest kernel to be able to modify them directly. > > This statement makes no sense. > >> - we cannot tell a genuine request from an attack. > > Why not? How is an explicit call different from an explicit call in a > paravirt hook? > >>From a maintenance pov we already hate paravirt with a passion, but it > is ever so much better than sprinkling yet another pile of crap > (heki_*) around. I only said that the idea was considered. We can resume the discussion on this topic when I send the text_poke() changes in a later version of the Heki patchset. Madhavan