Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2322429imm; Thu, 7 Jun 2018 08:46:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI+wWgrxTQz5U0N0d8zPKcqyrv+EAJu6XlBXliN1FE9p/gmENhr8FxF/9HncP5JMPU5uZzL X-Received: by 2002:a63:8c4f:: with SMTP id q15-v6mr2087120pgn.236.1528386365839; Thu, 07 Jun 2018 08:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528386365; cv=none; d=google.com; s=arc-20160816; b=yfDlvsetv0Uh2rRQL20Q0cSfuvIcTVYI+oSF+mnSP/9ZQormjnLpYtkNKDzd+MSCdZ Uz0z70H0uah2WW+KSd2K0jg0HD09OrrEvTaXKVXRw69+A3ETKtS8WxWN5V0GQyQgz+b3 WCkqDLC5qvjA3tuSDRwHSowGKbw8hoolMwMRoBuHBfyoFMB7ekkEcbueIWz356QJcxDF fsvQsTarkttR5Jm4NTA1TenTnJFMMKIKEQzNjQJLZlCDXsfyEd4GAf2GCKqVsByCKcM3 cP+UuNIVb8j0xekDhxlZUZuiv8w1A2IWddeRShz8x0ffmzQ+BovVjbTdKTqviOkF94cq Zg0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ZPbWOI3XHZMlc7fZlMsXduX5bywKYs1PYtPi8msQf0k=; b=NNbu8eXBw4O3kiQFlH8hCFyDai4JwHXM8te+R3WucilWsNFp7JBPb/4tN1bth2geWn V3UWLqfBtm9muFNmMjPt8J4g3yZ24YYGbrNgGI+5/ht1xS/OLooyXkJcyImlODigM5Qn IZIXK3DeQi4QtAxcdUfpR2g097EIn/j2m0lvW8c/OpE5cfukEQTe997o52LdTtJAAVCb k6VENJ39Pmxc+GWrWRW8Xt1MEGFkCD0MZo4yDQ4yFhd03ug0UKAkjRyudIq8A/7/gx7z QqXDypG/A3PhHrDTRyevQDWu/f7vGErtIcDaOqC9NRor/LxHdEMZlHe13QcZ4Lrg64YU zRhA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3-v6si417625pgp.527.2018.06.07.08.45.48; Thu, 07 Jun 2018 08:46: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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934669AbeFGPnm (ORCPT + 99 others); Thu, 7 Jun 2018 11:43:42 -0400 Received: from mga09.intel.com ([134.134.136.24]:36344 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934259AbeFGOl3 (ORCPT ); Thu, 7 Jun 2018 10:41:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 07:41:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="62632615" Received: from 2b52.sc.intel.com ([143.183.136.51]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2018 07:41:28 -0700 From: Yu-cheng Yu To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H.J. Lu" , Vedvyas Shanbhogue , "Ravi V. Shankar" , Dave Hansen , Andy Lutomirski , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , Mike Kravetz Cc: Yu-cheng Yu Subject: [PATCH 00/10] Control Flow Enforcement - Part (3) Date: Thu, 7 Jun 2018 07:37:57 -0700 Message-Id: <20180607143807.3611-1-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series introduces CET - Shadow stack At the high level, shadow stack is: Allocated from a task's address space with vm_flags VM_SHSTK; Its PTEs must be read-only and dirty; Fixed sized, but the default size can be changed by sys admin. For a forked child, the shadow stack is duplicated when the next shadow stack access takes place. For a pthread child, a new shadow stack is allocated. The signal handler uses the same shadow stack as the main program. Yu-cheng Yu (10): x86/cet: User-mode shadow stack support x86/cet: Introduce WRUSS instruction x86/cet: Signal handling for shadow stack x86/cet: Handle thread shadow stack x86/cet: ELF header parsing of Control Flow Enforcement x86/cet: Add arch_prctl functions for shadow stack mm: Prevent mprotect from changing shadow stack mm: Prevent mremap of shadow stack mm: Prevent madvise from changing shadow stack mm: Prevent munmap and remap_file_pages of shadow stack arch/x86/Kconfig | 4 + arch/x86/ia32/ia32_signal.c | 5 + arch/x86/include/asm/cet.h | 48 ++++++ arch/x86/include/asm/disabled-features.h | 8 +- arch/x86/include/asm/elf.h | 5 + arch/x86/include/asm/mmu_context.h | 3 + arch/x86/include/asm/msr-index.h | 14 ++ arch/x86/include/asm/processor.h | 5 + arch/x86/include/asm/special_insns.h | 44 +++++ arch/x86/include/uapi/asm/elf_property.h | 16 ++ arch/x86/include/uapi/asm/prctl.h | 15 ++ arch/x86/include/uapi/asm/sigcontext.h | 4 + arch/x86/kernel/Makefile | 4 + arch/x86/kernel/cet.c | 224 ++++++++++++++++++++++++ arch/x86/kernel/cet_prctl.c | 203 ++++++++++++++++++++++ arch/x86/kernel/cpu/common.c | 24 +++ arch/x86/kernel/elf.c | 236 ++++++++++++++++++++++++++ arch/x86/kernel/process.c | 10 ++ arch/x86/kernel/process_64.c | 7 + arch/x86/kernel/signal.c | 11 ++ arch/x86/lib/x86-opcode-map.txt | 2 +- arch/x86/mm/fault.c | 13 +- fs/binfmt_elf.c | 16 ++ fs/proc/task_mmu.c | 3 + include/uapi/linux/elf.h | 1 + mm/madvise.c | 9 + mm/mmap.c | 13 ++ mm/mprotect.c | 9 + mm/mremap.c | 5 +- tools/objtool/arch/x86/lib/x86-opcode-map.txt | 2 +- 30 files changed, 958 insertions(+), 5 deletions(-) create mode 100644 arch/x86/include/asm/cet.h create mode 100644 arch/x86/include/uapi/asm/elf_property.h create mode 100644 arch/x86/kernel/cet.c create mode 100644 arch/x86/kernel/cet_prctl.c create mode 100644 arch/x86/kernel/elf.c -- 2.15.1