Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp398170imm; Thu, 7 Jun 2018 21:36:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI0n/OLLzlagtG+vP5zOxF2JgMsFLTI9Q8Uhjx2xic7feBL7lqynefAMBy5LGoh7zMeyQur X-Received: by 2002:a17:902:8d8d:: with SMTP id v13-v6mr4830470plo.362.1528432573614; Thu, 07 Jun 2018 21:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528432573; cv=none; d=google.com; s=arc-20160816; b=0z135h1Oc0gU++5eaOKrIQOLgzavrJ8+gdZt5GWYwzTcNdJ+LAGBQxDoNrsNyjzJ/6 4z9Rh8isyhK3WaCrB1xhFg1nQN5wCVZcKmPyoIp3GskcnxjgV2EVXWvoo/ZmKe5xiNTN 8QH/PxykR4o/B7ItfRFkJhx+Fpxhh2lXRDlhP/x0GoKlOV/Jkh5xYIQ/DrzzDijwjT4W G8OOCTHeI1jUerV853np5Urc6XSbocirBnuEIa4nVLKV3CmCMcU8Fpo+pbC3Y0TD5vBy B2d11Sn4WLct4EC8k6On2+fVcNMKTnPIdKQyR1jsAFhJ8zmN8iclyxKrZaAcLa4dgbvo bJww== 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=3v3dyNjUU+TtLDPs6e+M6v6Lf2GwG5BgQ91pfGbyxYA=; b=l3nO43DsJGc/0zYioW7G1E1de4ZcfZYw7fkhEYcNHXOrkuq1AWeRrequd5VZgHYlGm N37+s8jEzgmTbCNJqQ3O7OZSqDxggzvFsn+WjOYad1G0Fjpw7N8CG5i38dbdrLlIaFG0 YI9UuWPhjvZQWhUaWp4QSUKCHJMa5itI6UUWY1DDosssLY/lFLCK/dsLcsJY9jt2V6Cd lVv/yo5UHHGKK1xxGAZXlGMp2Xp62tXo/zgWVJHTKRkTVXDW8XREEDFGbrM8t/WjD7gc QtxeroAyUBMvS+6tEQglTRIfl0bzHLQUeFYtuH6FLMkaoVL1kPMSsWGgAoOv7MgHln+1 L/Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lDE8OaUc; 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 h71-v6si14407674pfe.332.2018.06.07.21.35.58; Thu, 07 Jun 2018 21:36:13 -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=lDE8OaUc; 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 S1751050AbeFHEfd (ORCPT + 99 others); Fri, 8 Jun 2018 00:35:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:46564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbeFHEfb (ORCPT ); Fri, 8 Jun 2018 00:35:31 -0400 Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) (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 B6DA8208B0 for ; Fri, 8 Jun 2018 04:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528432531; bh=Yy/MOg5lY8RT/R+Td8aOKYrzKBLYWUBWowtyJ0VhcdI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lDE8OaUcf56dk7dqePO4PM4r6HKXlACpBiKUAhfq5kW3SXO9ZRHB/nBVdbhTTlXI7 tOWw1eQcSvdzTdpezKisVzKAYcIZCeZLjev3J0X+vG1atRYnuRgY0tTjRTywhbaKwV 1MBD7v9ouQto1kVU+QOsRJPIpX+PpZKEgiXGQc5c= Received: by mail-wr0-f178.google.com with SMTP id h10-v6so11910232wrq.8 for ; Thu, 07 Jun 2018 21:35:30 -0700 (PDT) X-Gm-Message-State: APt69E389ibLitlHZP8a+crFbJwKdsrqWOOEiwh42QrdBymYWdr2NA9N /TcetwCrPcTo/VVHMPcloqQFexkgWIBJ49QQvYL68A== X-Received: by 2002:adf:b445:: with SMTP id v5-v6mr3513194wrd.67.1528432529016; Thu, 07 Jun 2018 21:35:29 -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: Thu, 7 Jun 2018 21:35:17 -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 , Yu-cheng Yu , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Thomas Gleixner , 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 Thu, Jun 7, 2018 at 9:22 PM H.J. Lu wrote: > > On Thu, Jun 7, 2018 at 3:02 PM, H.J. Lu wrote: > > On Thu, Jun 7, 2018 at 2:01 PM, Andy Lutomirski wrote: > >> On Thu, Jun 7, 2018 at 1:33 PM Yu-cheng Yu wrote: > >>> > >>> On Thu, 2018-06-07 at 11:48 -0700, Andy Lutomirski wrote: > >>> > On Thu, Jun 7, 2018 at 7:41 AM Yu-cheng Yu wrote: > >>> > > > >>> > > The following operations are provided. > >>> > > > >>> > > ARCH_CET_STATUS: > >>> > > return the current CET status > >>> > > > >>> > > ARCH_CET_DISABLE: > >>> > > disable CET features > >>> > > > >>> > > ARCH_CET_LOCK: > >>> > > lock out CET features > >>> > > > >>> > > ARCH_CET_EXEC: > >>> > > set CET features for exec() > >>> > > > >>> > > ARCH_CET_ALLOC_SHSTK: > >>> > > allocate a new shadow stack > >>> > > > >>> > > ARCH_CET_PUSH_SHSTK: > >>> > > put a return address on shadow stack > >>> > > > > >> And why do we need ARCH_CET_EXEC? > >> > >> For background, I really really dislike adding new state that persists > >> across exec(). It's nice to get as close to a clean slate as possible > >> after exec() so that programs can run in a predictable environment. > >> exec() is also a security boundary, and anything a task can do to > >> affect itself after exec() needs to have its security implications > >> considered very carefully. (As a trivial example, you should not be > >> able to use cetcmd ... sudo [malicious options here] to cause sudo to > >> run with CET off and then try to exploit it via the malicious options. > >> > >> If a shutoff is needed for testing, how about teaching ld.so to parse > >> LD_CET=no or similar and protect it the same way as LD_PRELOAD is > >> protected. Or just do LD_PRELOAD=/lib/libdoesntsupportcet.so. > >> > > > > I will take a look. > > We can use LD_CET to turn off CET. Since most of legacy binaries > are compatible with shadow stack, ARCH_CET_EXEC can be used > to turn on shadow stack on legacy binaries: Is there any reason you can't use LD_CET=force to do it for dynamically linked binaries? I find it quite hard to believe that forcibly CET-ifying a legacy statically linked binary is a good idea.