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 61E1EC433DF 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 3AD77206F6 for ; Fri, 22 May 2020 18:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730840AbgEVSO1 (ORCPT ); Fri, 22 May 2020 14:14:27 -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-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@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