From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eugene Syromiatnikov Subject: Re: [PATCH v10 26/26] x86/cet/shstk: Add arch_prctl functions for shadow stack Date: Fri, 22 May 2020 19:29:34 +0200 Message-ID: <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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Yu-cheng Yu Cc: Kees Cook , x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.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, 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. [1] https://lore.kernel.org/linux-man/cb4c685b-6c5d-9c16-aade-0c95e57de4b9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org/ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 22 May 2020 19:29:34 +0200 From: Eugene Syromiatnikov Subject: Re: [PATCH v10 26/26] x86/cet/shstk: Add arch_prctl functions for shadow stack Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org To: Yu-cheng Yu 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: <20200522172934.bOSDpdN-Ben8bah7CsNpy-B08u4D_ZySTb5k9bAhF7M@z> 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. [1] https://lore.kernel.org/linux-man/cb4c685b-6c5d-9c16-aade-0c95e57de4b9@gmail.com/