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 DE05CC433E2 for ; Tue, 1 Sep 2020 17:46:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A55A3207D3 for ; Tue, 1 Sep 2020 17:46:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xxq4jGgC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A55A3207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2CC846B00C8; Tue, 1 Sep 2020 13:46:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A3B46B00CA; Tue, 1 Sep 2020 13:46:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B9B66B00CB; Tue, 1 Sep 2020 13:46:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id EE4596B00C8 for ; Tue, 1 Sep 2020 13:46:08 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A834B8248047 for ; Tue, 1 Sep 2020 17:46:08 +0000 (UTC) X-FDA: 77215221216.09.beef54_490ab332709a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 79D50180AD804 for ; Tue, 1 Sep 2020 17:46:08 +0000 (UTC) X-HE-Tag: beef54_490ab332709a X-Filterd-Recvd-Size: 6267 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 17:46:07 +0000 (UTC) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 94CF1207D3 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-f47.google.com with SMTP id v4so2021190wmj.5 for ; Tue, 01 Sep 2020 10:46:06 -0700 (PDT) X-Gm-Message-State: AOAM532KGgwiG98wPSxrAEFA2TZiFkB+gCM6/w1uxi79G4Oikcj0T+WO 7UdH/SGecJrstY2jBkFmyG0S6yFeR/Sd9pOvm1IYBw== 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" X-Rspamd-Queue-Id: 79D50180AD804 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 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