Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp146104imm; Thu, 12 Jul 2018 16:04:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpez+Pdg/Z0L91HBQNYC6rtt0k1/tCryIvF7BclD1Yf9R0ZYLh/P72a6C3ifSm9S4aGvfQON X-Received: by 2002:a63:f18:: with SMTP id e24-v6mr3828956pgl.320.1531436667054; Thu, 12 Jul 2018 16:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531436667; cv=none; d=google.com; s=arc-20160816; b=T0tt76NBFNvuAgpgm6j6DvdvOxtOk6cVAf0QUBqmhOTY3DC3uffdSK2+k/+XDkl5DP kzh7NnWczdsIsXlWeKnfGnF4MCmoBng7QZuRQT3pgy59Zl5RcVn8JjerUfxa0MnVpBDU Z1TKGC582vjoSSlYhiRit2XOM7pp/PgqOd51cBQbaadM40mZrONj06aTHUopBPoIipHL BtEPzB+gIyuWCIdFMH6zAgFWRGGVyRS9ksTm5CPyuLhSwPOh6EYe67ZqjFP4i1Qa1LlH kbIrKy4aKhfMaDqhEikShxZiGR4XHUKkkfrZu447FNEE6bdHjs4F8abP43rBB2eZ/GrW ESGA== 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:to:from:subject:message-id :arc-authentication-results; bh=il6dYQFhqP+j1K2OzsB6Sj8Ol6VfcF4LS2+anoTkI/w=; b=R+QGWV+NGjN7VFSbrXuGbfXTk1TF8YPksqj947oMRP+8kAdCpocw1dc964yXqYKu6J gBbOC5z4Ia07Zi0hi/GobYGVil35ctXKFWxFN/nXhUEi1ZnK9sBwpPNYwnGnjjLsRJo1 ZzGMu6j5qaANJEWJb6MAgmPHqbr8l5Atcp6mLabHEiU2UlXgpzf2NDmYWzaezaQJpY1j j2jeKJ9TjJSTCTPhCg9qTe4iGQzRgO0r+r0G/u7+MALA4nHIB+htFrha3Yy5/KE0t1kM dPgO5uFxlkeTumj+FJRzBTJO4Edknoryoc+lerQcrpDJpyKcBwlmj3Ex9UAkvInPrGqv Vbog== 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 z63-v6si23870780pfi.214.2018.07.12.16.04.11; Thu, 12 Jul 2018 16:04:27 -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 S2387527AbeGLXPY (ORCPT + 99 others); Thu, 12 Jul 2018 19:15:24 -0400 Received: from mga18.intel.com ([134.134.136.126]:10312 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732493AbeGLXPY (ORCPT ); Thu, 12 Jul 2018 19:15:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2018 16:03:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,345,1526367600"; d="scan'208";a="66542265" Received: from 2b52.sc.intel.com ([143.183.136.52]) by orsmga003.jf.intel.com with ESMTP; 12 Jul 2018 16:03:38 -0700 Message-ID: <1531436398.2965.18.camel@intel.com> Subject: Re: [RFC PATCH v2 18/27] x86/cet/shstk: Introduce WRUSS instruction From: Yu-cheng Yu To: Dave Hansen , 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 , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , "Ravi V. Shankar" , Vedvyas Shanbhogue Date: Thu, 12 Jul 2018 15:59:58 -0700 In-Reply-To: References: <20180710222639.8241-1-yu-cheng.yu@intel.com> <20180710222639.8241-19-yu-cheng.yu@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-07-10 at 16:48 -0700, Dave Hansen wrote: > > > > +/* > > + * WRUSS is a kernel instrcution and but writes to user > > + * shadow stack memory.  When a fault occurs, both > > + * X86_PF_USER and X86_PF_SHSTK are set. > > + */ > > +static int is_wruss(struct pt_regs *regs, unsigned long error_code) > > +{ > > + return (((error_code & (X86_PF_USER | X86_PF_SHSTK)) == > > + (X86_PF_USER | X86_PF_SHSTK)) && !user_mode(regs)); > > +} > I thought X86_PF_USER was set based on the mode in which the fault > occurred.  Does this mean that the architecture of this bit is different > now? Yes. > That seems like something we need to call out if so.  It also means we > need to update the SDM because some of the text is wrong. It needs to mention the WRUSS case. > > > > >  static void > >  show_fault_oops(struct pt_regs *regs, unsigned long error_code, > >   unsigned long address) > > @@ -848,7 +859,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, > >   struct task_struct *tsk = current; > >   > >   /* User mode accesses just cause a SIGSEGV */ > > - if (error_code & X86_PF_USER) { > > + if ((error_code & X86_PF_USER) && !is_wruss(regs, error_code)) { > >   /* > >    * It's possible to have interrupts off here: > >    */ > This needs commenting about why is_wruss() is special. Ok.