Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2803832imm; Wed, 3 Oct 2018 09:23:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV601IswROgFrXFt0ywjd32+Khlqv6DgbbloiY1QZREMN2QLPSy7QGiKZg6XUT9sEvTu+iZkN X-Received: by 2002:a62:5c03:: with SMTP id q3-v6mr2443523pfb.182.1538583781999; Wed, 03 Oct 2018 09:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538583781; cv=none; d=google.com; s=arc-20160816; b=hpKOelnCzrAqmxHxWkPThVShAtXp7JZpt241/BrHwRPWg0CRLjvcp0X1hA4kQVgdfO L6Up3HrgdvYn0UyFrPthIvoyqCy+hRRM6j5n4YXC2pv3/Vfpb1RBC+jq7ACZH5Vi6Aca hMvvSn3k2u5LDmMzPnSaY0NCFQaBLGtKwMx39KcmWjxvGkiv/OG3dED8wf3fiCt6aiA9 hd2oXPqVRsY/vljbYWdPNhN9dVVJ5bHcYvgnOqQpQDRM+2j9qnbpT+a3WBzI+f6XWTzW oYx4E90I06GtiYNoKwx6JnKbTj92Gr5eibrWLarss2uAe5JcmD45F7OFa+vVQ+kcNvbB jIGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=XzGLXoLkxKlaqOsFLBJ/xGXpPwRjRXzPIeCzZ/p4WYY=; b=GogfSsrAzM1Xu36moeV7Fe0wjF40itraLufNSIZsdQ84ncJVfRvfmOCiiCEOyDumWB p16Jc3Ej0f6cgxBHGeAjALQvFjoFND5cJrbWIamQp3ZsdvI4Jbh71HJUL/obAb/WWyz0 LA0GmzHA28+V3HfLS9M4vAwqpRNlSlh8aucrKPnZPfRH5wRu34PRqu7Yl9PXZzja/A92 2VHlWTD8rR8lL5bL6XYQaNlyh+gVsUP0xNN1nlzU31m3m2dEqvKSge9F8LYwxuRbHNZh 7833w3cWMeichEbs5oo7QU+NmpbpqksbXM/neaLHcD0c87/XsNsVZSuh3d+y8t+zNZi/ nzvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si1949650pll.360.2018.10.03.09.22.32; Wed, 03 Oct 2018 09:23:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727132AbeJCXKu (ORCPT + 99 others); Wed, 3 Oct 2018 19:10:50 -0400 Received: from mga02.intel.com ([134.134.136.20]:9897 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726950AbeJCXKu (ORCPT ); Wed, 3 Oct 2018 19:10:50 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2018 09:21:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,336,1534834800"; d="scan'208";a="91865603" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga002.fm.intel.com with ESMTP; 03 Oct 2018 09:16:14 -0700 Message-ID: <9c93e864e5996862cb5fdb66d4140faa634cbc47.camel@intel.com> Subject: Re: [RFC PATCH v4 06/27] x86/cet: Control protection exception handler From: Yu-cheng Yu To: Eugene Syromiatnikov 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 , 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 Date: Wed, 03 Oct 2018 09:11:34 -0700 In-Reply-To: <20181003103959.GB7111@asgard.redhat.com> References: <20180921150351.20898-1-yu-cheng.yu@intel.com> <20180921150351.20898-7-yu-cheng.yu@intel.com> <20181003103959.GB7111@asgard.redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-10-03 at 12:39 +0200, Eugene Syromiatnikov wrote: > On Fri, Sep 21, 2018 at 08:03:30AM -0700, Yu-cheng Yu wrote: > > +dotraplinkage void > > +do_control_protection(struct pt_regs *regs, long error_code) > > +{ > > + struct task_struct *tsk; > > + > > + RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU"); > > + if (notify_die(DIE_TRAP, "control protection fault", regs, > > + error_code, X86_TRAP_CP, SIGSEGV) == NOTIFY_STOP) > > + return; > > + cond_local_irq_enable(regs); > > + > > + if (!user_mode(regs)) > > + die("kernel control protection fault", regs, error_code); > > + > > + if (!static_cpu_has(X86_FEATURE_SHSTK) && > > + !static_cpu_has(X86_FEATURE_IBT)) > > + WARN_ONCE(1, "CET is disabled but got control " > > + "protection fault\n"); > > + > > + tsk = current; > > + tsk->thread.error_code = error_code; > > + tsk->thread.trap_nr = X86_TRAP_CP; > > + > > + if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) && > > + printk_ratelimit()) { > > + unsigned int max_err; > > + > > + max_err = ARRAY_SIZE(control_protection_err) - 1; > > + if ((error_code < 0) || (error_code > max_err)) > > + error_code = 0; > > + pr_info("%s[%d] control protection ip:%lx sp:%lx > > error:%lx(%s)", > > + tsk->comm, task_pid_nr(tsk), > > + regs->ip, regs->sp, error_code, > > + control_protection_err[error_code]); > > + print_vma_addr(KERN_CONT " in ", regs->ip); > > + pr_cont("\n"); > > + } > > + > > + force_sig_info(SIGSEGV, SEND_SIG_PRIV, tsk); > > That way, no information is provided to userspace (both application and > debugger), which is rather unfortunate. It would be nice if a new SEGV_* > code was added at least, and CET error (with error code constant provided > in UAPI) is passed via si_errno. (Having ip/sp/*ssp would be even > better, but I'm not exactly sure about ramifications of providing this > kind of information to user space). Ok, I will add that. Yu-cheng