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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 8C3AEC433E0 for ; Thu, 21 May 2020 23:23:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5111120C56 for ; Thu, 21 May 2020 23:23:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5111120C56 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 D0AB080008; Thu, 21 May 2020 19:23:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBA8880007; Thu, 21 May 2020 19:23:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD02080008; Thu, 21 May 2020 19:23:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id A3DC280007 for ; Thu, 21 May 2020 19:23:36 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5F4DE181AEF1A for ; Thu, 21 May 2020 23:23:36 +0000 (UTC) X-FDA: 76842305232.06.drop70_3c6fe3b2f8418 X-HE-Tag: drop70_3c6fe3b2f8418 X-Filterd-Recvd-Size: 3840 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 May 2020 23:23:35 +0000 (UTC) IronPort-SDR: aCMhGOKUw7YWZhAvmxqm0t+DKXH4yZDD6NmGj5bZW3Ws0ebw6y9iuD/gGgiwwMk7oUcwm2JJyG fsckFKXiGpgA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2020 16:23:33 -0700 IronPort-SDR: f4xi4/kB2AQgpcl64BLOZNV2i3wAVKQNYyyXsv/GfDPb8zyi5+VDOCCE4+3cT6nHjdDQEFajo1 0gU9OmIiO4Og== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,419,1583222400"; d="scan'208";a="268818207" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga006.jf.intel.com with ESMTP; 21 May 2020 16:23:32 -0700 Message-ID: Subject: Re: [RFC PATCH 5/5] selftest/x86: Add CET quick test From: Yu-cheng Yu To: Kees Cook 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 , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang Date: Thu, 21 May 2020 16:23:38 -0700 In-Reply-To: <202005211550.AF0E83BB@keescook> References: <20200521211720.20236-1-yu-cheng.yu@intel.com> <20200521211720.20236-6-yu-cheng.yu@intel.com> <202005211550.AF0E83BB@keescook> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 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 Thu, 2020-05-21 at 16:02 -0700, Kees Cook wrote: > On Thu, May 21, 2020 at 02:17:20PM -0700, Yu-cheng Yu wrote: > > Introduce a quick test to verify shadow stack and IBT are working. > > Cool! :) > > I'd love to see either more of a commit log or more comments in the test > code itself. I had to spend a bit of time trying to understand how the > test was working. (i.e. using ucontext to "reset", using segv handler to > catch some of them, etc.) I have not yet figured out why you need to > send USR1/USR2 for two of them instead of direct calls? Yes, I will work on it. [...] > > + > > +#pragma GCC push_options > > +#pragma GCC optimize ("O0") > > Can you avoid compiler-specific pragmas? (Or verify that Clang also > behaves correctly here?) Maybe it's better to just build the entire file > with -O0 in the Makefile? This file is compiled using -O2 in the makefile. I will see if other ways are possible. [...] > > + > > +void segv_handler(int signum, siginfo_t *si, void *uc) > > +{ > > Does anything in siginfo_t indicate which kind of failure you're > detecting? It'd be nice to verify test_id matches the failure mode being > tested. Yes, there is an si_code for control-protection fault. I will fix this. Agree with your other comments. Thanks, Yu-cheng