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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 A5065C47085 for ; Tue, 25 May 2021 15:05:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CF6C61430 for ; Tue, 25 May 2021 15:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230366AbhEYPGs (ORCPT ); Tue, 25 May 2021 11:06:48 -0400 Received: from mga11.intel.com ([192.55.52.93]:59785 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230328AbhEYPGn (ORCPT ); Tue, 25 May 2021 11:06:43 -0400 IronPort-SDR: hXHyP6KyFe3U7pgnfUaGTF74m/1IeJiG6ZJ4A3ZszbBTdDEcPmOuhvZvWrtzFA1GUkFly8and+ KXuioAXVeI5Q== X-IronPort-AV: E=McAfee;i="6200,9189,9995"; a="199159594" X-IronPort-AV: E=Sophos;i="5.82,328,1613462400"; d="scan'208";a="199159594" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2021 08:04:47 -0700 IronPort-SDR: RuF2zL360uQQpbZacdqVD52FfknkoSoqg8+GcER8bysyyUM4dXtqcD7vEBnH5wl0vntn3KjQw8 RjJ6I1ynDyYg== X-IronPort-AV: E=Sophos;i="5.82,328,1613462400"; d="scan'208";a="414061811" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.133.101]) ([10.209.133.101]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2021 08:04:44 -0700 Subject: Re: [PATCH v27 24/31] x86/cet/shstk: Handle thread shadow stack To: Andy Lutomirski Cc: 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 , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang References: <20210521221211.29077-1-yu-cheng.yu@intel.com> <20210521221211.29077-25-yu-cheng.yu@intel.com> From: "Yu, Yu-cheng" Message-ID: Date: Tue, 25 May 2021 08:04:43 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On 5/22/2021 4:39 PM, Andy Lutomirski wrote: > On Fri, May 21, 2021 at 3:14 PM Yu-cheng Yu wrote: >> diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c >> index 5ea2b494e9f9..8e5f772181b9 100644 >> --- a/arch/x86/kernel/shstk.c >> +++ b/arch/x86/kernel/shstk.c >> @@ -71,6 +71,53 @@ int shstk_setup(void) >> return 0; >> } >> >> +int shstk_alloc_thread_stack(struct task_struct *tsk, unsigned long clone_flags, >> + unsigned long stack_size) >> +{ > > ... > >> + state = get_xsave_addr(&tsk->thread.fpu.state.xsave, XFEATURE_CET_USER); >> + if (!state) >> + return -EINVAL; >> + > > The get_xsave_addr() API is horrible, and we already have one > egregiously buggy instance in the kernel. Let's not add another > dubious use case. > > If state == NULL, this means that CET_USER is in its init state. > CET_USER in the init state should behave identically regardless of > whether XINUSE[CET_USER] is set. Can you please adjust this code > accordingly? > I will work on that. Thanks, Yu-cheng