Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1618989pxk; Tue, 1 Sep 2020 03:29:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfz1QKpo+zUOyKZPUefn1NMBc0zD0U/iRuoAyTzP6ehQd+UbjOZrOjyH/bJP4Tq+iHYoVt X-Received: by 2002:a05:6402:1c85:: with SMTP id cy5mr1197692edb.6.1598956173270; Tue, 01 Sep 2020 03:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598956173; cv=none; d=google.com; s=arc-20160816; b=N/rdkKBirlqG4QIgtWA7xqBwdzQbEIHvHLLJY6kBd48OQ0V0fUcO6khiIm1RPUgJH6 vTRiZbFGhZhJJqT7IRkoombtkOzw6h4LLcINxYDlBfHBI9VwW2UTrphqiXNMmT7fq4EN 3ty1Ymvl9qnNiI3PZDJIQfP78Iw2DQwsTk40mFR8ct/NTIT/K/386w4GRfmtlpY9QG/R 8NAY96bXvPGo7zLztEQSSx2idYT7p6aulgqKJLd8XovwxhX7XeNT2glrfA15By6KonzY iZbcjvWpvx8Mu8BQuFTZTQu4Zhp9t6jKaRHWHejOrKE/9NXDs5isP7/5Be3HYJuinEL+ h87w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+2aeWEHV9ckhFowrK4xTYUt9OtpkfP1UyERbWCOytls=; b=zU7CRxQ8QMb35+kGKxhIcH82ocVGHBEu+Y1+7ggrnvGQr8ybhI958y7s4dYoTahEBN j3P1UTYS/FnOM4CwmXQ+YiB7OzLxjKMBtjLQ5XuXihUU67/j7nIH/TCr9FagaW+cH0zR KzZlFZIZT68bQlnD/tZR3wnUUBElCfTSIB81O3E63PaH4cdZxiNmu9PpM6VWPEPyCkwN 4B0bVgeMPKQcOgwt4v6mIC12UploAkRSIpun6Iwbu4/+U5QEWOktlWOplELlCaioT7eV pVS5XyOSSxgpRQDFLrTnV/LCEzxnUPA+nNHm4LWooEGE4upXFcqu5fXGr11MgWQg8ioF i1tA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu19si430591ejb.305.2020.09.01.03.29.10; Tue, 01 Sep 2020 03:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725848AbgIAK2M (ORCPT + 99 others); Tue, 1 Sep 2020 06:28:12 -0400 Received: from foss.arm.com ([217.140.110.172]:40064 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbgIAK2H (ORCPT ); Tue, 1 Sep 2020 06:28:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B96D330E; Tue, 1 Sep 2020 03:28:06 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 06EF93F71F; Tue, 1 Sep 2020 03:28:02 -0700 (PDT) Date: Tue, 1 Sep 2020 11:28:00 +0100 From: Dave Martin To: "H.J. Lu" Cc: Dave Hansen , "Yu, Yu-cheng" , 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 Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack Message-ID: <20200901102758.GY6642@arm.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? For now, I can't see what arg[2] is used for (and hence the type argument of mmap_special()), but I haven't dug through the whole series. Cheers ---Dave