From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu-cheng Yu Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack Date: Tue, 19 Jun 2018 15:38:57 -0700 Message-ID: <1529447937.27370.33.camel@intel.com> References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-7-yu-cheng.yu@intel.com> <1528403417.5265.35.camel@2b52.sc.intel.com> <569B4719-6283-4575-A16E-D0A78D280F4E@amacapital.net> <1529427588.23068.7.camel@intel.com> <0AF8B71E-B6CC-42DE-B95C-93896196C3D7@amacapital.net> <446EB18D-EF06-4A04-AF62-E72C68D96A84@amacapital.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <446EB18D-EF06-4A04-AF62-E72C68D96A84@amacapital.net> Sender: linux-kernel-owner@vger.kernel.org To: Andy Lutomirski , Kees Cook Cc: Andy Lutomirski , "H. J. Lu" , Thomas Gleixner , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Ingo Molnar , "Shanbhogue, Vedvyas" , "Ravi V. Shankar" , Dave Hansen , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , mike.kravetz@oracle.com, Florian Weimer List-Id: linux-arch.vger.kernel.org On Tue, 2018-06-19 at 13:47 -0700, Andy Lutomirski wrote: > > > > On Jun 19, 2018, at 1:12 PM, Kees Cook > > wrote: > > > > > > > > On Tue, Jun 19, 2018 at 10:20 AM, Andy Lutomirski > > l.net> wrote: > > > > > > > > > > > On Jun 19, 2018, at 10:07 AM, Kees Cook > > > > wrote: > > > > > > > > Does it provide anything beyond what PR_DUMPABLE does? > > > What do you mean? > > I was just going by the name of it. I wasn't sure what "ptrace CET > > lock" meant, so I was trying to understand if it was another "you > > can't ptrace me" toggle, and if so, wouldn't it be redundant with > > PR_SET_DUMPABLE = 0, etc. > > > No, other way around. The valid CET states are on/unlocked, > off/unlocked, on/locked, off/locked. arch_prctl can freely the state > unless locked. ptrace can change it no matter what.  The lock is to > prevent the existence of a gadget to disable CET (unless the gadget > involves ptrace, but I don’t think that’s a real concern). We have the arch_prctl now and only need to add ptrace lock/unlock. Back to the dlopen() "relaxed" mode. Would the following work? If the lib being loaded does not use setjmp/getcontext families (the loader knows?), then the loader leaves shstk on.  Otherwise, if the system-wide setting is "relaxed", the loader turns off shstk and issues a warning.  In addition, if (dlopen == relaxed), then cet is not locked in any time. The system-wide setting (somewhere in /etc?) can be: dlopen=force|relaxed /* controls dlopen of non-cet libs */ exec=force|relaxed /* controls exec of non-cet apps */ -- Yu-cheng From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com ([134.134.136.24]:54658 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754101AbeFSWmS (ORCPT ); Tue, 19 Jun 2018 18:42:18 -0400 Message-ID: <1529447937.27370.33.camel@intel.com> Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack From: Yu-cheng Yu Date: Tue, 19 Jun 2018 15:38:57 -0700 In-Reply-To: <446EB18D-EF06-4A04-AF62-E72C68D96A84@amacapital.net> References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-7-yu-cheng.yu@intel.com> <1528403417.5265.35.camel@2b52.sc.intel.com> <569B4719-6283-4575-A16E-D0A78D280F4E@amacapital.net> <1529427588.23068.7.camel@intel.com> <0AF8B71E-B6CC-42DE-B95C-93896196C3D7@amacapital.net> <446EB18D-EF06-4A04-AF62-E72C68D96A84@amacapital.net> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andy Lutomirski , Kees Cook Cc: Andy Lutomirski , "H. J. Lu" , Thomas Gleixner , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Ingo Molnar , "Shanbhogue, Vedvyas" , "Ravi V. Shankar" , Dave Hansen , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , mike.kravetz@oracle.com, Florian Weimer Message-ID: <20180619223857.S3ffIWueWBscJ8qWHRXmOZQMcOZFNvoC2fAXC_YNSMQ@z> On Tue, 2018-06-19 at 13:47 -0700, Andy Lutomirski wrote: > > > > On Jun 19, 2018, at 1:12 PM, Kees Cook > > wrote: > > > > > > > > On Tue, Jun 19, 2018 at 10:20 AM, Andy Lutomirski > > l.net> wrote: > > > > > > > > > > > On Jun 19, 2018, at 10:07 AM, Kees Cook > > > > wrote: > > > > > > > > Does it provide anything beyond what PR_DUMPABLE does? > > > What do you mean? > > I was just going by the name of it. I wasn't sure what "ptrace CET > > lock" meant, so I was trying to understand if it was another "you > > can't ptrace me" toggle, and if so, wouldn't it be redundant with > > PR_SET_DUMPABLE = 0, etc. > > > No, other way around. The valid CET states are on/unlocked, > off/unlocked, on/locked, off/locked. arch_prctl can freely the state > unless locked. ptrace can change it no matter what.  The lock is to > prevent the existence of a gadget to disable CET (unless the gadget > involves ptrace, but I don’t think that’s a real concern). We have the arch_prctl now and only need to add ptrace lock/unlock. Back to the dlopen() "relaxed" mode. Would the following work? If the lib being loaded does not use setjmp/getcontext families (the loader knows?), then the loader leaves shstk on.  Otherwise, if the system-wide setting is "relaxed", the loader turns off shstk and issues a warning.  In addition, if (dlopen == relaxed), then cet is not locked in any time. The system-wide setting (somewhere in /etc?) can be: dlopen=force|relaxed /* controls dlopen of non-cet libs */ exec=force|relaxed /* controls exec of non-cet apps */ -- Yu-cheng