Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5744919imm; Tue, 12 Jun 2018 12:35:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJAgskWsupSc1tHkOQf07yG5iirJ9eOH4JBy69D+6Zuhb3GJ6PMq1XUCil0QZ+p5kW7BavN X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr1843463plf.47.1528832124834; Tue, 12 Jun 2018 12:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528832124; cv=none; d=google.com; s=arc-20160816; b=chchhtqh9ywLJ5K19pUjYTQSfIT4iQJjU8OjIWMU2tZ0m5w1DjMBFtOU4GLEpXU5XA FHv2FBq+BnFByEWh08UNlWehBgd0hdQMjzpP2xL06pSdcWZFOnMDNxifzEV/6FcxMdUD 3bTlNaglFEh2J9OHwHlXe+0syMSG6l3Rcg64Z6hnspiNOxIZELvBrpdeDKYvPJ1fZ9yk 434/b27YJ9E3ciEGIUZ6P16u7ycVe7NfzjV5EkijQjeeJzEo21r58Y+QZNSi160N2tIe U9TQvBu8dmg7P1XbzkeZ/q+RyS8ezriNDRyW8v+B/wBmP/dYK0Yyfjm8KyTFuGjqvKiM Il7w== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=W+28d3Sr/9L9yJao9RPdfThx+qD77ejVW9EN5e4mgt4=; b=sZhrSpPI59ztLV3NJfJTR0wdQ5onvqQhBoIB0KEsEDq3h2MgOGbQVesJsnMXodJnXq R+3KBOm5HBuzZueAXCGAfc/Ee9kMRJfJYgK4EUkLlyeThk2LnObC6akgHD646puCT2KE kLxm8X8YUFMHISImk7VdhYIVkW6s1N1gtJJYTM72VuavtD9gPP9RCHcXScx+1Xl0Ag1p DB44UIP5QaK2cMJVkeOauowRGjDWBIXJAcCNXmj66ZUZsfXOdW2y5ZaUfl9cRCcGQt5F jJkOb5xfkevXmEGmk8JY47ZZLeIjwwyQXRSJpW5LOcx+t8gR+ntUV1VQQSSd76tAzhDN PcYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RFRbXM+C; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12-v6si687754pgs.560.2018.06.12.12.35.06; Tue, 12 Jun 2018 12:35:24 -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=@gmail.com header.s=20161025 header.b=RFRbXM+C; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932957AbeFLTei (ORCPT + 99 others); Tue, 12 Jun 2018 15:34:38 -0400 Received: from mail-ot0-f196.google.com ([74.125.82.196]:36476 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753517AbeFLTeg (ORCPT ); Tue, 12 Jun 2018 15:34:36 -0400 Received: by mail-ot0-f196.google.com with SMTP id c15-v6so175353otl.3; Tue, 12 Jun 2018 12:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=W+28d3Sr/9L9yJao9RPdfThx+qD77ejVW9EN5e4mgt4=; b=RFRbXM+C9r56bzdKYHB7ELVfTaEhMAk3GqJpS5CZlaoZm2GWvknbgESI9K6zJRxwym UClpaZjiUNLhgySSW3QQnD2BkAMNPH8qN/6ZC//2zVtB46jYKIqLiLV1KEYfzh4sy3LM 5cw2NF9zVCyWYnymoizg1/hQpz7ONakWryCOukx05QVi2bVH9qAHqfqz0wqYPt3z2HzK N86H+3HC1W8APVtNTlDSalw2+9UGFc5wqfSfrOkUTqwLvj3sTCT70g1xw2QMR9igXfsw exh4c64P0uLGweU2sSJOywr/aN+HvaR9MyhqFTXOAdCu5CCFay91+k9YZWJwsS3z/Z09 vHkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=W+28d3Sr/9L9yJao9RPdfThx+qD77ejVW9EN5e4mgt4=; b=MlhnctIoKdSbTcp6v6Bj9Hx6eVQrNzWbtvI8qN7+PG4QtiFfWTLUUB5QAASAcuXt6j Qte3RLXiOdfo1/nRc/usDenUKt8zmAiyGuFTaiK2NdHdU751i47/Eu++gM9eZbseoD3+ XwR8mcwB9X1J6YUWNTdqLuMnTnWcseV152A0o5U55NYOeSb0aGm7/RQROC3m8Os/s3Nc h2DCpCxjaNrG+OqcjuD3t80nibEbXz6KuYkKwQiTi3fB2QhdfAQv2+rAol1IqdEitWKr CftIOOItIIyIAIxuhQogqWjFiZjhjHg8alnHD3omL9zud1TweQDLlfHkfQ3DcX37zd+B NHQQ== X-Gm-Message-State: APt69E3ZbinuIOrUWmAwjqxgyu/GjMuVAmhbEfCOzTXrvenRv/OKqbXZ TNot+sxfAkWNA8gkIF5I3qMN8lRB5v98SF/MsYM= X-Received: by 2002:a9d:2ed3:: with SMTP id w77-v6mr1243664ota.123.1528832075346; Tue, 12 Jun 2018 12:34:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:7019:0:0:0:0:0 with HTTP; Tue, 12 Jun 2018 12:34:34 -0700 (PDT) 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 12:34:34 -0700 Message-ID: Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack To: Thomas Gleixner Cc: Andy 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 11:59 AM, Thomas Gleixner wrote: > On Tue, 12 Jun 2018, H.J. Lu wrote: >> On Tue, Jun 12, 2018 at 9:34 AM, Andy Lutomirski wrote: >> > On Tue, Jun 12, 2018 at 9:05 AM H.J. Lu wrote: >> >> 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: >> >> >> > 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. >> >> >> > >> > Which exactly illustrates my point. By making your security story too >> > absolute, you'll force people to turn it off when they don't need to. >> > If I'm using a fully CET-ified distro and I'm using a CET-aware >> > program that loads binary plugins, and I may or may not have an old >> > (binary-only, perhaps) plugin that doesn't support CET, then the >> > behavior I want is for CET to be on until I dlopen() a program that >> > doesn't support it. Unless there's some ABI reason why that can't be >> > done, but I don't think there is. >> >> We can make it opt-in via GLIBC_TUNABLES. But by default, the legacy >> shared object is disallowed when CET is enabled. > > That's a bad idea. Stuff has launchers which people might not be able to > change. So they will simply turn of CET completely or it makes them hack > horrible crap into init, e.g. the above export. > > Give them sane kernel options: > > cet = off, relaxed, forced > > where relaxed allows to run binary plugins. Then let dlopen() call into the > kernel with the filepath of the library to check for CET and that will tell > you whether its ok or or not and do the necessary magic in the kernel when > CET has to be disabled due to a !CET library/application. > > That's also making the whole thing independent of magic glibc environment > options and allows it to be used all over the place in the same way. This is very similar to our ARCH_CET_EXEC proposal which controls how CET should be enforced. But Andy thinks it is a bad idea. -- H.J.