From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H.J. Lu" Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack Date: Tue, 12 Jun 2018 09:05:24 -0700 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Andy Lutomirski Cc: Thomas Gleixner , Yu-cheng Yu , 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 List-Id: linux-arch.vger.kernel.org On Tue, Jun 12, 2018 at 9:01 AM, Andy Lutomirski wrote: > On Tue, Jun 12, 2018 at 4:43 AM H.J. Lu wrote: >> >> On Tue, Jun 12, 2018 at 3:03 AM, Thomas Gleixner wrote: >> > On Thu, 7 Jun 2018, H.J. Lu wrote: >> >> On Thu, Jun 7, 2018 at 2:01 PM, Andy Lutomirski wrote: >> >> > Why is the lockout necessary? If user code enables CET and tries to >> >> > run code that doesn't support CET, it will crash. I don't see why we >> >> > need special code in the kernel to prevent a user program from calling >> >> > arch_prctl() and crashing itself. There are already plenty of ways to >> >> > do that :) >> >> >> >> On CET enabled machine, not all programs nor shared libraries are >> >> CET enabled. But since ld.so is CET enabled, all programs start >> >> as CET enabled. ld.so will disable CET if a program or any of its shared >> >> libraries aren't CET enabled. ld.so will lock up CET once it is done CET >> >> checking so that CET can't no longer be disabled afterwards. >> > >> > That works for stuff which loads all libraries at start time, but what >> > happens if the program uses dlopen() later on? If CET is force locked and >> > the library is not CET enabled, it will fail. >> >> That is to prevent disabling CET by dlopening a legacy shared library. >> >> > I don't see the point of trying to support CET by magic. It adds complexity >> > and you'll never be able to handle all corner cases correctly. dlopen() is >> > not even a corner case. >> >> That is a price we pay for security. To enable CET, especially shadow >> shack, the program and all of shared libraries it uses should be CET >> enabled. Most of programs can be enabled with CET by compiling them >> with -fcf-protection. > > If you charge too high a price for security, people may turn it off. > I think we're going to need a mode where a program says "I want to use > the CET, but turn it off if I dlopen an unsupported library". There > are programs that load binary-only plugins. You can do # export GLIBC_TUNABLES=glibc.tune.hwcaps=-SHSTK which turns off shadow stack. -- H.J. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot0-f195.google.com ([74.125.82.195]:40681 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933137AbeFLQFZ (ORCPT ); Tue, 12 Jun 2018 12:05:25 -0400 MIME-Version: 1.0 In-Reply-To: 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> From: "H.J. Lu" Date: Tue, 12 Jun 2018 09:05:24 -0700 Message-ID: Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack Content-Type: text/plain; charset="UTF-8" Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andy Lutomirski Cc: Thomas Gleixner , Yu-cheng Yu , 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 Message-ID: <20180612160524.vArAUNt42x9lO42snJK4dS2HYDNV5uufHivFLQy-WLI@z> On Tue, Jun 12, 2018 at 9:01 AM, Andy Lutomirski wrote: > On Tue, Jun 12, 2018 at 4:43 AM H.J. Lu wrote: >> >> On Tue, Jun 12, 2018 at 3:03 AM, Thomas Gleixner wrote: >> > On Thu, 7 Jun 2018, H.J. Lu wrote: >> >> On Thu, Jun 7, 2018 at 2:01 PM, Andy Lutomirski wrote: >> >> > Why is the lockout necessary? If user code enables CET and tries to >> >> > run code that doesn't support CET, it will crash. I don't see why we >> >> > need special code in the kernel to prevent a user program from calling >> >> > arch_prctl() and crashing itself. There are already plenty of ways to >> >> > do that :) >> >> >> >> On CET enabled machine, not all programs nor shared libraries are >> >> CET enabled. But since ld.so is CET enabled, all programs start >> >> as CET enabled. ld.so will disable CET if a program or any of its shared >> >> libraries aren't CET enabled. ld.so will lock up CET once it is done CET >> >> checking so that CET can't no longer be disabled afterwards. >> > >> > That works for stuff which loads all libraries at start time, but what >> > happens if the program uses dlopen() later on? If CET is force locked and >> > the library is not CET enabled, it will fail. >> >> That is to prevent disabling CET by dlopening a legacy shared library. >> >> > I don't see the point of trying to support CET by magic. It adds complexity >> > and you'll never be able to handle all corner cases correctly. dlopen() is >> > not even a corner case. >> >> That is a price we pay for security. To enable CET, especially shadow >> shack, the program and all of shared libraries it uses should be CET >> enabled. Most of programs can be enabled with CET by compiling them >> with -fcf-protection. > > If you charge too high a price for security, people may turn it off. > I think we're going to need a mode where a program says "I want to use > the CET, but turn it off if I dlopen an unsupported library". There > are programs that load binary-only plugins. You can do # export GLIBC_TUNABLES=glibc.tune.hwcaps=-SHSTK which turns off shadow stack. -- H.J.