From patchwork Thu Oct 11 15:16:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10636903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3AFC17E1 for ; Thu, 11 Oct 2018 15:22:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2FEB2BA4A for ; Thu, 11 Oct 2018 15:22:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C097D2BA56; Thu, 11 Oct 2018 15:22:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38CA02BA53 for ; Thu, 11 Oct 2018 15:22:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08A256B0296; Thu, 11 Oct 2018 11:21:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EB1976B0298; Thu, 11 Oct 2018 11:21:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D04A86B0299; Thu, 11 Oct 2018 11:21:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 852326B0296 for ; Thu, 11 Oct 2018 11:21:44 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id 43-v6so6555152ple.19 for ; Thu, 11 Oct 2018 08:21:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=uwN6lSqu61OmoMx1DdBRIDCtLA1w09JxwXsSi1y6cOQ=; b=WueVv4EGH9whivPlhCYiNnZG5rKESg3rRQ4LnYuqdJ/js9dCfNOWe5nFJChYUQR1De 30ka6UMKWJsKTG4gCtX837+qly4zQQ3YTjYMCHZZdy5iyGgtbEdAdx3ibuZui7vc9Qcm 2+2cEsgQ3H5Ds15eOQ1VDboEporCR+f7Kls3o+SVtkcmfGEXS+nPh/8IdfXRW74ahgww EhSVJvgUa449bXTnjsFIEzB1j34ZkZZqeajp49KPhXeOxA+G97V0e6cZg65SizaGaQlp ewmWOYzw4drhvSGO7onODUXKrQe+fC/iQy2aOYELPAhz38BR6iARpQKWq3rNLLeV/ogB oj7Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfogAISmW5xNvMIcsJx0vMFJFxdJUohvu03IO02IEAswP7UIH54sR RXhOzHqL6lAfC1VGcTTQRYpFihxV379l3z979jCWzJ4DYjl0FPB02VgDmjR72yVRWeyr7mHGrck yD7fh8vSgEv+mQxdrmey3kXjz/IPh0I3PWaRfyoXcCsFQZQWjbveLSmMuOTMzhkcDmw== X-Received: by 2002:a17:902:6b81:: with SMTP id p1-v6mr2000472plk.162.1539271304136; Thu, 11 Oct 2018 08:21:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV637INqDBIADy5xr26Jkfcs0z5J4FNesthfy0mQW7KWiIiY0rWLzffzgvof7ZOiTFU3DvRhQ X-Received: by 2002:a17:902:6b81:: with SMTP id p1-v6mr2000419plk.162.1539271303436; Thu, 11 Oct 2018 08:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271303; cv=none; d=google.com; s=arc-20160816; b=jrAR7QAayCE5YaQ2nnOhv9Kd9uxCXWQkLeMo7FP5lYij26JstHw0D/krscS00VUhaH vhQrSXmFBroIi+8buBn52tQm4wI+OsTHqvuB0NgAzxc9JBw5DBktzc0JtT35COX9VujJ E04PRz5/Bz7t6JAh1kiXA0pA0dAITssL/fOJ186spP9xwubz1jsexPD8J343Arg7J/Rg UlY6IvK3j91zKJuQp1b+yWxR9S2ty0XwqR6ucHglywMilwoKTwp6qqykW71cqUwEiMno otPjYZoPST7GLpNiHjSEWmzn0yuWDVwSEQ8Yq/MIcs3qC+UHQfhJ/6SjswYsJDHqYaln j7jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=uwN6lSqu61OmoMx1DdBRIDCtLA1w09JxwXsSi1y6cOQ=; b=07rPYieKIFrIcqrjEA1cfIwJnrMqlFaR2W3lnGYbheAj0EQcZhq9kN4sCPhNxvaw12 EfGmsC1q6u7KA+1CddSy+wQH2iYrAA/3ktPxb+gtovjTlbde+W2m1cnUuCFWzsHaH3bv KAgd8t95ykapKl00vMixLjI2EKJTBrUXrAwcrlQYSMmOBfqyOqX0bn1z0vgHjNizJmEx V1OPm0R/rHUMzoE6f8CfOX7meUdq7a0IxbwEl4noD+Y4l3w4Y8kuheeWc14XygCW+pjv b4Cdl3HyoeKFOL7yut/nmEMcRr0zbVtrkqiz3yPT5Q9EvdbqMHQQrUgf85l7RIMrZr0K dG0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id w90-v6si28024425pfk.208.2018.10.11.08.21.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 08:21:43 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) client-ip=134.134.136.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:21:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="77271614" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga007.fm.intel.com with ESMTP; 11 Oct 2018 08:21:42 -0700 From: Yu-cheng Yu To: 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 , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [PATCH v5 00/11] Control Flow Enforcement: Branch Tracking, PTRACE Date: Thu, 11 Oct 2018 08:16:43 -0700 Message-Id: <20181011151654.27221-1-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The previous version of CET Branch Tracking/PTRACE patches is at the following link: https://lkml.org/lkml/2018/9/21/773 Summary of changes from v4: Add ENDBR32/ENDBR64 to vsyscall assembly code. Small cleanups. Small fixes in IBT bitmap allocation. From the discussion of IBT bitmap size, I got: 1. There are potential issues from using TASK_SIZE/TASK_SIZE_MAX; 2. We cannot always depend on in_compat_syscall(); 3. Doing allocation in the kernel is tricky; The bitmap is needed only when an app does dlopen() non-IBT .so files; most applications do not need it. I am proposing that dlopen() does mmap() and passes the bitmap to the kernel. If that is accepted, we can change these patches accordingly. H.J. Lu (3): x86: Insert endbr32/endbr64 to vDSO x86/vsyscall/32: Add ENDBR32 to vsyscall entry point x86/vsyscall/64: Add ENDBR64 to vsyscall entry points Yu-cheng Yu (8): x86/cet/ibt: Add Kconfig option for user-mode Indirect Branch Tracking x86/cet/ibt: User-mode indirect branch tracking support x86/cet/ibt: Add IBT legacy code bitmap allocation function mm/mmap: Add IBT bitmap size to address space limit check x86/cet/ibt: ELF header parsing for IBT x86/cet/ibt: Add arch_prctl functions for IBT x86/cet/ibt: Add ENDBR to op-code-map x86/cet: Add PTRACE interface for CET arch/x86/Kconfig | 16 ++++ arch/x86/Makefile | 7 ++ arch/x86/entry/vdso/.gitignore | 4 + arch/x86/entry/vdso/Makefile | 12 ++- arch/x86/entry/vdso/vdso-layout.lds.S | 1 + arch/x86/entry/vdso/vdso32/system_call.S | 3 + arch/x86/entry/vsyscall/vsyscall_emu_64.S | 9 +++ arch/x86/include/asm/cet.h | 8 ++ arch/x86/include/asm/disabled-features.h | 8 +- arch/x86/include/asm/fpu/regset.h | 7 +- arch/x86/include/asm/mmu_context.h | 7 ++ arch/x86/include/uapi/asm/elf_property.h | 1 + arch/x86/include/uapi/asm/prctl.h | 1 + arch/x86/kernel/cet.c | 78 +++++++++++++++++++ arch/x86/kernel/cet_prctl.c | 35 +++++++++ arch/x86/kernel/cpu/common.c | 17 ++++ arch/x86/kernel/elf.c | 5 ++ arch/x86/kernel/fpu/regset.c | 41 ++++++++++ arch/x86/kernel/process.c | 1 + arch/x86/kernel/ptrace.c | 16 ++++ arch/x86/lib/x86-opcode-map.txt | 13 +++- include/uapi/linux/elf.h | 1 + mm/mmap.c | 19 ++++- tools/objtool/arch/x86/lib/x86-opcode-map.txt | 13 +++- 24 files changed, 313 insertions(+), 10 deletions(-)