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=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 3E326C433E1 for ; Thu, 27 Aug 2020 19:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2344020714 for ; Thu, 27 Aug 2020 19:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726246AbgH0Td7 (ORCPT ); Thu, 27 Aug 2020 15:33:59 -0400 Received: from mga01.intel.com ([192.55.52.88]:43719 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbgH0Td7 (ORCPT ); Thu, 27 Aug 2020 15:33:59 -0400 IronPort-SDR: +r6fOacdljr8O+XW1cTad84jUIE7pZNHKkJaT1uSMWl6eHa21H0b0ytE/AM0IBxKmAXdvx7cBV bfUPu2xS99zg== X-IronPort-AV: E=McAfee;i="6000,8403,9726"; a="174603365" X-IronPort-AV: E=Sophos;i="5.76,360,1592895600"; d="scan'208";a="174603365" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2020 12:33:58 -0700 IronPort-SDR: OPISa7thH3ifFl2p+owBLIitIqmZbW/hl+EP5wSwNVukJNFhzMv4wB+31X5KIa136wfknEKV7P 7teTxH4ipSsQ== X-IronPort-AV: E=Sophos;i="5.76,360,1592895600"; d="scan'208";a="500229981" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.213.179.54]) ([10.213.179.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2020 12:33:57 -0700 Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: Andy Lutomirski Cc: Florian Weimer , "H.J. Lu" , Dave Martin , Dave Hansen , Andy Lutomirski , 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: <4BDFD364-798C-4537-A88E-F94F101F524B@amacapital.net> From: "Yu, Yu-cheng" Message-ID: Date: Thu, 27 Aug 2020 12:33:56 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <4BDFD364-798C-4537-A88E-F94F101F524B@amacapital.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-arch-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On 8/27/2020 11:56 AM, Andy Lutomirski wrote: > > >> On Aug 27, 2020, at 11:13 AM, Yu, Yu-cheng wrote: >> >> On 8/27/2020 6:36 AM, Florian Weimer wrote: >>> * H. J. Lu: >>>>> On Thu, Aug 27, 2020 at 6:19 AM Florian Weimer wrote: >>>>>> >>>>>> * Dave Martin: >>>>>> >>>>>>> You're right that this has implications: for i386, libc probably pulls >>>>>>> more arguments off the stack than are really there in some situations. >>>>>>> This isn't a new problem though. There are already generic prctls with >>>>>>> fewer than 4 args that are used on x86. >>>>>> >>>>>> As originally posted, glibc prctl would have to know that it has to pull >>>>>> an u64 argument off the argument list for ARCH_X86_CET_DISABLE. But >>>>>> then the u64 argument is a problem for arch_prctl as well. >>>>>> >>>> >>>> Argument of ARCH_X86_CET_DISABLE is int and passed in register. >>> The commit message and the C source say otherwise, I think (not sure >>> about the C source, not a kernel hacker). >> >> H.J. Lu suggested that we fix x86 arch_prctl() to take four arguments, and then keep MMAP_SHSTK as an arch_prctl(). Because now the map flags and size are all in registers, this also solves problems being pointed out earlier. Without a wrapper, the shadow stack mmap call (from user space) will be: >> >> syscall(_NR_arch_prctl, ARCH_X86_CET_MMAP_SHSTK, size, MAP_32BIT). > > I admit I don’t see a show stopping technical reason we can’t add arguments to an existing syscall, but I’m pretty sure it’s unprecedented, and it doesn’t seem like a good idea. > There are nine existing arch_prctl calls now. If the concern is the extra new arguments getting misused, we can mask them out for the existing calls. Otherwise, I have not seen anything that can break. Yu-cheng