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 96558C433E2 for ; Fri, 22 May 2020 18:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 818DC206F6 for ; Fri, 22 May 2020 18:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730869AbgEVSO2 (ORCPT ); Fri, 22 May 2020 14:14:28 -0400 Received: from mga02.intel.com ([134.134.136.20]:16615 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726373AbgEVSO1 (ORCPT ); Fri, 22 May 2020 14:14:27 -0400 IronPort-SDR: zs3tfRokZdk+ATDN2LSr9q1q9gdwxRkgbeIk3iSJCFvAaFKmBJlIX6TUX3VB8qwKHdIPJK0W06 9Uk66Zkeie2g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 11:14:27 -0700 IronPort-SDR: aNLuuOBLKjBvftxy5qfpXMw6yOA2vhLrKyOrglZqkDbI7Hj9AGX9tpQ4FYAEQKDJvCsu3KCEid u8YjDgm1J7Hw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,422,1583222400"; d="scan'208";a="467369306" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga006.fm.intel.com with ESMTP; 22 May 2020 11:14:26 -0700 Message-ID: <676f710b9747b091783aed38fb07259af3ca5b43.camel@intel.com> Subject: Re: [PATCH v10 26/26] x86/cet/shstk: Add arch_prctl functions for shadow stack From: Yu-cheng Yu To: Eugene Syromiatnikov Cc: Kees Cook , 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 , 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 , mtk.manpages@gmail.com Date: Fri, 22 May 2020 11:13:24 -0700 In-Reply-To: <20200522172934.GI12341@asgard.redhat.com> References: <20200429220732.31602-1-yu-cheng.yu@intel.com> <20200429220732.31602-27-yu-cheng.yu@intel.com> <202005211528.A12B4AD@keescook> <20200522172934.GI12341@asgard.redhat.com> 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-05-22 at 19:29 +0200, Eugene Syromiatnikov wrote: > On Fri, May 22, 2020 at 10:17:43AM -0700, Yu-cheng Yu wrote: > > On Thu, 2020-05-21 at 15:42 -0700, Kees Cook wrote: > > > On Wed, Apr 29, 2020 at 03:07:32PM -0700, Yu-cheng Yu wrote: > > [...] > > > > + > > > > +int prctl_cet(int option, u64 arg2) > > > > +{ > > > > + struct cet_status *cet; > > > > + > > > > + if (!IS_ENABLED(CONFIG_X86_INTEL_CET)) > > > > + return -EINVAL; > > > > > > Using -EINVAL here means userspace can't tell the difference between an > > > old kernel and a kernel not built with CONFIG_X86_INTEL_CET. Perhaps > > > -ENOTSUPP? > > > > Looked into this. The kernel and GLIBC are not in sync. So maybe we still use > > EINVAL here? > > > > Yu-cheng > > > > > > > > In kernel: > > ---------- > > > > #define EOPNOTSUPP 95 > > #define ENOTSUPP 524 > > > > In GLIBC: > > --------- > > > > printf("ENOTSUP=%d\n", ENOTSUP); > > printf("EOPNOTSUPP=%d\n", EOPNOTSUPP); > > printf("%s=524\n", strerror(524)); > > > > ENOTSUP=95 > > EOPNOTSUPP=95 > > Unknown error 524=524 > > EOPNOTSUPP/ENOTSUP/ENOTSUPP is actually a mess, it's summarized recently > by Michael Kerrisk[1]. From the kernel's point of view, I think it > would be reasonable to return EOPNOTSUPP, and expect that the userspace > would use ENOTSUP to match against it. Ok, use EOPNOTSUPP and add a comment why. Yu-cheng From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu-cheng Yu Subject: Re: [PATCH v10 26/26] x86/cet/shstk: Add arch_prctl functions for shadow stack Date: Fri, 22 May 2020 11:13:24 -0700 Message-ID: <676f710b9747b091783aed38fb07259af3ca5b43.camel@intel.com> References: <20200429220732.31602-1-yu-cheng.yu@intel.com> <20200429220732.31602-27-yu-cheng.yu@intel.com> <202005211528.A12B4AD@keescook> <20200522172934.GI12341@asgard.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20200522172934.GI12341@asgard.redhat.com> Sender: linux-doc-owner@vger.kernel.org To: Eugene Syromiatnikov Cc: Kees Cook , 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 , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov List-Id: linux-arch.vger.kernel.org On Fri, 2020-05-22 at 19:29 +0200, Eugene Syromiatnikov wrote: > On Fri, May 22, 2020 at 10:17:43AM -0700, Yu-cheng Yu wrote: > > On Thu, 2020-05-21 at 15:42 -0700, Kees Cook wrote: > > > On Wed, Apr 29, 2020 at 03:07:32PM -0700, Yu-cheng Yu wrote: > > [...] > > > > + > > > > +int prctl_cet(int option, u64 arg2) > > > > +{ > > > > + struct cet_status *cet; > > > > + > > > > + if (!IS_ENABLED(CONFIG_X86_INTEL_CET)) > > > > + return -EINVAL; > > > > > > Using -EINVAL here means userspace can't tell the difference between an > > > old kernel and a kernel not built with CONFIG_X86_INTEL_CET. Perhaps > > > -ENOTSUPP? > > > > Looked into this. The kernel and GLIBC are not in sync. So maybe we still use > > EINVAL here? > > > > Yu-cheng > > > > > > > > In kernel: > > ---------- > > > > #define EOPNOTSUPP 95 > > #define ENOTSUPP 524 > > > > In GLIBC: > > --------- > > > > printf("ENOTSUP=%d\n", ENOTSUP); > > printf("EOPNOTSUPP=%d\n", EOPNOTSUPP); > > printf("%s=524\n", strerror(524)); > > > > ENOTSUP=95 > > EOPNOTSUPP=95 > > Unknown error 524=524 > > EOPNOTSUPP/ENOTSUP/ENOTSUPP is actually a mess, it's summarized recently > by Michael Kerrisk[1]. From the kernel's point of view, I think it > would be reasonable to return EOPNOTSUPP, and expect that the userspace > would use ENOTSUP to match against it. Ok, use EOPNOTSUPP and add a comment why. Yu-cheng 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 3E8B7C433E0 for ; Fri, 22 May 2020 18:14:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 10AAC206F6 for ; Fri, 22 May 2020 18:14:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10AAC206F6 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 A294580008; Fri, 22 May 2020 14:14:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B35380007; Fri, 22 May 2020 14:14:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A2D380008; Fri, 22 May 2020 14:14:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 702CF80007 for ; Fri, 22 May 2020 14:14:29 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 353A6180AD80F for ; Fri, 22 May 2020 18:14:29 +0000 (UTC) X-FDA: 76845155058.23.lip84_270ce320ddd08 X-HE-Tag: lip84_270ce320ddd08 X-Filterd-Recvd-Size: 4119 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 May 2020 18:14:28 +0000 (UTC) IronPort-SDR: GBGplADm6ZoMB/lepfT9w4TvmhKLzjpxMlTIXBSViYmyv4bNXxTNcHCjHr7ICu4A2biwhec1pS 7DHWGGbBQgfw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 11:14:26 -0700 IronPort-SDR: aNLuuOBLKjBvftxy5qfpXMw6yOA2vhLrKyOrglZqkDbI7Hj9AGX9tpQ4FYAEQKDJvCsu3KCEid u8YjDgm1J7Hw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,422,1583222400"; d="scan'208";a="467369306" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by fmsmga006.fm.intel.com with ESMTP; 22 May 2020 11:14:26 -0700 Message-ID: <676f710b9747b091783aed38fb07259af3ca5b43.camel@intel.com> Subject: Re: [PATCH v10 26/26] x86/cet/shstk: Add arch_prctl functions for shadow stack From: Yu-cheng Yu To: Eugene Syromiatnikov Cc: Kees Cook , 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 , 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 , mtk.manpages@gmail.com Date: Fri, 22 May 2020 11:13:24 -0700 In-Reply-To: <20200522172934.GI12341@asgard.redhat.com> References: <20200429220732.31602-1-yu-cheng.yu@intel.com> <20200429220732.31602-27-yu-cheng.yu@intel.com> <202005211528.A12B4AD@keescook> <20200522172934.GI12341@asgard.redhat.com> 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 Fri, 2020-05-22 at 19:29 +0200, Eugene Syromiatnikov wrote: > On Fri, May 22, 2020 at 10:17:43AM -0700, Yu-cheng Yu wrote: > > On Thu, 2020-05-21 at 15:42 -0700, Kees Cook wrote: > > > On Wed, Apr 29, 2020 at 03:07:32PM -0700, Yu-cheng Yu wrote: > > [...] > > > > + > > > > +int prctl_cet(int option, u64 arg2) > > > > +{ > > > > + struct cet_status *cet; > > > > + > > > > + if (!IS_ENABLED(CONFIG_X86_INTEL_CET)) > > > > + return -EINVAL; > > > > > > Using -EINVAL here means userspace can't tell the difference between an > > > old kernel and a kernel not built with CONFIG_X86_INTEL_CET. Perhaps > > > -ENOTSUPP? > > > > Looked into this. The kernel and GLIBC are not in sync. So maybe we still use > > EINVAL here? > > > > Yu-cheng > > > > > > > > In kernel: > > ---------- > > > > #define EOPNOTSUPP 95 > > #define ENOTSUPP 524 > > > > In GLIBC: > > --------- > > > > printf("ENOTSUP=%d\n", ENOTSUP); > > printf("EOPNOTSUPP=%d\n", EOPNOTSUPP); > > printf("%s=524\n", strerror(524)); > > > > ENOTSUP=95 > > EOPNOTSUPP=95 > > Unknown error 524=524 > > EOPNOTSUPP/ENOTSUP/ENOTSUPP is actually a mess, it's summarized recently > by Michael Kerrisk[1]. From the kernel's point of view, I think it > would be reasonable to return EOPNOTSUPP, and expect that the userspace > would use ENOTSUP to match against it. Ok, use EOPNOTSUPP and add a comment why. Yu-cheng