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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,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 9C38DC433E0 for ; Mon, 1 Feb 2021 23:05:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0960964EAC for ; Mon, 1 Feb 2021 23:05:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0960964EAC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 484556B0005; Mon, 1 Feb 2021 18:05:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4345D6B0006; Mon, 1 Feb 2021 18:05:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 321CB6B006E; Mon, 1 Feb 2021 18:05:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 1DD556B0005 for ; Mon, 1 Feb 2021 18:05:26 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DEE001EE6 for ; Mon, 1 Feb 2021 23:05:25 +0000 (UTC) X-FDA: 77771232210.21.patch11_5d0ea8c275c6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id B8B7A180442C0 for ; Mon, 1 Feb 2021 23:05:25 +0000 (UTC) X-HE-Tag: patch11_5d0ea8c275c6 X-Filterd-Recvd-Size: 4900 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 23:05:24 +0000 (UTC) IronPort-SDR: UztRH9E1ldFczKo+c38X+RihcBtevXduMbPi+wHl0TD3fyb0j3evaShx1xGdA6/hHaKskpH947 iguNhxMH34NA== X-IronPort-AV: E=McAfee;i="6000,8403,9882"; a="168446676" X-IronPort-AV: E=Sophos;i="5.79,393,1602572400"; d="scan'208";a="168446676" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 15:05:20 -0800 IronPort-SDR: Sk7ncts+73AGCaMMi91HA/0PjCNQTioKvWsv3VXI82btE/75sAijj26QN65AICsr5CwY/e+CNw iUGkiuQO9LZw== X-IronPort-AV: E=Sophos;i="5.79,393,1602572400"; d="scan'208";a="358781936" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.212.112.229]) ([10.212.112.229]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 15:05:17 -0800 Subject: Re: [PATCH v18 05/25] x86/fpu/xstate: Introduce CET MSR and XSAVES supervisor states To: Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , 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 , Andrew Cooper References: <20210127212524.10188-1-yu-cheng.yu@intel.com> <20210127212524.10188-6-yu-cheng.yu@intel.com> <7793b36e-6386-3f2e-36ca-b7ca988a88c9@intel.com> <43f264df-2f3a-ea4c-c737-85cdc6714bd8@intel.com> <0a5a80c0-afc7-5f91-9e28-a300e30f1ab3@intel.com> <465836bd-9c80-fed9-d9af-89275ff810eb@intel.com> From: "Yu, Yu-cheng" Message-ID: Date: Mon, 1 Feb 2021 15:05:16 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2/1/2021 2:59 PM, Dave Hansen wrote: > On 2/1/21 2:43 PM, Yu, Yu-cheng wrote: >> On 1/29/2021 2:53 PM, Dave Hansen wrote: >>> On 1/29/21 2:35 PM, Yu, Yu-cheng wrote: >>>>> Andy Cooper just mentioned on IRC about this nugget in the spec: >>>>> >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0XRSTORS on CET state will do reserve= d bit and canonicality >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0checks on the state in similar manne= r as done by the WRMSR to >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0these state elements. >>>>> >>>>> We're using copy_kernel_to_xregs_err(), so the #GP *should* be OK. >>>>> Could we prove this out in practice, please? >>>>>> >>>> Do we want to verify that setting reserved bits in CET XSAVES states >>>> triggers GP?=C2=A0 Then, yes, I just verified it again.=C2=A0 Thanks= for >>>> reminding.=C2=A0 Do we have any particular case relating to this? >>> >>> I want to confirm that it triggers #GP and kills userspace without th= e >>> kernel WARN'ing or otherwise being visibly unhappy. >> >> For sigreturn, shadow stack pointer is checked against its restore tok= en >> and must be smaller than TASK_SIZE_MAX.=C2=A0 Sigreturn cannot set any >> MSR_IA32_U_CET reserved bits. >=20 > That would be nice to at least allude to in the changelog or comments. >=20 Ok. >>> What about the return-to-userspace path after a ptracer writes conten= t >>> to the CET fields?=C2=A0=C2=A0 I don't see the same tolerance for err= ors in >>> __fpregs_load_activate(), for instance. >>> >> >> Good thought.=C2=A0 I have not sent out my revised PTRACE patch, but v= alues >> from user will be checked for valid address and reserved bits. >=20 > Wait a sec... What about *THIS* series? Will *THIS* series give us > oopses when userspace blasts a new XSAVE buffer in with NT_X86_XSTATE? >=20 Fortunately, CET states are supervisor states. NT_x86_XSTATE has only=20 user states.