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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 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 49378C433FF for ; Wed, 14 Aug 2019 16:37:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B0512133F for ; Wed, 14 Aug 2019 16:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbfHNQhC (ORCPT ); Wed, 14 Aug 2019 12:37:02 -0400 Received: from mga02.intel.com ([134.134.136.20]:39981 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbfHNQhB (ORCPT ); Wed, 14 Aug 2019 12:37:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2019 09:37:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,385,1559545200"; d="scan'208";a="178213373" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by fmsmga007.fm.intel.com with ESMTP; 14 Aug 2019 09:37:00 -0700 Message-ID: Subject: Re: [PATCH v8 15/27] mm: Handle shadow stack page fault From: Yu-cheng Yu To: Andy Lutomirski Cc: X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , 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 Date: Wed, 14 Aug 2019 09:27:21 -0700 In-Reply-To: References: <20190813205225.12032-1-yu-cheng.yu@intel.com> <20190813205225.12032-16-yu-cheng.yu@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-08-13 at 15:55 -0700, Andy Lutomirski wrote: > On Tue, Aug 13, 2019 at 2:02 PM Yu-cheng Yu wrote: > > > > When a task does fork(), its shadow stack (SHSTK) must be duplicated > > for the child. This patch implements a flow similar to copy-on-write > > of an anonymous page, but for SHSTK. > > > > A SHSTK PTE must be RO and dirty. This dirty bit requirement is used > > to effect the copying. In copy_one_pte(), clear the dirty bit from a > > SHSTK PTE to cause a page fault upon the next SHSTK access. At that > > time, fix the PTE and copy/re-use the page. > > Is using VM_SHSTK and special-casing all of this really better than > using a special mapping or other pseudo-file-backed VMA and putting > all the magic in the vm_operations? A special mapping is cleaner. However, we also need to exclude normal [RO + dirty] pages from shadow stack. Yu-cheng