From mboxrd@z Thu Jan 1 00:00:00 1970 From: 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> Return-path: Sender: linux-kernel-owner@vger.kernel.org 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 List-Id: linux-arch.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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: 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> Sender: linux-arch-owner@vger.kernel.org List-ID: 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 Message-ID: <20180607143757.4VnZ4xP3rWD4hPeSlBcY7Qb5u5H2gRpfFstx7_vyQF8@z> 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