Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2152156pxb; Fri, 5 Feb 2021 10:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAaq4dhxGW8kqnXa9mI19xgzXseZZv4tEDQqjYIPhrH9mlE8AavvyvbzQQ02Gu0zGaLl/r X-Received: by 2002:a17:906:b31a:: with SMTP id n26mr5133266ejz.358.1612548508303; Fri, 05 Feb 2021 10:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612548508; cv=none; d=google.com; s=arc-20160816; b=nDPruqXfOOj3+wlw2zY9owViiE9xuGBU+MSeUa2lPJzVeoARRrDkkREnPWF7FTs8pJ o9oWNKGHq6vkZpqHdxZzZH3WYo/tmvA+8ZSYzrzU78m7As4FTJUxzpfCNPhjEpBDJE/s M/AmufF+UPiTj9T80UYAoLr3w8X0LCgFW9Zn8LIg7M2OBA6d45f9jW98DzcA2QIE9bPq KP1J+YY3YbLcmLqczjzwJ+Kdaai8CwHfToZbPWFm5pPvEWbYEYxmRkaHfzEimc9izWRw YK7glFK9dkVQ61eQ37FPS1ybqbibrPsjS0ZPlE6UfQCWX5i259dov0t2E5eWKXouEdjS rV6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence: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=GZXAqCNx6oIHpHvngSnAJLLh8HupZ5CYRorX72tW0T4=; b=z+AS5fhIAYYCoF8UhBvu2OPmLnjiOXpYEn7yqmdollAYoU5RvQ/B18KIQtGJbLkoRo VcXe43jgUla1Mv84fwmojeHUVR2fmeeifVn1M8Us/YZ4YL9yB3LLQj2Gg9xVd3rqa0Md DIQ/Qo2pPYKdDjT2/UxG4xayPQU8kpFD2yMgrJioGCxGJPMb1MlVfzMMYwM48lb9Enw+ wpfcijg+8snB0t8KgFldkQDd4QjYIfYMXYQYf9KWoSp2wBNMZfWonJNI4qT8nQdjQ2j5 lY7guu18bXoK2qLw4YY3I64fBbh3G5lQ3MToygu4NQiH0bq9RWyeQqEvQybTuOhd4PQp jX0g== 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 v4si5705467edy.79.2021.02.05.10.07.46; Fri, 05 Feb 2021 10:08:28 -0800 (PST) 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 S233317AbhBEQVq (ORCPT + 99 others); Fri, 5 Feb 2021 11:21:46 -0500 Received: from mga18.intel.com ([134.134.136.126]:57360 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230374AbhBEQTC (ORCPT ); Fri, 5 Feb 2021 11:19:02 -0500 IronPort-SDR: xsyp4/dVN4iFhYQCwBJxmKGvLSM7JeNc4F3zqTsXFxy60X9OAfbwrkEbRVCq/ciaqyPZ2r0rcU HtA09LD2jY9A== X-IronPort-AV: E=McAfee;i="6000,8403,9886"; a="169141569" X-IronPort-AV: E=Sophos;i="5.81,155,1610438400"; d="scan'208";a="169141569" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 10:00:31 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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