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: 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 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" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , mtk.manpages@gmail.com List-ID: Message-ID: <20200522181324.DuLgGrEw7TZxp7W_MLTJMkFtZrbTwq6lmM7qf0LBqIM@z> 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