Received: by 10.223.164.200 with SMTP id h8csp932788wrb; Mon, 6 Nov 2017 01:13:37 -0800 (PST) X-Google-Smtp-Source: ABhQp+TmdZ77HV+GyQkA/T/J+vekNOYy5gOjVDxmKGrOdYvJ1R7NHpY+36WB/wLeUMq32JlUkc8u X-Received: by 10.98.63.213 with SMTP id z82mr16338404pfj.10.1509959617108; Mon, 06 Nov 2017 01:13:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509959617; cv=none; d=google.com; s=arc-20160816; b=YOknOqA36lC8XnkR8Zdo3VOmnNNf5twzDkko/r4pCGPNioIsYdSaUfdGCkCNIADhWo 2jDap+5J9N4rgRiVD8882eQLg82W+dQwKo23CED9FM4OgyGgvMaF567IP4NAV7MyphRB 732jnycy2kneIPNqB4ycqPOhEd2aUzNGSN/gidY16ZQiybJ+bzRfsYE7hy30hK4RFiek TGQ7kfFjVJkPPfzlY1WdetVCcIByWVoyWRkJAUK0QxQkFzzyr4PzXrmD+egQjyHH+IsO WxmzSJUWT68q+rgxFjsyW8KfrPb+CYm+bpCyJbsrJpqrM8fSlXih2u8K3h0WXUcr9kt8 t3SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/EBIOgIYQtij3vYzKPu8nWMJXTO2U+bzGqKC64EXsWY=; b=wQc7YojZ0v/4udsqEy8R1g6rqqe2IQwnfyeQNHtvJqNaLP0ZMO+YuALLlfkt7YC1XG SJbYhFKsATR6d/iD/Y0vwhTc+aJ37gwPBCVx+ksaVjHmYxf+iJfW/ambCNV4zbjCczid 4jLzA398+QqK52E4kJxO/Ng0YSuzjXDbU4k/BRRqbYM5SD9cJP/2uV1oxBLW9BL2y0mj lJdeeQd/966vf9LU7Xdp7D+COeY5oQhEqt1uOUgI+uRchupebQC92z1vxB00X0dgnWgc EInn7XqwBzwRIIUhSnugeWngA7WxCCmTZ5aM/hh/FKHWr67i3DxDfkvoviRFJFbX3+W8 lioQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WfQPFO9X; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si10035620plp.177.2017.11.06.01.13.23; Mon, 06 Nov 2017 01:13:37 -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=fail header.i=@gmail.com header.s=20161025 header.b=WfQPFO9X; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752453AbdKFI7i (ORCPT + 98 others); Mon, 6 Nov 2017 03:59:38 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:50933 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752419AbdKFI7d (ORCPT ); Mon, 6 Nov 2017 03:59:33 -0500 Received: by mail-qk0-f194.google.com with SMTP id o187so10008493qke.7; Mon, 06 Nov 2017 00:59:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=/EBIOgIYQtij3vYzKPu8nWMJXTO2U+bzGqKC64EXsWY=; b=WfQPFO9XvL76n6T0Qtq9rknaFilHSw0pXM/0HBQ0Vw0zefG/FyZaD3bCU0LX5KzVj0 YEjZjWY+nzvUTUZUNLOoOgaMB9bwkVqZ/F/NYTB8ClnUoJye8zskjG33bf0spOCVH7aD 6cEEdbdNMsjXeEmR3SadEvoiZPUchvWxN1fgj8+g2BsV1mKaIq24Z/f2BDyn8lxva9z+ kO7cVZQa/yL3XDZgdr+GGxQkvFPgSzInzCkbQHf7ZMjMfoabtGFuuM5vRs3ik4PhbO/Y jSb9iA5ULnro/pL/B1hKD+Syqg6u76IC9m3lF3XzxUotESUMPr86gDJmqgc80WtEolsT XSrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=/EBIOgIYQtij3vYzKPu8nWMJXTO2U+bzGqKC64EXsWY=; b=BuRHUMihw/2JUiS6/LBY8FdkebUYOLryrtIWVYsCw8O8DPovN11/OoM7x/g58sz4Wa oXTY38fJq9N4izh8R5eTKvuBv25oKs91qOzBV9xtlV9E2xJx3y78KNHQ0UAusP/57F/R s8mCaQOvhuhQdWBUNhmcZ5XO8rv/6Jpru8MXXXODPeZQM3h84hPaEnJ8Vie66SsNnzf4 qSAbzmMWOm3lpTQUfRs1xm9gCoc3e9f6HcJ4Dk3H6UzoCOhEpk5hCpDnukNkFnyZhLYz GFrEzqsgGZqgUOjbMLeXT5XfOXONgUmixmAeXePG5tnH6/TQtQIl9/C46XSLopjNNMrO +TYA== X-Gm-Message-State: AJaThX6RBVFpcurru+siaB8Okym6TfUGI5YVgdiucmLx+v6bypSh+Hu3 9H/HVznNk24Vir3iVkUmLFo= X-Received: by 10.55.179.196 with SMTP id c187mr20981560qkf.249.1509958772546; Mon, 06 Nov 2017 00:59:32 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id r26sm8001094qki.42.2017.11.06.00.59.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 00:59:32 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com, linuxram@us.ibm.com Subject: [PATCH v9 26/51] powerpc: add sys_pkey_modify() system call Date: Mon, 6 Nov 2017 00:57:18 -0800 Message-Id: <1509958663-18737-27-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> References: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sys_pkey_modify() is powerpc specific system call. It enables the ability to modify *any* attribute of a key. Since powerpc disallows modification of IAMR from user space an application is unable to change a key's execute-attribute. This system call helps accomplish the above. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/systbl.h | 1 + arch/powerpc/include/asm/unistd.h | 2 +- arch/powerpc/include/uapi/asm/unistd.h | 1 + arch/powerpc/kernel/entry_64.S | 9 +++++++++ arch/powerpc/mm/pkeys.c | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h index d61f9c9..533cdc5 100644 --- a/arch/powerpc/include/asm/systbl.h +++ b/arch/powerpc/include/asm/systbl.h @@ -392,3 +392,4 @@ SYSCALL(pkey_alloc) SYSCALL(pkey_free) SYSCALL(pkey_mprotect) +PPC64ONLY(pkey_modify) diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h index daf1ba9..1e97086 100644 --- a/arch/powerpc/include/asm/unistd.h +++ b/arch/powerpc/include/asm/unistd.h @@ -12,7 +12,7 @@ #include -#define NR_syscalls 387 +#define NR_syscalls 388 #define __NR__exit __NR_exit diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h index 389c36f..318cd79 100644 --- a/arch/powerpc/include/uapi/asm/unistd.h +++ b/arch/powerpc/include/uapi/asm/unistd.h @@ -398,5 +398,6 @@ #define __NR_pkey_alloc 384 #define __NR_pkey_free 385 #define __NR_pkey_mprotect 386 +#define __NR_pkey_modify 387 #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 4a0fd4f..47c85f9 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -455,6 +455,15 @@ _GLOBAL(ppc_switch_endian) bl sys_switch_endian b .Lsyscall_exit +_GLOBAL(ppc_pkey_modify) + bl save_nvgprs +#ifdef CONFIG_PPC_MEM_KEYS + bl sys_pkey_modify +#else + bl sys_ni_syscall +#endif + b .Lsyscall_exit + _GLOBAL(ret_from_fork) bl schedule_tail REST_NVGPRS(r1) diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index 5047371..2612f61 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm/pkeys.c @@ -420,3 +420,20 @@ bool arch_vma_access_permitted(struct vm_area_struct *vma, bool write, return pkey_access_permitted(vma_pkey(vma), write, execute); } + +long sys_pkey_modify(int pkey, unsigned long new_val) +{ + bool ret; + /* Check for unsupported init values */ + if (new_val & ~PKEY_ACCESS_MASK) + return -EINVAL; + + down_write(¤t->mm->mmap_sem); + ret = mm_pkey_is_allocated(current->mm, pkey); + up_write(¤t->mm->mmap_sem); + + if (!ret) + return -EINVAL; + + return __arch_set_user_pkey_access(current, pkey, new_val); +} -- 1.7.1 From 1583307962777472105@xxx Mon Nov 06 09:22:19 +0000 2017 X-GM-THRID: 1583307962777472105 X-Gmail-Labels: Inbox,Category Promotions,HistoricalUnread