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,USER_AGENT_SANE_1 autolearn=ham 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 CAD1BC433E6 for ; Wed, 24 Feb 2021 16:45:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2761464F07 for ; Wed, 24 Feb 2021 16:45:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2761464F07 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 391C66B006C; Wed, 24 Feb 2021 11:45:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 31B806B0006; Wed, 24 Feb 2021 11:45:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20AF76B006C; Wed, 24 Feb 2021 11:45:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 0A2FB6B0005 for ; Wed, 24 Feb 2021 11:45:00 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C3756362C for ; Wed, 24 Feb 2021 16:44:59 +0000 (UTC) X-FDA: 77853735918.11.A112154 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf14.hostedemail.com (Postfix) with ESMTP id BD92AC0007C4 for ; Wed, 24 Feb 2021 16:44:42 +0000 (UTC) IronPort-SDR: 1ATzJQ5PjuBYZhuwwo9WtXjCK9KqAg4dEtdqMIMgnzdxX482eevpltlHGEgois0EIZqyHkfAak 9XCT52j8IqXA== X-IronPort-AV: E=McAfee;i="6000,8403,9905"; a="270193927" X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="270193927" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2021 08:44:47 -0800 IronPort-SDR: cO6tUP/okEbGeERP7ncSscGvWFoqHF2wSdnLMFWdPr4Y3w9ngVkS4ODpHA5fLWv9bzRuj4JBHJ y3psIq07rtLw== X-IronPort-AV: E=Sophos;i="5.81,203,1610438400"; d="scan'208";a="515715838" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.212.35.50]) ([10.212.35.50]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2021 08:44:45 -0800 Subject: Re: [PATCH v21 06/26] 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 , Haitao Huang , Michael Kerrisk References: <20210217222730.15819-1-yu-cheng.yu@intel.com> <20210217222730.15819-7-yu-cheng.yu@intel.com> <20210224161343.GE20344@zn.tnic> From: "Yu, Yu-cheng" Message-ID: <32ac05ef-b50b-c947-095d-bc31a42947a3@intel.com> Date: Wed, 24 Feb 2021 08:44:45 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210224161343.GE20344@zn.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BD92AC0007C4 X-Stat-Signature: 98b3uidt5x5ssddm88hmuzciqcxbt11d Received-SPF: none (intel.com>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=mga05.intel.com; client-ip=192.55.52.43 X-HE-DKIM-Result: none/none X-HE-Tag: 1614185082-321439 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/24/2021 8:13 AM, Borislav Petkov wrote: > On Wed, Feb 17, 2021 at 02:27:10PM -0800, Yu-cheng Yu wrote: >> +/* >> + * When a control protection exception occurs, send a signal to the responsible >> + * application. Currently, control protection is only enabled for user mode. >> + * This exception should not come from kernel mode. >> + */ >> +DEFINE_IDTENTRY_ERRORCODE(exc_control_protection) >> +{ >> + static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, >> + DEFAULT_RATELIMIT_BURST); [...] >> + >> + rdmsrl(MSR_IA32_PL3_SSP, ssp); >> + pr_emerg("%s[%d] control protection ip:%lx sp:%lx ssp:%lx error:%lx(%s)", >> + tsk->comm, task_pid_nr(tsk), >> + regs->ip, regs->sp, ssp, error_code, >> + control_protection_err[err]); >> + print_vma_addr(KERN_CONT " in ", regs->ip); >> + pr_cont("\n"); >> + } >> + >> + force_sig_fault(SIGSEGV, SEGV_CPERR, >> + (void __user *)uprobe_get_trap_addr(regs)); > > Why is this calling an uprobes function? > I will change it to error_get_trap_addr(). > Also, do not break that line even if it is longer than 80. > >> + cond_local_irq_disable(regs); >> +} >> +#endif >> + >> static bool do_int3(struct pt_regs *regs) >> { >> int res; >> diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h >> index d2597000407a..1c2ea91284a0 100644 >> --- a/include/uapi/asm-generic/siginfo.h >> +++ b/include/uapi/asm-generic/siginfo.h >> @@ -231,7 +231,8 @@ typedef struct siginfo { >> #define SEGV_ADIPERR 7 /* Precise MCD exception */ >> #define SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */ >> #define SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ >> -#define NSIGSEGV 9 >> +#define SEGV_CPERR 10 /* Control protection fault */ >> +#define NSIGSEGV 10 > > I still don't see the patch adding this to the manpage of sigaction(2). > > There's a git repo there: https://www.kernel.org/doc/man-pages/ > > and I'm pretty sure Michael takes patches. > I will send a patch. -- Yu-cheng