Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5576975imm; Tue, 12 Jun 2018 09:53:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIKe40pgCz9rkCWvsEqc9k4FJvJPgzlpo8Kilvra0feVE1AEu9ZxDUXZe7x15a+86eHwqmR X-Received: by 2002:a65:51cb:: with SMTP id i11-v6mr1014671pgq.320.1528822400346; Tue, 12 Jun 2018 09:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528822400; cv=none; d=google.com; s=arc-20160816; b=Nwtx8kE0gnaNAp73h3WfN6CrxHix9aFlRlsKHy46K8Ijgej5ljBh6rLqiKirt6J+zp kVljLFtWC+nQi5eyTE/CR5sqJvp2UqiKfqj2TOg5C8ncEDLtDyo6VI3c5TA5x03QvsuM yKgp1mLeqQAn1PMXhs+k2RNonY8E9Ao7JWnvVVL/F6Dv0fQsUm6A1qe6cIdYTYuuDkyI b3dtgg92TTMFJ4jkLesntgrxzAY5vJ63icVLY6kUv/8DWzNhDFYLAvwMs7sCd1nP83rW ro/6qlXUQEtym7zpcapHsbo6wo58hTST0hna7wVBMhjdYkH1tdBtd47ScZB2nnfzNvy/ i5og== 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=7VMNrzAjKDc64qlsbblULFGY6ZOX0+yF8AB/zjQjF4w=; b=E6eL07gpEW0bZNn3eV1UGiUetLsmeM6x1EYvnEkE6DIB12sALjI3BwSPmY5K2qX9dU Fkj228HV/0zJM/4Z8Jtqn572ZVN+sIOqRnZbav2hJuVoJzSzEWCG1tnFLuM5Y6BkDO0N mqC1Ce6PrcwupsGXwaKgMz4s2THlRkEq2aYF+qkRALEoEq+4OGAi/J0H7thtOHrCX5JQ nJUGao1Zj89spD7GrOcW9orejKKqsLFJs0ooG1Av3ZasCj5PeKF1u/qjcS5vMZbGGmMs AYPMyASo3YBx3Fmj2+FzsbfgkmQcKapxf8bkav0GVuKwKt4VRUGV27uB5VhhTGdeQG7i u5PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r5bcPoKq; 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 t70-v6si413564pgc.481.2018.06.12.09.53.05; Tue, 12 Jun 2018 09:53:20 -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=r5bcPoKq; 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 S934975AbeFLQwD (ORCPT + 99 others); Tue, 12 Jun 2018 12:52:03 -0400 Received: from mail-ot0-f194.google.com ([74.125.82.194]:39530 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933983AbeFLQv5 (ORCPT ); Tue, 12 Jun 2018 12:51:57 -0400 Received: by mail-ot0-f194.google.com with SMTP id l15-v6so27855330oth.6; Tue, 12 Jun 2018 09:51:56 -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=7VMNrzAjKDc64qlsbblULFGY6ZOX0+yF8AB/zjQjF4w=; b=r5bcPoKqPybYyuookIFv6aza1+MAA4exq0fYyNwIhHUsx0VaRHYEm4u4AlKY12TbS+ owXlm3jUJ8Y7pG6plClGnNwR00nJhNFAq/AnmJADQKTLqXzMItF8FgEuqg9Jgt2X5DQF iZye0UtRPC1g4sYlTQlz/Lv8ppoEDMF5kkEisjSjV5YGI/wzaWcBRlBTGa6K8SrbhXWk MplZAE57lkCnvTEq6J+6mWzcnAzKcUhZiOBDm69EnDwOxObZKxjReRq6VItpycx2So5p LqSgjcwq8m7cJCoQ1PfV6ZjNBgRT9RllgOaWLh/f9mptCsb5gGgGjGO0ayb0EjlQBg1f TmdQ== 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=7VMNrzAjKDc64qlsbblULFGY6ZOX0+yF8AB/zjQjF4w=; b=fxBjZ6614lVCnYjRlGfX3FLiXB1m12RWX8WlB5g5yeTKgY2OIMeuI43WFag/LAxDNm 9U+bxwJSY/D68/dZPK33WCLCgWCb0tF6CNE962X7xbMX0hEdOj+4VeovObY7jqMh9aku aR2y4kZeZ9j8RQ3JrlH9txL///j2+GeL06SNaosYN667030glEm9ZCjnSIth9K5uFVSs i1VS/QiF/N9qnhGVDhTSN+d9vSQGDzyc4ksmIDHSX7QHZkxaQQZazBi1+rP5ES2AaqAz iOzLKce3uEzZ92crwusROk+9o1cbE7NggmhU0Ju/qMvasOCAgkeIjOfGuei/+RTwzWxe Obfg== X-Gm-Message-State: APt69E3td/MIWWoc0rt2aLmP4AFOPvcPJW7uBEh1+yOleRs1DJNDfi6w 3az3hEqF9uWakRdcUcbETqvQvohjD7WWSdR7iEc= X-Received: by 2002:a9d:2ed3:: with SMTP id w77-v6mr858645ota.123.1528822316023; Tue, 12 Jun 2018 09:51:56 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:7019:0:0:0:0:0 with HTTP; Tue, 12 Jun 2018 09:51:55 -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 09:51:55 -0700 Message-ID: Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack 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 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 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: >> >> > 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. >> > > 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. > I'm concerned that the entire concept of locking CET is there to solve > a security problem that doesn't actually exist. We don't know that. -- H.J.