Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp959845imm; Fri, 8 Jun 2018 07:53:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKrAbxUaBEocOeokHzJjOGxKfnj7KpODmCsDPH1tI06MGx5UkK81b9EdIyO2kG5Pm+eLeru X-Received: by 2002:aa7:8148:: with SMTP id d8-v6mr824891pfn.78.1528469638301; Fri, 08 Jun 2018 07:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528469638; cv=none; d=google.com; s=arc-20160816; b=LDYjUGlBM5DFkPuEDzxND0qEs/FQZz/9o6Vs3FYkK8ruGa3rXpieVORjLB3JmES723 LuW9B2w3Y3YJMnyy9VZEB/sMosVnl/d+OeSnYfPWkaqWQ9/II3YxIrXPT9x6o4Cm62ly 1hycP39MHoAPT9N2bfGIaEz8WOx7yXLpYB0BQujHc6KK6fGnUzqMajjmfNk6NIIxMzCI V+xk9n01tIS7BD7QBqTDJzeJUlO0TjygpRjzSRVImJEHKSBGtzpH/pgsBMMBZoSycxc+ X9ixkjSQXd8QtFuCIC0i9+Qy/3OF0xG6o0d7ZfGTbICV2ZLCRjFWynpO8kZIBOjnESCs M9/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=1OBGocUKexoKraog+2xu7PwY0dYB8mitK6kf3uJAt/g=; b=WEgUwxSv+B6PKV0FjR7wq4JcAMHlrFIEfjI2csogdY08/kXzsQYvLYBN2pVKy3syYr I3RbwBMu75ecGLe9UkSF2SisLCTfGCkLDsv8sIOI4APyNyUYFIXAKifuIdC/BO2mk0eZ Xg4JSKHFOMHkcQBvRtaP2Ls5y0je0I3GWxCRy6Utd8xkT1kj7pw7u8WoKZQ0Ar3ifnbA 8YLS/9fSCXXQLcR0De2tjlf3D9t31QlaEaRXRdcyG/7cq14SvgvP+X54x3esFhSKXnlA da581ehZflVHrc0xDqzBoSrPw7Fvcy7NoGuNGE4mzcGjQNfaLRzsLvXMkXrarzD+OTaV q+iw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5-v6si11834365pgs.15.2018.06.08.07.53.43; Fri, 08 Jun 2018 07:53:58 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752674AbeFHOxN (ORCPT + 99 others); Fri, 8 Jun 2018 10:53:13 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751152AbeFHOxL (ORCPT ); Fri, 8 Jun 2018 10:53:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE047401EF06; Fri, 8 Jun 2018 14:53:10 +0000 (UTC) Received: from oldenburg.str.redhat.com (dhcp-192-212.str.redhat.com [10.33.192.212]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CEBF1C70A; Fri, 8 Jun 2018 14:53:04 +0000 (UTC) Subject: Re: [PATCH 04/10] x86/cet: Handle thread shadow stack To: Andy Lutomirski Cc: Yu-cheng Yu , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H. J. Lu" , "Shanbhogue, Vedvyas" , "Ravi V. Shankar" , Dave Hansen , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , mike.kravetz@oracle.com References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-5-yu-cheng.yu@intel.com> <3c1bdf85-0c52-39ed-a799-e26ac0e52391@redhat.com> From: Florian Weimer Message-ID: <6ee29e8b-4a0a-3459-a1ee-03923ba4e15d@redhat.com> Date: Fri, 8 Jun 2018 16:53:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 08 Jun 2018 14:53:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 08 Jun 2018 14:53:10 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'fweimer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/07/2018 10:53 PM, Andy Lutomirski wrote: > On Thu, Jun 7, 2018 at 12:47 PM Florian Weimer wrote: >> >> On 06/07/2018 08:21 PM, Andy Lutomirski wrote: >>> On Thu, Jun 7, 2018 at 7:41 AM Yu-cheng Yu wrote: >>>> >>>> When fork() specifies CLONE_VM but not CLONE_VFORK, the child >>>> needs a separate program stack and a separate shadow stack. >>>> This patch handles allocation and freeing of the thread shadow >>>> stack. >>> >>> Aha -- you're trying to make this automatic. I'm not convinced this >>> is a good idea. The Linux kernel has a long and storied history of >>> enabling new hardware features in ways that are almost entirely >>> useless for userspace. >>> >>> Florian, do you have any thoughts on how the user/kernel interaction >>> for the shadow stack should work? >> >> I have not looked at this in detail, have not played with the emulator, >> and have not been privy to any discussions before these patches have >> been posted, however … >> >> I believe that we want as little code in userspace for shadow stack >> management as possible. One concern I have is that even with the code >> we arguably need for various kinds of stack unwinding, we might have >> unwittingly built a generic trampoline that leads to full CET bypass. > > I was imagining an API like "allocate a shadow stack for the current > thread, fail if the current thread already has one, and turn on the > shadow stack". glibc would call clone and then call this ABI pretty > much immediately (i.e. before making any calls from which it expects > to return). Ahh. So you propose not to enable shadow stack enforcement on the new thread even if it is enabled for the current thread? For the cases where CLONE_VM is involved? It will still need a new assembler wrapper which sets up the shadow stack, and it's probably required to disable signals. I think it should be reasonable safe and actually implementable. But the benefits are not immediately obvious to me. > We definitely want strong enough user control that tools like CRIU can > continue to work. I haven't looked at the SDM recently enough to > remember for sure, but I'm reasonably confident that user code can > learn the address of its own shadow stack. If nothing else, CRIU > needs to be able to restore from a context where there's a signal on > the stack and the signal frame contains a shadow stack pointer. CRIU also needs the shadow stack *contents*, which shouldn't be directly available to the process. So it needs very special interfaces anyway. Does CRIU implement MPX support? Thanks, Florian