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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D7ABC43470 for ; Mon, 26 Apr 2021 11:11:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE38A610E6 for ; Mon, 26 Apr 2021 11:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233160AbhDZLMO (ORCPT ); Mon, 26 Apr 2021 07:12:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:46112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233112AbhDZLMH (ORCPT ); Mon, 26 Apr 2021 07:12:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1DFCF61075; Mon, 26 Apr 2021 11:11:17 +0000 (UTC) Date: Mon, 26 Apr 2021 12:11:15 +0100 From: Catalin Marinas To: "Kirill A. Shutemov" Cc: Yu-cheng Yu , 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 , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang , "Kirill A . Shutemov" , Vincenzo Frascino , Will Deacon Subject: Re: [PATCH v25 29/30] mm: Update arch_validate_flags() to include vma anonymous Message-ID: <20210426111114.GF4985@arm.com> References: <20210415221419.31835-1-yu-cheng.yu@intel.com> <20210415221419.31835-30-yu-cheng.yu@intel.com> <20210426064056.bqbeekpsogd32yvm@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210426064056.bqbeekpsogd32yvm@box.shutemov.name> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 26, 2021 at 09:40:56AM +0300, Kirill A. Shutemov wrote: > On Thu, Apr 15, 2021 at 03:14:18PM -0700, Yu-cheng Yu wrote: > > When newer VM flags are being created, such as VM_MTE, it becomes necessary > > for mmap/mprotect to verify if certain flags are being applied to an > > anonymous VMA. > > > > To solve this, one approach is adding a VM flag to track that MAP_ANONYMOUS > > is specified [1], and then using the flag in arch_validate_flags(). > > > > Another approach is passing vma_is_anonymous() to arch_validate_flags(). > > To prepare the introduction of PROT_SHSTK, which creates a shadow stack > > mapping and can only be applied to an anonymous VMA, update arch_validate_ > > flags() to include anonymous VMA information. > > I would rather pass down whole vma. Who knows what else > arch_validate_flags() would need to know about the VMA tomorrow: > > arch_validate_flags(vma, newflags); > > should do the trick. A reason why we added a separate VM_MTE_ALLOWED flag was that we wanted MTE on other RAM-based based mappings, not just anonymous pages. See 51b0bff2f703 ("mm: Allow arm64 mmap(PROT_MTE) on RAM-based files"). Anyway, the above change doesn't get in the way. -- Catalin