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=-8.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 8C581C433B4 for ; Fri, 23 Apr 2021 10:13:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C05AC61445 for ; Fri, 23 Apr 2021 10:13:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C05AC61445 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0045D8D0008; Fri, 23 Apr 2021 06:13:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1E3C8D0001; Fri, 23 Apr 2021 06:13:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBF138D0008; Fri, 23 Apr 2021 06:13:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id BDB9A8D0001 for ; Fri, 23 Apr 2021 06:13:55 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 646622484 for ; Fri, 23 Apr 2021 10:13:55 +0000 (UTC) X-FDA: 78063220830.35.44E3CBC Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by imf24.hostedemail.com (Postfix) with ESMTP id DA6DAA00038D for ; Fri, 23 Apr 2021 10:13:45 +0000 (UTC) Received: by mail-lf1-f47.google.com with SMTP id j4so37236830lfp.0 for ; Fri, 23 Apr 2021 03:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Gnaf3r9UNdG1FggI1YyKvtZjPl2wCw9hbk0IVarKdeY=; b=rohJ3ApdIp8eIDty7ZTykL0M+0n3Epndq2W6IeNG7zaahDj/PopRDPrmIvMNC5+N5q AbvRN7ueJnP4X2turnnaqbrP6Os4PRpq5vuSizTQDpO5+U7hQ8upLvlWgZ5Q9TBz2oRD SzqgQhOBxMZv76R3gF7og4Q9hoI1fQZgXTPB8BfTIymSc8oUc62hJd9YYqip9qBV6xl0 1OeDqztS0gOfQxsE12iqR4DLWIe98uxJIdb5LaueIcey95FCDvFFxL5sGmlQ1gJtuMg2 JBH+yeQy2LyQLAkvjJnkBhNAy6ciRblNJIOHfcp2z8Ush5vGQicLNhE9yuknfI5K7Qg/ Dy1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Gnaf3r9UNdG1FggI1YyKvtZjPl2wCw9hbk0IVarKdeY=; b=mMnWgNvDYmtA8Xm81dL53zWkxYFJLtdUnRcaYx3j4mt2P/XHtufbRCUGJ8QCZbcuLw 35gaFd21mCXkOtFXja0lPPxtGZzarvsFLKBxw7k/gy0Om2tL0GuMf9vfQQRqYkVcS2NQ +rki6kZvPYbl3Xsi4oV82vDP1MZqwiu7SJsTINBmUpX02TPJIvlJsG4crN4JF9XmKyg2 dvJvfGM3jIYLdrViNZIuDxyiPwef5KRNmqhCcGo1TQvhw6snR0hanoHavhka1tlhYOtR ztvqF1vNodInvba5kMh0pCa4mXTZueXksRI6RTba9BD7FXND5bSqls6WkGRlrOEP5/+z vimw== X-Gm-Message-State: AOAM530Y+jrj8oFO13Faq1gpbvmtKJ6y9lTh+rIvCXd53dsxHT3ladPQ 36TSjz/rL68vJwT+t1d/CbhLwg== X-Google-Smtp-Source: ABdhPJz9uy18OLUxIti5N9jQtwFUmXPO5gGtMxzSl2Fy0S1+VLIN2ACGrMCf6lbceikj1AyzpdDXhA== X-Received: by 2002:a05:6512:308a:: with SMTP id z10mr2280947lfd.15.1619172831869; Fri, 23 Apr 2021 03:13:51 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id h66sm505910lfd.248.2021.04.23.03.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 03:13:51 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id D32BC10257F; Fri, 23 Apr 2021 13:13:52 +0300 (+03) Date: Fri, 23 Apr 2021 13:13:52 +0300 From: "Kirill A. Shutemov" 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 , 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" Subject: Re: [PATCH v25 16/30] mm: Fixup places that call pte_mkwrite() directly Message-ID: <20210423101352.zwvltq734peuec4g@box.shutemov.name> References: <20210415221419.31835-1-yu-cheng.yu@intel.com> <20210415221419.31835-17-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210415221419.31835-17-yu-cheng.yu@intel.com> X-Stat-Signature: 7gjpwbti71e19iwfqe6inoa8imipimgr X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DA6DAA00038D Received-SPF: none (shutemov.name>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-lf1-f47.google.com; client-ip=209.85.167.47 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619172825-399043 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 15, 2021 at 03:14:05PM -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 have the > same result as from maybe_mkwrite(). These sites need to be updated for > 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() > is called directly. Fix it by doing maybe_mkwrite(). Make the same > changes to do_huge_pmd_numa_page(). > > - In change_pte_range(), pte_mkwrite() is called directly. Replace it with > maybe_mkwrite(). > > Signed-off-by: Yu-cheng Yu > Cc: Kees Cook Reviewed-by: Kirill A. Shutemov -- Kirill A. Shutemov