Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp364610pxa; Wed, 26 Aug 2020 12:45:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc3oMjVzKrbVdxeAvjOVa55jEWgjuijaHHaoJz8io5ujw5c1qLW/uNvbp1GIKtIn1KsCZB X-Received: by 2002:a17:907:728e:: with SMTP id dt14mr4791065ejc.4.1598471116276; Wed, 26 Aug 2020 12:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598471116; cv=none; d=google.com; s=arc-20160816; b=oO+7lFMWQBg55Fp8hdmL6OR7Wi20zd7jhoUvXbtjgxkN2XB2bm5ZEV6v2VnsSpOutU TDJXLpHzMnvlX3vafjafD3Q6jWu3Q8YIjIV+v005DAq2v+SkYcjTc3gDfZyGsCI629+M NWupSgBCsA6VAR6b9Gd7hyiaRL0ISB3OxnKoQrVprM1vAwd9e3TpCYZFPR88kuW/pzOW o9NrRyfEVfy+UfA5ryRK6mqKRYi7JF6J0A8XyY4v30JxOjo7tvo9qo/nEv2HwZ6/7I0N t2XR43JQxauMKEFgFHD4SOOqmz6B/YuefbZOSMWP6ydvWm6YRUFHt987AQCl63/YKNya KeCw== 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=lJ9q/iTfnCsZrkSkcmh8UHaAoIWOgUVnnZaiByIljT0=; b=H/IwsAs4I02HqzrMNzxM103wYlk0+idZVLunFBKTlKzuXpR8J8p7YiotSuOWlQUorS Q7tsE+cNH73VptTEBzLB+ks8kZXRrDDA9AiHg19NXxbJpGS5Xmwy2pfY8qRzPMltWM81 zJxU+simoq9IMMoKChAqJrIpme6CGI3ECREyBjfygJVziRjWQNW8E04ZUhT6nP/84C9d qKv7ZQnLynj3yx3Ms/p/cPXA7DWqXn0gEUdET3FHtD7lDoSBxRGc9aMp/Rq54nSQDZN5 xqVAi5JUUxP2IuxkR4ngvjJ6YE5pJBz9E312Q1nsSJ2H4FChx1MNC0JNdjw5chGOLEf0 g5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ps/pJgcT"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si2182255ejz.613.2020.08.26.12.44.52; Wed, 26 Aug 2020 12:45:16 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ps/pJgcT"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbgHZToR (ORCPT + 99 others); Wed, 26 Aug 2020 15:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbgHZToQ (ORCPT ); Wed, 26 Aug 2020 15:44:16 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C116DC061574; Wed, 26 Aug 2020 12:44:15 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id v2so2867029ilq.4; Wed, 26 Aug 2020 12:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lJ9q/iTfnCsZrkSkcmh8UHaAoIWOgUVnnZaiByIljT0=; b=Ps/pJgcT6hlQjSiv9LSDBFUBLEqMhQjJl+vRmYXQWoVU8FEt85TyheW93v4c1xKGn/ Anw5MGEuck1Lw8tOFZoHxtEaoxnCWoz8uxKNhvVxhLt+YphOBqavRg8DvHi4gVLDpJcQ W70rn7508qLaTn6d9FhUW8fZwkyu+CkONk1SFPOv9lniXIv0xYoBp3tMPOrfY4rb383t n+bYcmhHNKNXw0DztTgcTxgPH7HSyrQl+OQFOQkCrktG37+gm086BRyxfgUHercSBzx/ 70sVcuJy44Tn1oIqxDtgzULX/9cii27Iygnv0Rs35vn6icujZTGyyAU2BAqnhJtO3wcU HnDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lJ9q/iTfnCsZrkSkcmh8UHaAoIWOgUVnnZaiByIljT0=; b=tP3xqVqJVBWgbiN709DipcbMnp8XvnqapX1VMT3PfSlXtATyxhGz5yk0pCRGvWkz2T uH+DfLydZKVZ6WlyVEmZFQ0Ymwt0gs4Rd7mzsCfoKyyla1QCIIaZD8O/x7131O2i1RKF HUDK+nybp/gCWVB2N/NICk+DAqbsCiZeBxm6YnGyZNjAF+M/nwx4UkW759h1dCMR9FNN CsDPn5pI3pYLPBmIp3fUFJi+6Ktcju8/aVlZd2vT8HyAjCJY21XFmQ34y6Kd3g2GH//I 445s6o7QAs1PT7maruk7bPmNp4YMN1R1e6bX9DtfgKZMWnnP/ojM1TzePxeRel76x0du N0IA== X-Gm-Message-State: AOAM5333/fI7N24v2CsO8Yndr8j2aiu8FskIMjEUK+ULWZQzVUWULcif m4suG5eerIxREicwZ0mrj6Ve3pi0u7U44FO3swM= X-Received: by 2002:a92:6a0c:: with SMTP id f12mr13581043ilc.213.1598471055050; Wed, 26 Aug 2020 12:44:15 -0700 (PDT) MIME-Version: 1.0 References: <20200825002540.3351-1-yu-cheng.yu@intel.com> <20200825002540.3351-26-yu-cheng.yu@intel.com> <2d253891-9393-44d0-35e0-4b9a2da23cec@intel.com> <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> In-Reply-To: <0e9996bc-4c1b-cc99-9616-c721b546f857@intel.com> From: "H.J. Lu" Date: Wed, 26 Aug 2020 12:43:39 -0700 Message-ID: Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: "Yu, Yu-cheng" Cc: Andy Lutomirski , Florian Weimer , Dave Martin , Dave Hansen , 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 11:49 AM Yu, Yu-cheng wrote: > > On 8/26/2020 10:04 AM, Andy Lutomirski wrote: > > On Wed, Aug 26, 2020 at 9:52 AM Florian Weimer wrote: > >> > >> * Dave Martin: > >> > >>> On Tue, Aug 25, 2020 at 04:34:27PM -0700, Yu, Yu-cheng wrote: > >>>> On 8/25/2020 4:20 PM, Dave Hansen wrote: > >>>>> On 8/25/20 2:04 PM, Yu, Yu-cheng wrote: > >>>>>>>> I think this is more arch-specific. Even if it becomes a new syscall, > >>>>>>>> we still need to pass the same parameters. > >>>>>>> > >>>>>>> Right, but without the copying in and out of memory. > >>>>>>> > >>>>>> Linux-api is already on the Cc list. Do we need to add more people to > >>>>>> get some agreements for the syscall? > >>>>> What kind of agreement are you looking for? I'd suggest just coding it > >>>>> up and posting the patches. Adding syscalls really is really pretty > >>>>> straightforward and isn't much code at all. > >>>>> > >>>> > >>>> Sure, I will do that. > >>> > >>> Alternatively, would a regular prctl() work here? > >> > >> Is this something appliation code has to call, or just the dynamic > >> loader? > >> > >> prctl in glibc is a variadic function, so if there's a mismatch between > >> the kernel/userspace syscall convention and the userspace calling > >> convention (for variadic functions) for specific types, it can't be made > >> to work in a generic way. > >> > >> The loader can use inline assembly for system calls and does not have > >> this issue, but applications would be implcated by it. > >> > > > > 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? > arch/arm64/include/uapi/asm/mman.h: #define PROT_BTI 0x10 /* BTI guarded page */ -- H.J.