Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp673546pxa; Thu, 27 Aug 2020 12:35:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2S8I88+C20crU81J0P+M9jTH7L1RVLCA574aQCEm5jB7LQkQJs07ogGa2aoOcelZMaQ/N X-Received: by 2002:a05:6402:84e:: with SMTP id b14mr20942891edz.115.1598556904526; Thu, 27 Aug 2020 12:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598556904; cv=none; d=google.com; s=arc-20160816; b=pWT/zbXc7S0M91OmLlFeCzN1FrJfdDzj6erP+rbVQNphVsfyxKNrgkxEAof7OfBx8O gCRTkA387tgZcf2e+VW4J44H4oLhFys9laA3w0tYbL5B8NmdzDu/yp9fafhAuOmUGcyJ yfuvDXiQ377DOkneichWpX8tvWixZXuF+QkzbjwtomZOlKmjYdCJ/GsvvM4Ib6eB8+h/ rNFMN1+oFeiDNGcdvameKQm6SWw2Gy3ZEi0TYt2iqLtfzu4XO1lyuABP0Jnl1ZDB7s6u yVUdjIqzrDA5sOxwjnslfpu2ZwzYoo07WFotP6oASUTBxur6OJ7m7CO6nmCM/h7hkUUE r5ww== 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=Mq4oSbSM9mXR04zEvCnznGpoRwD1YTjl0cO5bjuWhwM=; b=SA1sXHF+V76MDedfsMbubZIwVpV4/6JdpMWXanKcAi2J4aC1AYNstpUMLBWpxEvwV/ lMrKFfwfv0SkL7IBYegrSZ4viU+L6tXvZu2zsyj7wBFrh17BtZ9bHf/pfyjoNn3Ir+eu 20WqTYU7CqadMYTkt5rwlkW2f4VOqfN8kXZNjsgC/8nH9b9Rrgslt+SmprTt+Vha2+62 2Dd1AqioGC3MNYFuuIo0XDz/CiLhmxDmtrkk8er+33gnaLybjolLlzFkDUOi0i74p/O8 s4ATD4GFy2KZv0zGkj8u8knp2v3GqK2B2QxgHfUepAraHLQD8xsWv8FECUA0+d77xIum J26A== 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 i2si2098215ejp.500.2020.08.27.12.34.41; Thu, 27 Aug 2020 12:35:04 -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 S1726706AbgH0Td7 (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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