From patchwork Fri Sep 7 22:34:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 10592651 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 A4E441515 for ; Fri, 7 Sep 2018 22:34:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 943342B030 for ; Fri, 7 Sep 2018 22:34:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88B792B12D; Fri, 7 Sep 2018 22:34:22 +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=unavailable 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 2B9E32B030 for ; Fri, 7 Sep 2018 22:34:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A77D8E0005; Fri, 7 Sep 2018 18:34:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5300C8E0001; Fri, 7 Sep 2018 18:34:21 -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 3D2778E0005; Fri, 7 Sep 2018 18:34:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id EC5EC8E0001 for ; Fri, 7 Sep 2018 18:34:20 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id u13-v6so8068587pfm.8 for ; Fri, 07 Sep 2018 15:34:20 -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:date:from:to :cc:subject:message-id:references:mime-version:content-disposition :in-reply-to:user-agent; bh=IVltMZcLvXCu7eahft+qTtP8/V/q04bfidCXE5Op37A=; b=mJgvNIAhYcwBD1CF1EpHdrHPxVzoZaAW1VAgLmjEhvvVbE7K/9mT7dz2zJT2e8e+uR +GYyYiepTYXNolSa4Kr6yPz6esCQRjZARv8isUOj87LaUdZ3FNma/e7I3iEPPYRSGX2Q UC/hLe8i6mnv5VRxdlvlwASqpxRdDbh1YSPcpUnMcGNsxfdwqnXDJE6JkeuVMoN78+Gr +jo3poAWYfugwvKGu4+U3ioYTh0VxuF4H3zf/51QDm494ZBZPRD85++g9TUFPCdBrN95 SrSbm/o2whT+pJ3aA7tFHb+3byA/ANDt5iVoHfXqcC9FdyQ6xVhHuMb1SkVWKs52wESu Bhrg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of alison.schofield@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=alison.schofield@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APzg51D5BM8iCBnqkNaYiWegjdZTFW+fm4AHYEd8HBlMQp3IBR0/lBuW js+mwASG+WftujkQOvBHS44JcuB3zPQf03V1JZxDWkBAOTMO6SwF9Rl+VSAx7u9QpxVXouF2Htj oqF9GbUimIJmmYXBg1JzprtKAUCXzenpQ4Y8rdPMnvWJdgIgMEiZGzzjfHJZdFhlurw== X-Received: by 2002:a63:6a06:: with SMTP id f6-v6mr10488157pgc.63.1536359660632; Fri, 07 Sep 2018 15:34:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY1Pf/CeykUu9COhPb8JoeNz37kBoBfwDYDqvgrC6sXK9OisHp7e7vPhQqBnBRQUHQx1DPk X-Received: by 2002:a63:6a06:: with SMTP id f6-v6mr10488114pgc.63.1536359659843; Fri, 07 Sep 2018 15:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536359659; cv=none; d=google.com; s=arc-20160816; b=bowLIN1+7pfauI9ZYNxxNjqQeU/ZtkLkAArQXhZYaM19EpXg1VNBcytbgO/eZPF3+h v2XP8DhQCEXM0NYlK4rpM1KoaTaQOlNYbUMyr4KHw5W0gOLlVr4PKlAHbbWuv5TW776l 0JmytQEIgGAFOJ/ZM7e3LPUYI64K0y6CPPOYmsgWdQFnNipg15YoS1hW7KNzXjYQd6R8 sEkJgIPsDVSq7Zn1f6PaRKuBSpOAieDulUPz/n9+BWz5AvKNrL0gysudsRoIHMMJ66Wp tFkfeIGtn//w3wBzycYxeJS5nSK/1DsjgcWl2fZ1YOUZDBqy+xZdlrH0LDELyY/GetYt ghCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date; bh=IVltMZcLvXCu7eahft+qTtP8/V/q04bfidCXE5Op37A=; b=ja8BZGDncYtMOugp9f8IzhYA6vQBdi9pLy8uIqUtJddyuertdAvxQC0zDyTdNYr7K4 0JEGQS5lXIuW0xRUubzs9aYIj/a6xdqyQYNCoSWP1XKOajCmxfnnYZVhR/6ZMXc/7y5D rMfZ4Q12VCRSoS1pCdSGKEBQhufTxk7/mFNvApRxt984w3N1M2MQUzRjgz1wGuuXoBlx lWEgWuc40uHd+25jmn+vsm5h5L2HobccwUXeVw+Wh1nvTHtxWfeN1e5JuJLB1xE10iHu ZnpgrQomJPGMAqVewi/9U43w03OBDMR0AkmZAMf+LkxZvzkZni2YC4ivRQWIH7d8YP3E nIvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of alison.schofield@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=alison.schofield@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id g10-v6si9006002pgl.425.2018.09.07.15.34.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 15:34:19 -0700 (PDT) Received-SPF: pass (google.com: domain of alison.schofield@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of alison.schofield@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=alison.schofield@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 15:34:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,344,1531810800"; d="scan'208";a="260815502" Received: from alison-desk.jf.intel.com ([10.54.74.53]) by fmsmga005.fm.intel.com with ESMTP; 07 Sep 2018 15:34:12 -0700 Date: Fri, 7 Sep 2018 15:34:54 -0700 From: Alison Schofield To: dhowells@redhat.com, tglx@linutronix.de Cc: Kai Huang , Jun Nakajima , Kirill Shutemov , Dave Hansen , Jarkko Sakkinen , jmorris@namei.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-mm@kvack.org Subject: [RFC 03/12] syscall/x86: Wire up a new system call for memory encryption keys Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) 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 encrypt_mprotect() is a new system call to support memory encryption. It takes the same parameters as legacy mprotect, plus an additional key serial number that is mapped to an encryption keyid. Signed-off-by: Alison Schofield --- arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + include/linux/syscalls.h | 2 ++ include/uapi/asm-generic/unistd.h | 4 +++- kernel/sys_ni.c | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index 3cf7b533b3d1..f41ad857d5c6 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -398,3 +398,4 @@ 384 i386 arch_prctl sys_arch_prctl __ia32_compat_sys_arch_prctl 385 i386 io_pgetevents sys_io_pgetevents __ia32_compat_sys_io_pgetevents 386 i386 rseq sys_rseq __ia32_sys_rseq +387 i386 encrypt_mprotect sys_encrypt_mprotect __ia32_sys_encrypt_mprotect diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index f0b1709a5ffb..cf2decfa6119 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -343,6 +343,7 @@ 332 common statx __x64_sys_statx 333 common io_pgetevents __x64_sys_io_pgetevents 334 common rseq __x64_sys_rseq +335 common encrypt_mprotect __x64_sys_encrypt_mprotect # # x32-specific system call numbers start at 512 to avoid cache impact diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 3ed377d0c46c..7dc0ed3a182e 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -904,6 +904,8 @@ asmlinkage long sys_statx(int dfd, const char __user *path, unsigned flags, unsigned mask, struct statx __user *buffer); asmlinkage long sys_rseq(struct rseq __user *rseq, uint32_t rseq_len, int flags, uint32_t sig); +asmlinkage long sys_encrypt_mprotect(unsigned long start, size_t len, + unsigned long prot, int serial); /* * Architecture-specific system calls diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 42990676a55e..d2cb0af68160 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -734,9 +734,11 @@ __SYSCALL(__NR_pkey_free, sys_pkey_free) __SYSCALL(__NR_statx, sys_statx) #define __NR_io_pgetevents 292 __SC_COMP(__NR_io_pgetevents, sys_io_pgetevents, compat_sys_io_pgetevents) +#define __NR_encrypt_mprotect 293 +__SYSCALL(__NR_encrypt_mprotect, sys_encrypt_mprotect) #undef __NR_syscalls -#define __NR_syscalls 293 +#define __NR_syscalls 294 /* * 32 bit systems traditionally used different diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index df556175be50..1b48f709c265 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -336,6 +336,8 @@ COND_SYSCALL(pkey_mprotect); COND_SYSCALL(pkey_alloc); COND_SYSCALL(pkey_free); +/* multi-key total memory encryption keys */ +COND_SYSCALL(encrypt_mprotect); /* * Architecture specific weak syscall entries.