Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5521234imm; Tue, 12 Jun 2018 09:03:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKpG6vieBylOrMhHdBPMZkVFPGM0FWfuX21oQP7oLmKOfAL4M18enXmMDt9wGxB3LXOMt4E X-Received: by 2002:a62:138c:: with SMTP id 12-v6mr1054592pft.34.1528819381365; Tue, 12 Jun 2018 09:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528819381; cv=none; d=google.com; s=arc-20160816; b=eh+FAa8Gsxv1IYqkouA+TaEUuSChf9P4NPFchvVgm+Oh6mxbNlto+hZOs4732kb6cd YxO0ulPakifRRZKVWoFFmY6tuptrEFkURZ+MYqAZT0iqEEVWbdjWQWwliVxvgh0XDdpj 6kLH4MxmhXVBn5S92+7EXAUazVycZZA9YGnntWbsU3/a3ST+7F+OPdP1xFojfkWh8K2Z HSZIOaRDGjIWbWdVdJmov7aNu9bOW/sLoav8sQaPn4TwBM2BRH/JCgfTMvRqJ86Ghky8 C1Yx3vBgIIx8NZDndL/CyFWq/OXaaGxEBDgy6d9in2bP7JcL4wHkJdlYrofWryilWKvZ ySTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=zRPE1OeUrDoVSnR8h9jPUfh3sZW5C+Xh7PZ20f+zZrY=; b=sBI4Xo2EMJmqdbuDeWPLCF80rcMb7sDPX/p3J2/DWdrP2O6FQIQUeA9/r7jCUjlYFN z4W0AiafrZZ/dGCIVy2EnbQNRtCqiRuP7VMi3ePkeGeKao4JuHH4imiXtH3VokrcvGKs KBvo/0oG9JvSanYbnIdo3f94k9jpRD62/L/eb97fTKLZsdjbe7RrOGq97bni60WniiXH S2QzlU0MrPzx0QC6RdmjyDZIdaLvH+qmB+pJ4Up/RPWN/kEdkBdWgTtmutBjthihPcYQ iA6um6m3WQqe6HPmjvvPEJoeut5wZpufbOR11rzyMQKcacycJa83W/qQGG4fFn4TTZQE QLZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WRjiookJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21-v6si314482pgn.279.2018.06.12.09.02.46; Tue, 12 Jun 2018 09:03:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WRjiookJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934191AbeFLQCF (ORCPT + 99 others); Tue, 12 Jun 2018 12:02:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933137AbeFLQCD (ORCPT ); Tue, 12 Jun 2018 12:02:03 -0400 Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 06FCA208B8 for ; Tue, 12 Jun 2018 16:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528819323; bh=qz844i3hlmnmB8pkhGqjdrUbbK1JubnKcBc70gs4OjU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WRjiookJB6fro00rW7i/oWYdJqMgT5rgaW2hz0rFM406ldh9VdecdFNjAjkueiIX1 5apPoQKXsBxYQWhLdT2cdbTX8EwCj4RfEE2mrzdaTrz8kb8SyRHasGbx1bbQfp1Pj9 Fn0wLomwZtR1blwOTFHJuhkkKRABzcUvM1w4chwY= Received: by mail-wm0-f51.google.com with SMTP id r125-v6so24348453wmg.2 for ; Tue, 12 Jun 2018 09:02:02 -0700 (PDT) X-Gm-Message-State: APt69E3dO8i+bauoy+7/uEIYi8UunK9fow7ztV+913NPDS2ht2mJ9+CS 6sIuyiWaWjETAh01Epf2N2xue+bJWmd6+wFWg3f8gQ== X-Received: by 2002:a1c:34c9:: with SMTP id b192-v6mr690294wma.21.1528819321435; Tue, 12 Jun 2018 09:02:01 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Andy Lutomirski Date: Tue, 12 Jun 2018 09:01:48 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack To: "H. J. Lu" Cc: Thomas Gleixner , Andrew Lutomirski , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.