From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3028DC6379F for ; Mon, 20 Feb 2023 11:18:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231605AbjBTLSw (ORCPT ); Mon, 20 Feb 2023 06:18:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbjBTLSt (ORCPT ); Mon, 20 Feb 2023 06:18:49 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1638218AA0 for ; Mon, 20 Feb 2023 03:17:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676891836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4EQNfPCKlm/dnqlucYMgfhMhQeV8s6OOHLtd2gYWnSc=; b=bCt5/hFMgVueFQtlt9TrsPeAUpka+6urNnoT9ydQj5eb4cOYqaUEs/HKI887XEIYC5l1n9 mCZlR94CzlcmUnHOXOrcBw8ln3H2qCCwo69HhHR/2W4ny7riYBKCQHs6X9u7Xw9O6z58E6 kE0TJdVdItM8HQ8k30dLuJuq0KHbTYI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-325-Gm5fbJr6NgCB5Gx4OfnCmQ-1; Mon, 20 Feb 2023 06:17:14 -0500 X-MC-Unique: Gm5fbJr6NgCB5Gx4OfnCmQ-1 Received: by mail-wr1-f72.google.com with SMTP id v18-20020adfedd2000000b002c3f0a93825so266986wro.15 for ; Mon, 20 Feb 2023 03:17:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4EQNfPCKlm/dnqlucYMgfhMhQeV8s6OOHLtd2gYWnSc=; b=uH0h/LOFzosMuZfKojtH0z/DYKyiBnzCadt1Hc75AXS+5d2ifnduRMCGU15RT+bFp9 CiNB3QJi05q+5DFWXmRZj9BTmJlbMsNrGTgsI1b1opIA2BvR152o3vBq7sccapafHu/j 4wFcEHEbBis9kmPqZdQ0YzkfK1Bg77HVSI8J62HD5UZrdw3D3qfetwH/T9yVeZxVcjDz RwCr9+7syBB2+cSkK/XD14le7QLJ1La/8A3tW+es2qJarv+8l4ugDTRiJbIU98djqIdS gXZDdbA3mtD+v9NZnyWrTWlooYcyCgS6WUajE2XPnzOs3XKniR6Nsfv4TY4Ls/aPOA/Q LxzA== X-Gm-Message-State: AO0yUKX+ODFbpeghKfWNtyrGiBMVR15BWz1cmgADltBTLag3NnQfx7Yy +e5leVX4/WZe8QDbyWLeXEHQ/a7AiKt4MLuy2Xa2QcXXpWm7TeFT43MxX5jpi5SUCMj/nEzZigO jWeydc0j8kBrAMmEqKCeN X-Received: by 2002:a05:600c:4d89:b0:3e0:1a9:b1e0 with SMTP id v9-20020a05600c4d8900b003e001a9b1e0mr578795wmp.25.1676891833524; Mon, 20 Feb 2023 03:17:13 -0800 (PST) X-Google-Smtp-Source: AK7set8S0E2hPJcQfDWwVBHJ827trXEDgyAecAtZgO3tsbPQgMPJ2pfBI07ijKz0qUw/7N5br62ouQ== X-Received: by 2002:a05:600c:4d89:b0:3e0:1a9:b1e0 with SMTP id v9-20020a05600c4d8900b003e001a9b1e0mr578749wmp.25.1676891833134; Mon, 20 Feb 2023 03:17:13 -0800 (PST) Received: from ?IPV6:2003:cb:c705:8300:e519:4218:a8b5:5bec? (p200300cbc7058300e5194218a8b55bec.dip0.t-ipconnect.de. [2003:cb:c705:8300:e519:4218:a8b5:5bec]) by smtp.gmail.com with ESMTPSA id c128-20020a1c3586000000b003e21558ee9dsm331492wma.2.2023.02.20.03.17.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Feb 2023 03:17:12 -0800 (PST) Message-ID: Date: Mon, 20 Feb 2023 12:17:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: [PATCH v6 11/41] mm: Introduce pte_mkwrite_kernel() Content-Language: en-US To: Kees Cook , Rick Edgecombe Cc: x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, debug@rivosinc.com, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, xen-devel@lists.xenproject.org References: <20230218211433.26859-1-rick.p.edgecombe@intel.com> <20230218211433.26859-12-rick.p.edgecombe@intel.com> <63f288cc.a70a0220.5558c.3c92@mx.google.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <63f288cc.a70a0220.5558c.3c92@mx.google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On 19.02.23 21:38, Kees Cook wrote: > On Sat, Feb 18, 2023 at 01:14:03PM -0800, Rick Edgecombe wrote: >> The x86 Control-flow Enforcement Technology (CET) feature includes a new >> type of memory called shadow stack. This shadow stack memory has some >> unusual properties, which requires some core mm changes to function >> properly. >> >> One of these changes is to allow for pte_mkwrite() to create different >> types of writable memory (the existing conventionally writable type and >> also the new shadow stack type). Future patches will convert pte_mkwrite() >> to take a VMA in order to facilitate this, however there are places in the >> kernel where pte_mkwrite() is called outside of the context of a VMA. >> These are for kernel memory. So create a new variant called >> pte_mkwrite_kernel() and switch the kernel users over to it. Have >> pte_mkwrite() and pte_mkwrite_kernel() be the same for now. Future patches >> will introduce changes to make pte_mkwrite() take a VMA. >> >> Only do this for architectures that need it because they call pte_mkwrite() >> in arch code without an associated VMA. Since it will only currently be >> used in arch code, so do not include it in arch_pgtable_helpers.rst. >> >> Cc: linux-doc@vger.kernel.org >> Cc: linux-arm-kernel@lists.infradead.org >> Cc: linux-s390@vger.kernel.org >> Cc: xen-devel@lists.xenproject.org >> Cc: linux-arch@vger.kernel.org >> Cc: linux-mm@kvack.org >> Tested-by: Pengfei Xu >> Suggested-by: David Hildenbrand >> Signed-off-by: Rick Edgecombe > > I think it's a little weird that it's the only PTE helper taking a vma, > but it does seem like the right approach. Right. We could pass the vm flags instead, but not sure if that really improves the situation. So unless someone has a better idea, this LGTM. -- Thanks, David / dhildenb