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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 6140DC433E6 for ; Tue, 1 Sep 2020 17:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40B992098B for ; Tue, 1 Sep 2020 17:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598982374; bh=XFZ88HewQoEjX2uJ9z8eaQBKTvSmcqHdw3MZB06++UA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=oVWytU+otoB28AwJ4g1fzhUP+WO3dFEAYUDay6DA/jGJfJNDCvFr5etpAdCgnO3ka ye6BaHO4QrG/W8XdzBXUwNdahKct9V/rp2pyNGyx1Ilc8xcAJYXPDLIWrBxKQcfV7V 3mhvD9xy7SVUJBGWNzxLWkxSJsiv5DD68enCk62U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728969AbgIARqJ (ORCPT ); Tue, 1 Sep 2020 13:46:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:34200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728804AbgIARqH (ORCPT ); Tue, 1 Sep 2020 13:46:07 -0400 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 8BC30214D8 for ; Tue, 1 Sep 2020 17:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598982366; bh=XFZ88HewQoEjX2uJ9z8eaQBKTvSmcqHdw3MZB06++UA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Xxq4jGgC3FP6E6gs/q13XQfdoEec6OPL6DZe2AMlX8NETGLlw5cCIhOa+6nXyzLUX uoPktWkJN7ohYD0ZUWHIzNAtWE+iimV6ZSWTLQ9YxeYXOo2wb1XfqVUBSE/b9QQaOs Mu+RS9g2Aa3YatA3A8fs18faklWbaNh4F1BXA5bo= Received: by mail-wm1-f53.google.com with SMTP id b79so2018583wmb.4 for ; Tue, 01 Sep 2020 10:46:06 -0700 (PDT) X-Gm-Message-State: AOAM531apDtHl0Kkdje7XAIB7ahTa+eIP8auT6v3UHF5BKv+pyM0Mrh7 TBZaL1JXT53xo3IcNVQyt1OeS3+wVz40oiJVFYVS2Q== X-Google-Smtp-Source: ABdhPJzgN/ki/QOy8VBTjEfkf88yPgVKoMbt/LBzptwfMiUASf1g/B5786/uD6CW1kC9N6DS/YCeDyVeKhyIJxbKQ58= X-Received: by 2002:a1c:2983:: with SMTP id p125mr2831445wmp.21.1598982364949; Tue, 01 Sep 2020 10:46:04 -0700 (PDT) MIME-Version: 1.0 References: <086c73d8-9b06-f074-e315-9964eb666db9@intel.com> <73c2211f-8811-2d9f-1930-1c5035e6129c@intel.com> <20200826164604.GW6642@arm.com> <87ft892vvf.fsf@oldenburg2.str.redhat.com> <0e9996bc-4c1b-cc99-9616-c721b546f857@intel.com> <4f2dfefc-b55e-bf73-f254-7d95f9c67e5c@intel.com> <20200901102758.GY6642@arm.com> In-Reply-To: From: Andy Lutomirski Date: Tue, 1 Sep 2020 10:45:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: "Yu, Yu-cheng" Cc: Dave Martin , "H.J. Lu" , Dave Hansen , Andy Lutomirski , Florian Weimer , 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 , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Weijiang Yang Content-Type: text/plain; charset="UTF-8" Sender: linux-arch-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Tue, Sep 1, 2020 at 10:23 AM Yu, Yu-cheng wrote: > > On 9/1/2020 3:28 AM, Dave Martin wrote: > > On Thu, Aug 27, 2020 at 06:26:11AM -0700, H.J. Lu wrote: > >> On Wed, Aug 26, 2020 at 12:57 PM Dave Hansen wrote: > >>> > >>> On 8/26/20 11:49 AM, Yu, Yu-cheng wrote: > >>>>> I would expect things like Go and various JITs to call it directly. > >>>>> > >>>>> If we wanted to be fancy and add a potentially more widely useful > >>>>> syscall, how about: > >>>>> > >>>>> mmap_special(void *addr, size_t length, int prot, int flags, int type); > >>>>> > >>>>> Where type is something like MMAP_SPECIAL_X86_SHSTK. Fundamentally, > >>>>> this is really just mmap() except that we want to map something a bit > >>>>> magical, and we don't want to require opening a device node to do it. > >>>> > >>>> One benefit of MMAP_SPECIAL_* is there are more free bits than MAP_*. > >>>> Does ARM have similar needs for memory mapping, Dave? > >>> > >>> No idea. > >>> > >>> But, mmap_special() is *basically* mmap2() with extra-big flags space. > >>> I suspect it will grow some more uses on top of shadow stacks. It could > >>> have, for instance, been used to allocate MPX bounds tables. > >> > >> There is no reason we can't use > >> > >> long arch_prctl (int, unsigned long, unsigned long, unsigned long, ..); > >> > >> for ARCH_X86_CET_MMAP_SHSTK. We just need to use > >> > >> syscall (SYS_arch_prctl, ARCH_X86_CET_MMAP_SHSTK, ...); > > > > > > For arm64 (and sparc etc.) we continue to use the regular mmap/mprotect > > family of calls. One or two additional arch-specific mmap flags are > > sufficient for now. > > > > Is x86 definitely not going to fit within those calls? > > That can work for x86. Andy, what if we create PROT_SHSTK, which can > been seen only from the user. Once in kernel, it is translated to > VM_SHSTK. One question for mremap/mprotect is, do we allow a normal > data area to become shadow stack? I'm unconvinced that we want to use a somewhat precious PROT_ or VM_ bit for this. Using a flag bit makes sense if we expect anyone to ever map an fd or similar as a shadow stack, but that seems a bit odd in the first place. To me, it seems more logical for a shadow stack to be a special sort of mapping with a special vm_ops, not a normal mapping with a special flag set. Although I realize that we want shadow stacks to work like anonymous memory with respect to fork(). Dave? --Andy