Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4049463ybv; Tue, 25 Feb 2020 12:08:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzx3pGxQVdnCFnC+nmeg3DqovCehV9Y9d2qfzE84zzsuBHRcNyy9B0iLJt9+0+YybOWN/Rn X-Received: by 2002:a9d:7509:: with SMTP id r9mr244198otk.270.1582661339650; Tue, 25 Feb 2020 12:08:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582661339; cv=none; d=google.com; s=arc-20160816; b=muo5tqTPRBP2Y/3R9Q4YIIM/5jus7RcfJlAFsqcIHa4m9i7KVHjXhzBd/QGyj4YoEp EYIAq4mgOZGUdxv9CzSe5EMWNGicDR69hCH77CUInJ4ah19xHBRjMy8HGLvkx9fFmWhE ZnAzk0OVR3JbMonS9yAJ4JVRjRISEOy1FSQ4dUmM684GoUN5NLVzpYHgqGaf0X+DjTbZ Kr8lHrO3Ugtrr8H9QVX9K09s9EL/qE44vTaSj6dGrkvyqpGoxTyf1BzvY2Km9CT//3EG 8eU0JaHYgMCmvd4F5oDrxPJM1k6T6VfAUeaeOYXkrFJkFsvLayBegXcpTYqEUPcqv4sF PwmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+pmf0q/yQobAoH/07ZbYSuskhk1jR7zZpMRJsChqv5g=; b=R+eu72Yfg4Ttu3ge6D0gywXl9ZEQBxl384X5gytTwugVo+VPGWE8Sr6W1u6mWLy3kJ Ep60dFNxW30H3RSd+w1eF9pV+rrSXtnW/ZHVpjq30VWTCmDq/TM8SMxnmtLKzq6hRc16 Sggr/2qR86tYl0tdBLk8/j9GCPoYjbRESXMuovcoKmaIhGlmEl9kwjZHqPVIdkC0TjMp 3GOx0QCh8c47lMjGHEPCSSqe+03hHBz/2/a5XJ2lgDKD9GSCEK2Ok+3QXu1OpXDCqdKr syq4PFvGZOUcV8F6HgqGx2rZFS7f4mZ9fyZGihIFXnPsDkEM3wqGD6IZoeJ8m76cB20G zzIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DWyaKOrn; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s129si112422oig.177.2020.02.25.12.08.44; Tue, 25 Feb 2020 12:08:59 -0800 (PST) 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=@chromium.org header.s=google header.b=DWyaKOrn; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731382AbgBYUHL (ORCPT + 99 others); Tue, 25 Feb 2020 15:07:11 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:50450 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731173AbgBYUHK (ORCPT ); Tue, 25 Feb 2020 15:07:10 -0500 Received: by mail-pj1-f66.google.com with SMTP id r67so203861pjb.0 for ; Tue, 25 Feb 2020 12:07:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+pmf0q/yQobAoH/07ZbYSuskhk1jR7zZpMRJsChqv5g=; b=DWyaKOrnA08bBBHiKbZV/oqpfDg5UAsqlM4nMGy5LWYLGlIhGwPIeKPvvUgnp2P33d dHeMtxvgTcqqMvW5CAqjji0CUw0/KKZOWJA6mkJaDIrODjVQ0uQh7xr84QPagG9oyfRs cCjOIB8MTl0+UKHUtGEaEJutf29gnAQLCtmKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+pmf0q/yQobAoH/07ZbYSuskhk1jR7zZpMRJsChqv5g=; b=uZrENj4EuJuD/AbM4xHSr9WqOpFyCtYIPnId0Sj0G3BOCq1d2j+fZO5LBnz/glen/a HZuUXrjBCIPOapkiGC185VgISOrsdCeJ4dykBOpQ5BQEVTVF/SXl6APzkst4b6e5oQFq 4fie2OE9fnKSYnV6YHno/83xjLeISIXgk1/aDtwyMyuUgmOjs3plWV7VnBaKXyFjorlp 9+LVWUj1Th+hSVKLolmtUPe/g0Rw4PS9vK89IHWlgdRDkP4XhGWQyYHt8zFN+CopBW/B g7T8W0nsqHBqudqMekzBOeiz+qCGmlihQd3da8AYBYskKlAxH+KXoTub5KTZrwpzNY2H DLEA== X-Gm-Message-State: APjAAAVmRdCHqATQ/0iSDuZ5wjAYViS5qKaeXBJ8ZyJkSDUH1usFFXUk RcFUvZT6lqLMvGSpMRKCT/KGXw== X-Received: by 2002:a17:902:a414:: with SMTP id p20mr218843plq.7.1582661229878; Tue, 25 Feb 2020 12:07:09 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id f8sm17972057pfn.2.2020.02.25.12.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 12:07:09 -0800 (PST) Date: Tue, 25 Feb 2020 12:07:07 -0800 From: Kees Cook To: Yu-cheng Yu Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , x86-patch-review@intel.com Subject: Re: [RFC PATCH v9 05/27] x86/cet/shstk: Add Kconfig option for user-mode Shadow Stack protection Message-ID: <202002251206.43C6B6DA@keescook> References: <20200205181935.3712-1-yu-cheng.yu@intel.com> <20200205181935.3712-6-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200205181935.3712-6-yu-cheng.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 05, 2020 at 10:19:13AM -0800, Yu-cheng Yu wrote: > Introduce Kconfig option: X86_INTEL_SHADOW_STACK_USER. > > Shadow Stack (SHSTK) provides protection against function return address > corruption. It is active when the kernel has this feature enabled, and > both the processor and the application support it. When this feature is > enabled, legacy non-SHSTK applications continue to work, but without SHSTK > protection. > > The user-mode SHSTK protection is only implemented for the 64-bit kernel. > IA32 applications are supported under the compatibility mode. > > Signed-off-by: Yu-cheng Yu > --- > arch/x86/Kconfig | 22 ++++++++++++++++++++++ > arch/x86/Makefile | 7 +++++++ > 2 files changed, 29 insertions(+) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 5e8949953660..6c34b701c588 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -1974,6 +1974,28 @@ config X86_INTEL_TSX_MODE_AUTO > side channel attacks- equals the tsx=auto command line parameter. > endchoice > > +config X86_INTEL_CET > + def_bool n > + > +config ARCH_HAS_SHSTK > + def_bool n > + > +config X86_INTEL_SHADOW_STACK_USER > + prompt "Intel Shadow Stack for user-mode" > + def_bool n > + depends on CPU_SUP_INTEL && X86_64 > + select ARCH_USES_HIGH_VMA_FLAGS > + select X86_INTEL_CET > + select ARCH_HAS_SHSTK > + ---help--- > + Shadow Stack (SHSTK) provides protection against program > + stack corruption. It is active when the kernel has this > + feature enabled, and the processor and the application > + support it. When this feature is enabled, legacy non-SHSTK > + applications continue to work, but without SHSTK protection. > + > + If unsure, say y. > + > config EFI > bool "EFI runtime service support" > depends on ACPI > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > index 94df0868804b..c34f5befa4c8 100644 > --- a/arch/x86/Makefile > +++ b/arch/x86/Makefile > @@ -149,6 +149,13 @@ ifdef CONFIG_X86_X32 > endif > export CONFIG_X86_X32_ABI > > +# Check assembler Shadow Stack suppot > +ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER > + ifeq ($(call as-instr, saveprevssp, y),) This test needs to happen in the Kconfig rather than the Makefile; the CONFIG should be unavailable if AS doesn't support the feature. -Kees > + $(error CONFIG_X86_INTEL_SHADOW_STACK_USER not supported by the assembler) > + endif > +endif > + > # > # If the function graph tracer is used with mcount instead of fentry, > # '-maccumulate-outgoing-args' is needed to prevent a GCC bug > -- > 2.21.0 > -- Kees Cook