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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 2F93EC433E6 for ; Thu, 18 Mar 2021 09:48:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA57C64F3B for ; Thu, 18 Mar 2021 09:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbhCRJsB (ORCPT ); Thu, 18 Mar 2021 05:48:01 -0400 Received: from mail.skyhub.de ([5.9.137.197]:54566 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbhCRJro (ORCPT ); Thu, 18 Mar 2021 05:47:44 -0400 Received: from zn.tnic (p200300ec2f0fad007adf1d3bb2d68d82.dip0.t-ipconnect.de [IPv6:2003:ec:2f0f:ad00:7adf:1d3b:b2d6:8d82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 961B31EC058C; Thu, 18 Mar 2021 10:47:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1616060862; 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:in-reply-to:in-reply-to: references:references; bh=4Rj/z7f7I1IokpvMBB12tiM4VnDP7OF9VwWSkkcJM3k=; b=hjhIoz7Uc/TRti+bG+0jGfNRhjyIAibHRwRbRukyWfFjYgfXsYiU7OXqw6zle+qmaa5nMT rCfcxa3lGP2GSRLIb7WXLNEz8/gvoOTqkXNVzSYuyN4J4JX/5FEB1t4OWVEDF953pr4J2n yhTWh13jmFAeHQgA0mL4BIZT3bjXnSM= Date: Thu, 18 Mar 2021 10:47:40 +0100 From: Borislav Petkov To: Yu-cheng Yu 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 , 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 Subject: Re: [PATCH v23 16/28] mm: Fixup places that call pte_mkwrite() directly Message-ID: <20210318094740.GA19570@zn.tnic> References: <20210316151054.5405-1-yu-cheng.yu@intel.com> <20210316151054.5405-17-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210316151054.5405-17-yu-cheng.yu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 08:10:42AM -0700, Yu-cheng Yu wrote: > When serving a page fault, maybe_mkwrite() makes a PTE writable if it is in > a writable vma. A shadow stack vma is writable, but its PTEs need > _PAGE_DIRTY to be set to become writable. For this reason, maybe_mkwrite() > has been updated. > > There are a few places that call pte_mkwrite() directly, but effect the > same result as from maybe_mkwrite(). These sites need to be updated for s/effect the same result/have the same result/ > shadow stack as well. Thus, change them to maybe_mkwrite(): > > - do_anonymous_page() and migrate_vma_insert_page() check VM_WRITE directly > and call pte_mkwrite(), which is the same as maybe_mkwrite(). Change > them to maybe_mkwrite(). > > - In do_numa_page(), if the numa entry 'was-writable', then pte_mkwrite() You can simply say "was writable" instead of trying to hint at the variable there. > is called directly. Fix it by doing maybe_mkwrite(). > > - In change_pte_range(), pte_mkwrite() is called directly. Replace it with > maybe_mkwrite(). > > A shadow stack vma is writable but has different vma > flags, and handled accordingly in maybe_mkwrite(). > > Signed-off-by: Yu-cheng Yu > Reviewed-by: Kees Cook > --- > mm/memory.c | 5 ++--- > mm/migrate.c | 3 +-- > mm/mprotect.c | 2 +- > 3 files changed, 4 insertions(+), 6 deletions(-) As with the previous one, I guess this one needs a mm person ACK. I mean, it is pretty obvious but still... Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette