Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4131394pxk; Tue, 8 Sep 2020 11:27:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwP5rUWEcrU72N0o2CGpVVk4Nttqo5WaAryBaX/YFu+PlI6Z+2pKeqQPPGa3OYKxJExhQzG X-Received: by 2002:a17:906:fa8a:: with SMTP id lt10mr26791853ejb.307.1599589664786; Tue, 08 Sep 2020 11:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599589664; cv=none; d=google.com; s=arc-20160816; b=V4a2rlwykC4R5mcCeaeKqIn7o7Rzg0GO+z6Ms5WA3UHJfMPCbd+Lo5FKSjsKD8M1L2 W1DnoyRgOQSASWqsz6Zqm1TLX7difvgc2vOoFxqLeYVNPeSRc2UqIX88njHft/hRM7WD LYiArfRR3L7y2GK+SzJjU60Sg3KpaSn/CZA+i8FqsB4f23sqkbzoMykBJd+VTmJrHWgr TupGCFsskyI9IQH0/H6CNgVznw8u+CO4caqcTqKr4R+j6QM1Ri2FqlO7hfeD4/sUcPF3 lrD7eA9E46mc0oSCI5sECSzBBs/EnkZc12t1K8z8vjpKB6BrBQoUBzSp9wldcMDmzA+g JEWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=xxNp3hVlHXrzZogJVVGWwB6X/jKwu9YuIrH/R/LHiZw=; b=ECPpudBCvu0jnzdazrX0ugUq3/aTTaJFfzLFC2/XYz0+jkGz+ebzf4An0CCtm6+xkl Z52ilYT3HX7yOhnWzmwiT+6qioHuCXaZONGY6UlddDJRMzsl9c1TE92/lzL3VkbcWtBj xa+w1JvS392xupRHj01YDgp/ay3HV3VH7JbHUFqe2LODPighZV5F2D1Bzk9vh0VPZrAN q+n2Pp7yEoLsxRdMa1uCW6HZZ6qVLrxiX79Bx73LSh8wEFB8Yzu3xm6JqZHeIFFL+GHb 1CD7iVs/SEydXGMA9tlvHh/3eU93QvqTHWO3Pv6q36Fp35G1d+VeYlyPEDrqf8v279lX B2gw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si903396ejb.145.2020.09.08.11.27.22; Tue, 08 Sep 2020 11:27:44 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729181AbgIHSZh (ORCPT + 99 others); Tue, 8 Sep 2020 14:25:37 -0400 Received: from mga04.intel.com ([192.55.52.120]:51499 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbgIHSZZ (ORCPT ); Tue, 8 Sep 2020 14:25:25 -0400 IronPort-SDR: dG5By9HBXXJoXUGErJ6k/+2MyMDAkdGFigq6MHw5IC1d4AaGwY/WhuE+YiEFL0JTzYmNp+z0O0 rSqFh8q/Su1g== X-IronPort-AV: E=McAfee;i="6000,8403,9738"; a="155602347" X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="155602347" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 11:25:23 -0700 IronPort-SDR: bTS1USQJwqhUAqTZ1mXCWmgKPD1f8ak2tiuGhfZUz3y/kZrFWzwSTM0whGUwwHvZRrXPondA26 9gLrCKJRf3PA== X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="448891489" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.111.239]) ([10.209.111.239]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 11:25:21 -0700 Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: Dave Hansen , Andy Lutomirski Cc: Dave Martin , "H.J. Lu" , 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 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> <32005d57-e51a-7c7f-4e86-612c2ff067f3@intel.com> <46dffdfd-92f8-0f05-6164-945f217b0958@intel.com> From: "Yu, Yu-cheng" Message-ID: <6e1e22a5-1b7f-2783-351e-c8ed2d4893b8@intel.com> Date: Tue, 8 Sep 2020 11:25:20 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/8/2020 10:57 AM, Dave Hansen wrote: > On 9/8/20 10:50 AM, Yu, Yu-cheng wrote: >> What about this: >> >> - Do not add any new syscall or arch_prctl for creating a new shadow stack. >> >> - Add a new arch_prctl that can turn an anonymous mapping to a shadow >> stack mapping. >> >> This allows the application to do whatever is necessary.  It can even >> allow GDB or JIT code to create or fix a call stack. > > Fine with me. But, it's going to effectively be > > arch_prctl(PR_CONVERT_TO_SHS..., addr, len); > > when it could just as easily be: > > madvise(addr, len, MADV_SHSTK...); > > Or a new syscall. The only question in my mind is whether we want to do > something generic that we can use for other similar things in the > future, like: > > madvise2(addr, len, flags, MADV2_SHSTK...); > > I don't really feel strongly about it, though. Could you please share > your logic on why you want a prctl() as opposed to a whole new syscall? > A new syscall is more intrusive, I think. When creating a new shadow stack, the kernel also installs a restore token on the top of the new shadow stack, and it is somewhat x86-specific. So far no other arch's need this. Yes, madvise is better if the kernel only needs to change the mapping. The application itself can create the restore token before calling madvise().