Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5559285imm; Tue, 12 Jun 2018 09:36:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIkY4EPrDLnY3jKVZS/J4eNQcCf9Aufd+oye3MQ+X5tamBkZU27vnlWg5XyHK9iXXQxtGQX X-Received: by 2002:a17:902:bb0d:: with SMTP id l13-v6mr1182048pls.115.1528821365284; Tue, 12 Jun 2018 09:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528821365; cv=none; d=google.com; s=arc-20160816; b=c6dxHPAV1Tqe7d/wmPFC7AIgBb4hbgCrYZbTa4AovC6UBttfGBZWMuWErlm3NTyj7g uhukA5BOiTfeWq2PGAjsqo5nrYyNzEBymsE7O9jBGYaMQ/8Z3yL8F73XtoW1X+dc92Bl euVkwd+cjDoTudK5zj93T9mawTIfvbvdGzg+2W1+cjctioP8I3mMWeZtOquDh3snBoFE a/JLgNe6YAdF0d9wZxbkzuQlCZJhvpswbYHKe5/0BXHmddGSKqzcaFK5vmdT173WB304 A+nYuVujiQLg83UHVDZvQ15OLv8lwEHgLfobtL7On7Zr/hF1xEWQGvqziTaknCHGDFU5 ss6A== 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=7tkb/i7et4WmchSHSnknRI26Y9KJSSQIRI8wwKIf4uw=; b=FPRyjKMgtdCElm//g0OJ/LSvkVGIaXcWbrwJWAcg4Fp1aJMo1LiplolJCsnOW+0dB8 jhX/t3HnvYJrck5+eJkJixxHn4zRCrXTC46B3WKQmuxj8l+9515fdMfKxK9qCBDR6eXi qTzSXHfyw+Bsvmo7OGpkZaxT5C8na1gpLwhRv39UUULS7ZWndDDasGtVKe3L3imoAOwB ptwtl719n9lvEHUY4LtKrIz5t6kUTCBltPpBtY/GTaDnB1fAsSln2Auobo5QESwdsZ8m wUMRMht9/q7PCwyMC1vC88pdiMoUXNaEEwFI89doQuSs+TgH5VEmxqfWKGGXP9T3PKyy ns6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EXURu2tj; 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 h3-v6si372803pgf.364.2018.06.12.09.35.50; Tue, 12 Jun 2018 09:36:05 -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=EXURu2tj; 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 S934702AbeFLQei (ORCPT + 99 others); Tue, 12 Jun 2018 12:34:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:53132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933640AbeFLQef (ORCPT ); Tue, 12 Jun 2018 12:34:35 -0400 Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) (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 0AE8D208B2 for ; Tue, 12 Jun 2018 16:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528821275; bh=EzzfG0a8cu2r/pCtb2ro4nWK49y1X5ywdX3P6HHd85Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=EXURu2tjqcluA73MwGSzhl3UGrN0Qh3K+9N9V3OMxPO0Jo7gEI5iYWIfkaHt6CLNW /R+gP9okergUCM3dxXCvqX2E0XR5nMQGitjNLUvKdnVj5LPpH1InXqLFQ36+5jzfl8 I6yi63J+T6TlUf2nsQ0Frz2JhfaTRyWgju0J1RaI= Received: by mail-wm0-f50.google.com with SMTP id 69-v6so161744wmf.3 for ; Tue, 12 Jun 2018 09:34:34 -0700 (PDT) X-Gm-Message-State: APt69E0eNy8pHSZqJRuoQLUrVKFMJipaL0c+0uZVoHpXqC10rgRRzJSQ 1haAUUlpES2Srk1cnLHyE2/sDjVc4WX4AAUshJZZSw== X-Received: by 2002:a1c:f902:: with SMTP id x2-v6mr709578wmh.116.1528821273566; Tue, 12 Jun 2018 09:34:33 -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:34:21 -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: Andrew Lutomirski , 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: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. I'm concerned that the entire concept of locking CET is there to solve a security problem that doesn't actually exist.