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.6 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 82F7BC433DB for ; Fri, 5 Feb 2021 18:00:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B074D64E2E for ; Fri, 5 Feb 2021 18:00:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B074D64E2E 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 D91136B0071; Fri, 5 Feb 2021 13:00:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D40126B0073; Fri, 5 Feb 2021 13:00:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C57636B0074; Fri, 5 Feb 2021 13:00:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id B15E86B0071 for ; Fri, 5 Feb 2021 13:00:56 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 110A7362E for ; Fri, 5 Feb 2021 18:00:56 +0000 (UTC) X-FDA: 77784980112.08.jewel03_4f08b2a275e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 2B1661819E623 for ; Fri, 5 Feb 2021 18:00:55 +0000 (UTC) X-HE-Tag: jewel03_4f08b2a275e6 X-Filterd-Recvd-Size: 4133 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 18:00:53 +0000 (UTC) IronPort-SDR: wG0w8sstPAmXoBW3u5KTstr9z0dlIS3vIg2q61Pwf+Nod0oL1KLcl+Qkmlv8EKWsWZEjNvmzED VjySP1Qmv3Tw== X-IronPort-AV: E=McAfee;i="6000,8403,9885"; a="161220620" X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="161220620" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 10:00:32 -0800 IronPort-SDR: flCR177ho8xnj0bLEwOjvZcs9Zedun0/6v6kqhP8zw+5aFJY/km3RD+12kLLIkQ1hijsUSVCTq zK9mt3DZSzxA== X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="434549248" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.212.95.7]) ([10.212.95.7]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 10:00:24 -0800 Subject: Re: [PATCH v19 06/25] x86/cet: Add control-protection fault handler To: Borislav Petkov 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 , 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 , Michael Kerrisk References: <20210203225547.32221-1-yu-cheng.yu@intel.com> <20210203225547.32221-7-yu-cheng.yu@intel.com> <20210205135927.GH17488@zn.tnic> From: "Yu, Yu-cheng" Message-ID: <2d829cba-784e-635a-e0c5-a7b334fa9b40@intel.com> Date: Fri, 5 Feb 2021 10:00:21 -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: <20210205135927.GH17488@zn.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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/5/2021 5:59 AM, Borislav Petkov wrote: > On Wed, Feb 03, 2021 at 02:55:28PM -0800, Yu-cheng Yu wrote: >> +DEFINE_IDTENTRY_ERRORCODE(exc_control_protection) >> +{ >> + static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, >> + DEFAULT_RATELIMIT_BURST); >> + struct task_struct *tsk; >> + >> + if (!user_mode(regs)) { >> + pr_emerg("PANIC: unexpected kernel control protection fault\n"); >> + die("kernel control protection fault", regs, error_code); >> + panic("Machine halted."); >> + } >> + >> + cond_local_irq_enable(regs); >> + >> + if (!boot_cpu_has(X86_FEATURE_CET)) >> + WARN_ONCE(1, "Control protection fault with CET support disabled\n"); >> + >> + tsk = current; >> + tsk->thread.error_code = error_code; >> + tsk->thread.trap_nr = X86_TRAP_CP; >> + >> + if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) && >> + __ratelimit(&rs)) { > > I can't find it written down anywhere why the ratelimiting is needed at > all? > The ratelimit here is only for #CP, and its rate is not counted together with other types of faults. If a task gets here, it will exit. The only condition the ratelimit will trigger is when multiple tasks hit #CP at once, which is unlikely. Are you suggesting that we do not need the ratelimit here? Thanks! -- Yu-cheng