Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2896853rwb; Mon, 3 Oct 2022 07:05:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XIr3U8dvkPrIi8iq/cm8/FRkDVeteaN52e02sdDp4HzdULeTrmZ2s+YTiRP0W7iRxg4Ei X-Received: by 2002:a63:1359:0:b0:43c:753:c319 with SMTP id 25-20020a631359000000b0043c0753c319mr19401564pgt.575.1664805922580; Mon, 03 Oct 2022 07:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664805922; cv=none; d=google.com; s=arc-20160816; b=p2wNMaTCQkF3b4N7kWU6UReIXF6ljGJ+5VFIVEwMTag1N7iPstL9ILVfrhcua7DdDm c/gwDMohWiH5eIglIj7+Z+wG5EKFDm+2VRT12GedvfH4c0i1galzTfQkTQmKpMUz/mIA iclu4kOTYDDF+UEerGZR0h+TCnNxFfm3SdQYbcdUh20vRhu5u2qr35h8atPlDpa3LDi3 d5QQIL1wtWIhwDQZgl/ZdiFpAu1krcBug0H/cUZhA8+OCIcCNH+LnLLYUgzjo6YuGjdK N089aBsJZ6oi8HtT+DPS7VTN7YJt7v5/Xt3YAbkQraF/g/ljKBM1HCDGeWHL43ew8XUe qRCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PFa/4AdkKq6pX6Vg322SQhs/6uo42/sbH3bURV6MDUM=; b=udSeqspGg+Dq14FGVxG5HVaocY5eQ7+7SQHPZgjBeCU4IOG2ylWLZAi9UifTk4NgfF k9nOns5HPIaqFwT/UKroEn8EVfgPbXCmQ94QwSkF5ifT5IP2DJ4CtfkrUa8aSneHp5xK IHKsuADv5OP2Z15qcOghxhELFs2aicX8cKLy0mN5Y1gbxj7llVDZWxQkaBPGixgbYdps DN4lf/UIQdWR3cATWjm8Qd7J+GMtSpBORD4GgJFj9bPWn0gVWxKu/OO8XNu9kos57xs/ FcTzOk/87ZU3SUs/84DzTaQkobamYbMVAxMJCTjFXs6kA+ieNx9ULmtrHzGokYQ4DKcr ErdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n2k8FZkw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a63e807000000b0042b804ca112si10718930pgh.785.2022.10.03.07.05.05; Mon, 03 Oct 2022 07:05:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n2k8FZkw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbiJCOC1 (ORCPT + 99 others); Mon, 3 Oct 2022 10:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbiJCOBy (ORCPT ); Mon, 3 Oct 2022 10:01:54 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65E6241991; Mon, 3 Oct 2022 07:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664805700; x=1696341700; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ddjztWhV3UUDkLswvk71WAdPtvy3j53/6CHOczkz9O8=; b=n2k8FZkwu5Iz6fdtgPv6jrnfiUai2yAC5bxjn6Oo+HODZx9NBpG9DrzT GXQ3S9WyI3jM8tAVMpd44c+NCbvfou/MycbIrZkcchH5nR159JBOb8x0t idS3P3k+OEJAtBD+CNvn8rPx9pxlkHviZ0f8vwNArg4pSdSgYVu1wLg1t KAf+bkq9CxBV2d3jMTTgQ7BWLtqSuj6P/byyBGKHKzC28X5XFhKV9ranp f/bbsqC7oyOgUoJjDLihCvK+pqq29GQZEiniJspR95kGKwPLV82IZsHfl wTl55VRol6snT8x0/+JQ23E4FoyRL6mIsR1jPn1uWFGnO/18vuRzcEf07 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10489"; a="302615772" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="302615772" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2022 07:01:26 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10489"; a="798729084" X-IronPort-AV: E=Sophos;i="5.93,365,1654585200"; d="scan'208";a="798729084" Received: from bandrei-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.37.219]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Oct 2022 07:01:12 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 9751D104CE4; Mon, 3 Oct 2022 17:01:09 +0300 (+03) Date: Mon, 3 Oct 2022 17:01:09 +0300 From: "Kirill A . Shutemov" To: Rick Edgecombe Cc: 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" , Weijiang Yang , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, Yu-cheng Yu , Michael Kerrisk Subject: Re: [PATCH v2 07/39] x86/cet: Add user control-protection fault handler Message-ID: <20221003140109.jgn3per7vbthifn5@box.shutemov.name> References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-8-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929222936.14584-8-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 29, 2022 at 03:29:04PM -0700, Rick Edgecombe wrote: > +#else > +static void do_user_control_protection_fault(struct pt_regs *regs, > + unsigned long error_code) > +{ > + WARN_ONCE(1, "User-mode control protection fault with shadow support disabled\n"); Why is this a warning, but runtime check for !X86_FEATURE_IBT and !X86_FEATURE_SHSTK below is fatal? > +} > +#endif > + > +#ifdef CONFIG_X86_KERNEL_IBT > + > +static __ro_after_init bool ibt_fatal = true; > + > +extern void ibt_selftest_ip(void); /* code label defined in asm below */ > > +static void do_kernel_control_protection_fault(struct pt_regs *regs) > +{ > if (unlikely(regs->ip == (unsigned long)&ibt_selftest_ip)) { > regs->ax = 0; > return; > @@ -283,9 +335,29 @@ static int __init ibt_setup(char *str) > } > > __setup("ibt=", ibt_setup); > - > +#else > +static void do_kernel_control_protection_fault(struct pt_regs *regs) > +{ > + WARN_ONCE(1, "Kernel-mode control protection fault with IBT disabled\n"); Ditto. > +} > #endif /* CONFIG_X86_KERNEL_IBT */ > > +#if defined(CONFIG_X86_KERNEL_IBT) || defined(CONFIG_X86_SHADOW_STACK) > +DEFINE_IDTENTRY_ERRORCODE(exc_control_protection) > +{ > + if (!cpu_feature_enabled(X86_FEATURE_IBT) && > + !cpu_feature_enabled(X86_FEATURE_SHSTK)) { > + pr_err("Unexpected #CP\n"); > + BUG(); > + } > + > + if (user_mode(regs)) > + do_user_control_protection_fault(regs, error_code); > + else > + do_kernel_control_protection_fault(regs); > +} > +#endif /* defined(CONFIG_X86_KERNEL_IBT) || defined(CONFIG_X86_SHADOW_STACK) */ > + > #ifdef CONFIG_X86_F00F_BUG > void handle_invalid_op(struct pt_regs *regs) > #else -- Kiryl Shutsemau / Kirill A. Shutemov