Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp61139ybl; Tue, 13 Aug 2019 15:56:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEAzczEH8btcE1DFLaa+HhvOS7p93yKdG0IaIvKhOn6JsN+OFTpIpFtT8+M6MGd4loaASs X-Received: by 2002:a17:902:e30f:: with SMTP id cg15mr40243926plb.46.1565737010360; Tue, 13 Aug 2019 15:56:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565737010; cv=none; d=google.com; s=arc-20160816; b=go8mp/4hLZJ9OmEoxxPglujjCDo+lx5+EN2mJuoyGyPi6mRs5n9K9PzbsfTc49YaeP SmJM4NhVJZQxn3mOPW9Pc+jYM+LUfpJI5I6s8GILHtUZTlgvqdePBYZIazMZ0A6pT8sx E8QiTjeoaFy33HlxbcpHSqoyro7XQgopVIJUMLPJIoQSjLg6cGavisdFcuHyWXKKxaUg FwanLyfOXYxNbNhiBj5nDqcd95EBN9Mu+vPT1m+ijxkWaTq2EPRVAtVD/rcU84mnYPnd DYirmaFkxFkvA+xL/wTk2womRLxDg2H2ZP0o01Efmktg3b+/u202yNE3aN1KfT4vKubV bl2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/4h/Lqtm7KayZLypqr3NHPbDV2N3U0e7ADnwbjMnTyQ=; b=szzBvlcZk4Qf/IkG0+xzHO3S31tBy3psmDtKLuBNXYnBp2q1izepwQ7Dy4v0xAXS/x lIE6qli+chiEavnwH6KSIWaDzw+ZwqOvj3cvZ7VSfTqPufKPQ9yTZl9T8WdQT1CuU77T fePUjnAkGfhT8Su6mmkGnSt2cY59e8bWIqpwHnUzBI1QTob6QmQr2q8jlr0NSiM5znWi 1L7jN/bh56n9smY9W5rfA0GyFvV+z8H63vfdWc2C5TAQscmci27VcEL2G9psSKv5b2AQ pj6cn2qrGsjOK8vRZMTqM0h6L3h5LNcyU3rwcPZ4ZBosun9iT38wsWBWTdpQbrlmQrt7 QOng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ywdw8i9N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si16894766pgi.347.2019.08.13.15.56.34; Tue, 13 Aug 2019 15:56:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ywdw8i9N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727452AbfHMWzW (ORCPT + 99 others); Tue, 13 Aug 2019 18:55:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:59224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726698AbfHMWzW (ORCPT ); Tue, 13 Aug 2019 18:55:22 -0400 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF7AE2070D for ; Tue, 13 Aug 2019 22:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565736921; bh=+rrGnvdcanVtNKSBWoGJHi/njpfEfmBbO4E1AUigxgg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ywdw8i9NOLTIIMCBL4r7dwTOGtr9jQVBQm2Nfi4QSKZ5TDuLbpD9BYu+MoNU50rde W1tfa4sGxkMsyAhZ8YrFO5xzfxyA9tQ1NJMN+KFszGDWDnu3nYJ5D8+ayQf/onHMht XUrwBquLBtXbY8oQ8Evp9cZErtU2KDJXP2HM3BiQ= Received: by mail-wm1-f46.google.com with SMTP id 207so2924231wma.1 for ; Tue, 13 Aug 2019 15:55:20 -0700 (PDT) X-Gm-Message-State: APjAAAXOZl0cnbwUcmvnMAg3x0duaZzT6iVgusozVtg0gZ53wN7pshIf mj2Xe/xedbzF6NGBx2rpUuy/NhZl1xW3sUNeVyNbsQ== X-Received: by 2002:a05:600c:24cf:: with SMTP id 15mr5069335wmu.76.1565736919249; Tue, 13 Aug 2019 15:55:19 -0700 (PDT) MIME-Version: 1.0 References: <20190813205225.12032-1-yu-cheng.yu@intel.com> <20190813205225.12032-16-yu-cheng.yu@intel.com> In-Reply-To: <20190813205225.12032-16-yu-cheng.yu@intel.com> From: Andy Lutomirski Date: Tue, 13 Aug 2019 15:55:07 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 15/27] mm: Handle shadow stack page fault To: Yu-cheng Yu 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? --Andy