From patchwork Fri Mar 11 00:57:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1604209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BxtcDwbW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KF6yP3cC9z9sGF for ; Fri, 11 Mar 2022 11:59:08 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KF6yL2jwlz30Lq for ; Fri, 11 Mar 2022 11:59:06 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BxtcDwbW; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ira.weiny@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BxtcDwbW; dkim-atps=neutral Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KF6y45pt1z2ybD for ; Fri, 11 Mar 2022 11:58:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646960332; x=1678496332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qdRZwcheezTGfs6H8foja5La9g1WfULiBkuZy4sc1Hs=; b=BxtcDwbWtkpXY/l53P9rL7c3ZeERoWOVEgqczzddCk1IFlMttAoNDd+i qJZVfunngX620Ga0A86ToxMLuTTd00gSm+2y/0dt2qj4TiO4hdsuvVGJY apRWxKgLcIh+RJc98PKtAmxBaYaJ4D/6sx3flsxoqJJeiMDn3HdeNj2pd rB5BAz/NGnghdnw4S1jMoUL/bMLd4ica/ztVM2yFpEBCK0yjbvxFZjWSg hrZ5+JP0Nos6716txLAuUR3XlLJQq8bowAhOJ7mT4mpRcIkjkwzXPf3IG OHWE5Ea+R6xoBXnkSERl8Lf9lJQM9PZqBc2BHvn+8QJydGrlgr56TmhRY g==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="341883870" X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="341883870" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:45 -0800 X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="538750557" Received: from gdavids1-mobl.amr.corp.intel.com (HELO localhost) ([10.212.65.108]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:45 -0800 From: ira.weiny@intel.com To: Dave Hansen , "Aneesh Kumar K.V" Subject: [PATCH 1/5] x86/pkeys: Clean up arch_set_user_pkey_access() declaration Date: Thu, 10 Mar 2022 16:57:38 -0800 Message-Id: <20220311005742.1060992-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311005742.1060992-1-ira.weiny@intel.com> References: <20220311005742.1060992-1-ira.weiny@intel.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, "Edgecombe, Rick P" , Ira Weiny , linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Ira Weiny arch_set_user_pkey_access() was declared two times in the header. Remove the 2nd declaration. Suggested-by: "Edgecombe, Rick P" Signed-off-by: Ira Weiny --- arch/x86/include/asm/pkeys.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h index 1d5f14aff5f6..9c530530b9a7 100644 --- a/arch/x86/include/asm/pkeys.h +++ b/arch/x86/include/asm/pkeys.h @@ -118,8 +118,6 @@ int mm_pkey_free(struct mm_struct *mm, int pkey) return 0; } -extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, - unsigned long init_val); extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, unsigned long init_val); From patchwork Fri Mar 11 00:57:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1604211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jYaUA3A0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KF6zf5Dcdz9sGF for ; Fri, 11 Mar 2022 12:00:14 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KF6zf33xrz3bk8 for ; Fri, 11 Mar 2022 12:00:14 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jYaUA3A0; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ira.weiny@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jYaUA3A0; dkim-atps=neutral Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KF6y61M9Sz2y6K for ; Fri, 11 Mar 2022 11:58:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646960334; x=1678496334; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9siIY6FLOfYc5ocEKvjG/SmhAvdKrtM6lD3UINVbS4o=; b=jYaUA3A0rRLiYS2AG4WxwSXUyYk96WWdI3W1UqB4O+eA4fehAK9VQ7Zw P8q+MITQ1hMAweKubQQn681Qm6cTkt2Rzf6GC3skeyYNvRJbowoY6di7u HPHeGb1KqZFRtnjL27hRTiFfi7R+J7TJXGUH65eKYvqWo9Xk67c0L/oS4 SC/8ralXTcNH/juTb21bQm2+e/Ym4O3TcRJ2kN5NpY0C9CRhpX9+yG/Uy fcjFH20qpTJVFf/x5Tqrvd+cE5h5BagmG8RreOQzfHzDKUoTgOJ0RLhJL Xb94C/75moTI3pc+jqexNaoikCuOY0lRr51b/xjwRvwfTKcOk68SIZl3v w==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="341883872" X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="341883872" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:46 -0800 X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="554989174" Received: from gdavids1-mobl.amr.corp.intel.com (HELO localhost) ([10.212.65.108]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:46 -0800 From: ira.weiny@intel.com To: Dave Hansen , "Aneesh Kumar K.V" Subject: [PATCH 2/5] x86/pkeys: Remove __arch_set_user_pkey_access() declaration Date: Thu, 10 Mar 2022 16:57:39 -0800 Message-Id: <20220311005742.1060992-3-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311005742.1060992-1-ira.weiny@intel.com> References: <20220311005742.1060992-1-ira.weiny@intel.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, "Edgecombe, Rick P" , Ira Weiny , linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Ira Weiny In the x86 code __arch_set_user_pkey_access() is not used and is not defined. Remove the dead declaration. To: Dave Hansen Signed-off-by: Ira Weiny --- Changes from V1: Make this part of a series of pkey clean ups --- arch/x86/include/asm/pkeys.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h index 9c530530b9a7..2e6c04d8a45b 100644 --- a/arch/x86/include/asm/pkeys.h +++ b/arch/x86/include/asm/pkeys.h @@ -41,9 +41,6 @@ static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma, return __arch_override_mprotect_pkey(vma, prot, pkey); } -extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, - unsigned long init_val); - #define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | VM_PKEY_BIT3) #define mm_pkey_allocation_map(mm) (mm->context.pkey_allocation_map) @@ -118,9 +115,6 @@ int mm_pkey_free(struct mm_struct *mm, int pkey) return 0; } -extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, - unsigned long init_val); - static inline int vma_pkey(struct vm_area_struct *vma) { unsigned long vma_pkey_mask = VM_PKEY_BIT0 | VM_PKEY_BIT1 | From patchwork Fri Mar 11 00:57:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1604212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=myjLC7Qc; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KF70K0KXXz9s09 for ; Fri, 11 Mar 2022 12:00:49 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KF70J6g5tz3bfK for ; Fri, 11 Mar 2022 12:00:48 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=myjLC7Qc; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ira.weiny@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=myjLC7Qc; dkim-atps=neutral Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KF6y70Hp9z2y6K for ; Fri, 11 Mar 2022 11:58:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646960335; x=1678496335; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wzyA39JwdZxDDT/IXqrk8/yZKwNXu3aWKvXpfEakV14=; b=myjLC7Qccht0V//IVp3/bSaPHy9+OW+SAE/fSb94QUiI1gym9NyetN+0 KTcwEtLEpyra5seMA64ZDCyTMjRimFuiRXEdQIAJef7fRgeTRgIimDrVs 2RBCPen2I3J1aT2RD0a1nXwUY9XpqKnIYb1YuZ6ovG1E7JgKbwphayPJ7 AJe//r4sVOPbtSPzpZgZyZx3h2mfjSXjzj2loGtKunc17AYNO7nPd2DHQ b3Nsnyic8c51kIzrjfvqLZ1dnhygciq6ZxzvDFiKKMy9fCLw3DTHyA4h1 4eMyOxF01SKLYNRiGwi7pVZyxSD7ET/isQbE8TEmrtiEHAqvDF7zq1wIg w==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="341883873" X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="341883873" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:47 -0800 X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="538750565" Received: from gdavids1-mobl.amr.corp.intel.com (HELO localhost) ([10.212.65.108]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:47 -0800 From: ira.weiny@intel.com To: Dave Hansen , "Aneesh Kumar K.V" Subject: [PATCH 3/5] powerpc/pkeys: Properly type pkey in init_{i}amr() Date: Thu, 10 Mar 2022 16:57:40 -0800 Message-Id: <20220311005742.1060992-4-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311005742.1060992-1-ira.weiny@intel.com> References: <20220311005742.1060992-1-ira.weiny@intel.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, "Edgecombe, Rick P" , Ira Weiny , linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Ira Weiny Negative values passed to pkeyshift() will cause an overflow of the amr and imar values. Pkey should not be negative in this call path and u8 is large enough for the 32 pkeys available on powerpc. Change pkey to u8 in init_amr() and init_iamr(). To: Michael Ellerman Cc: Aneesh Kumar K.V Cc: Dave Hansen Signed-off-by: Ira Weiny --- arch/powerpc/mm/book3s64/pkeys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index 753e62ba67af..d6456f8846de 100644 --- a/arch/powerpc/mm/book3s64/pkeys.c +++ b/arch/powerpc/mm/book3s64/pkeys.c @@ -310,7 +310,7 @@ void pkey_mm_init(struct mm_struct *mm) mm->context.execute_only_pkey = execute_only_key; } -static inline void init_amr(int pkey, u8 init_bits) +static inline void init_amr(u8 pkey, u8 init_bits) { u64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey)); u64 old_amr = current_thread_amr() & ~((u64)(0x3ul) << pkeyshift(pkey)); @@ -318,7 +318,7 @@ static inline void init_amr(int pkey, u8 init_bits) current->thread.regs->amr = old_amr | new_amr_bits; } -static inline void init_iamr(int pkey, u8 init_bits) +static inline void init_iamr(u8 pkey, u8 init_bits) { u64 new_iamr_bits = (((u64)init_bits & 0x1UL) << pkeyshift(pkey)); u64 old_iamr = current_thread_iamr() & ~((u64)(0x1ul) << pkeyshift(pkey)); From patchwork Fri Mar 11 00:57:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1604214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=gl8XLlPK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KF71m4kp7z9sGG for ; Fri, 11 Mar 2022 12:02:04 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KF71m3vs8z3c6B for ; Fri, 11 Mar 2022 12:02:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=gl8XLlPK; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=ira.weiny@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=gl8XLlPK; dkim-atps=neutral Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KF6yz6qpCz3bNr for ; Fri, 11 Mar 2022 11:59:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646960380; x=1678496380; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vM08ag580GDO+fflJK8POCmsH9pEVzp+hsefHBAzboI=; b=gl8XLlPK+db7m59pytVITC0y17jWCBbhe97D1rabElQVO4dv7QqLw8qc MNk4S3U+c/IjlY6lcn8pGdlFO3+OgoI8rLyJUVXqAGFQ8ZLsDs6/R2e3u /d3kuytqg0152MhcFP1mWncLW+dfKOkyW+8mk4TLkkB80A8co5Sr1fFtW q5RVP9K5koUKxFo6geDVIE4ekh9LqTCpbW692CVgPMsuo8dJ0j32pLyqX bi0aF13h2VBeS75qg6d2umnsdZ9MiNB1KgKdFeyL8LYg3kKeDMdoaB3N8 ebhCL+7A4+zYg3X+KuWd0Zwl/GpbyVMdWInkbVoJ608Bjd4rb36DCyjAj A==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="242904720" X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="242904720" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:49 -0800 X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="511163178" Received: from gdavids1-mobl.amr.corp.intel.com (HELO localhost) ([10.212.65.108]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:48 -0800 From: ira.weiny@intel.com To: Dave Hansen , "Aneesh Kumar K.V" Subject: [PATCH 4/5] mm/pkeys: Make pkey unsigned in arch_set_user_pkey_access() Date: Thu, 10 Mar 2022 16:57:41 -0800 Message-Id: <20220311005742.1060992-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311005742.1060992-1-ira.weiny@intel.com> References: <20220311005742.1060992-1-ira.weiny@intel.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, "Edgecombe, Rick P" , Ira Weiny , linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Ira Weiny The WARN_ON check in arch_set_user_pkey_access() in the x86 architecture fails to check for an invalid negative value. A simple check for less than 0 would fix this issue however, in the call stack below arch_set_user_pkey_access() the pkey should never be negative on any architecture. x86 only supports 16 keys while ppc supports 32, u8 is therefore large enough for all current architectures and likely those in the future. Change the type of the pkey passed to arch_set_user_pkey_access() to u8. To: Dave Hansen To: Michael Ellerman Cc: Aneesh Kumar K.V Signed-off-by: Ira Weiny --- Changes from V1: Make this part of a generic pkey clean up series. --- arch/powerpc/include/asm/pkeys.h | 4 ++-- arch/powerpc/mm/book3s64/pkeys.c | 2 +- arch/x86/include/asm/pkeys.h | 4 ++-- arch/x86/kernel/fpu/xstate.c | 2 +- include/linux/pkeys.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h index 59a2c7dbc78f..e70615a1da9b 100644 --- a/arch/powerpc/include/asm/pkeys.h +++ b/arch/powerpc/include/asm/pkeys.h @@ -143,9 +143,9 @@ static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma, return __arch_override_mprotect_pkey(vma, prot, pkey); } -extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, +extern int __arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey, unsigned long init_val); -static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, +static inline int arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey, unsigned long init_val) { if (!mmu_has_feature(MMU_FTR_PKEY)) diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index d6456f8846de..310feb9efd57 100644 --- a/arch/powerpc/mm/book3s64/pkeys.c +++ b/arch/powerpc/mm/book3s64/pkeys.c @@ -333,7 +333,7 @@ static inline void init_iamr(u8 pkey, u8 init_bits) * Set the access rights in AMR IAMR and UAMOR registers for @pkey to that * specified in @init_val. */ -int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, +int __arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey, unsigned long init_val) { u64 new_amr_bits = 0x0ul; diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h index 2e6c04d8a45b..3f5c236e34cd 100644 --- a/arch/x86/include/asm/pkeys.h +++ b/arch/x86/include/asm/pkeys.h @@ -9,8 +9,8 @@ */ #define arch_max_pkey() (cpu_feature_enabled(X86_FEATURE_OSPKE) ? 16 : 1) -extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, - unsigned long init_val); +extern int arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey, + unsigned long init_val); static inline bool arch_pkeys_enabled(void) { diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 7c7824ae7862..db511bec57e5 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -1068,7 +1068,7 @@ void *get_xsave_addr(struct xregs_state *xsave, int xfeature_nr) * This will go out and modify PKRU register to set the access * rights for @pkey to @init_val. */ -int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, +int arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey, unsigned long init_val) { u32 old_pkru, new_pkru_bits = 0; diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h index 86be8bf27b41..aa40ed2fb0fc 100644 --- a/include/linux/pkeys.h +++ b/include/linux/pkeys.h @@ -35,7 +35,7 @@ static inline int mm_pkey_free(struct mm_struct *mm, int pkey) return -EINVAL; } -static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, +static inline int arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey, unsigned long init_val) { return 0; From patchwork Fri Mar 11 00:57:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1604213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ow6x3pIX; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KF71663zsz9s09 for ; Fri, 11 Mar 2022 12:01:30 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KF7163JpFz3bj1 for ; Fri, 11 Mar 2022 12:01:30 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ow6x3pIX; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=ira.weiny@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Ow6x3pIX; dkim-atps=neutral Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KF6yG6dFcz30Fw for ; Fri, 11 Mar 2022 11:59:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646960343; x=1678496343; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9ygcwAbQ0NfIqlDdywkiojUz0KGKAHWj5E1qd9qQFb4=; b=Ow6x3pIXJXr796tQYRo71+XtTMbm9/orDCmyo/7an5pCRCMb6+U2Oue3 zf1sJaBjl/1hBtKH1a2e/md1q2eOzZQkxu5ZPjjOfzt45jkZmzwrRd+8P Q506srCVsqSzZfYCLWZJcKpPoVQmuurXN4/ZJPDi1VVKOWtgRwtgYcz+J zY5UvgyAchOoHswAXSWHfXTkCei93Mol6nJDCXZ4mWykZkQrIsr6pKyU0 Y9sEFGRcVnPrdQrR+Smj00LdRcAmeQ4zMC6KICm8JBCVoun79ohC8VIXX Llsbvy9W9KNkpFJw5uDD4xvP5hVfUH5HFw7YScVqJB0RpT2TLVVsCOfPX Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="316177690" X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="316177690" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:59 -0800 X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="554989246" Received: from gdavids1-mobl.amr.corp.intel.com (HELO localhost) ([10.212.65.108]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 16:57:49 -0800 From: ira.weiny@intel.com To: Dave Hansen , "Aneesh Kumar K.V" Subject: [PATCH 5/5] x86/pkeys: Standardize on u8 for pkey type Date: Thu, 10 Mar 2022 16:57:42 -0800 Message-Id: <20220311005742.1060992-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220311005742.1060992-1-ira.weiny@intel.com> References: <20220311005742.1060992-1-ira.weiny@intel.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, "Edgecombe, Rick P" , Ira Weiny , linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Ira Weiny The number of pkeys supported on x86 and powerpc are much smaller than a u16 value can hold. It is desirable to standardize on the type for pkeys. powerpc currently supports the most pkeys at 32. u8 is plenty large for that. Standardize on the pkey types by changing u16 to u8. To: Dave Hansen Cc: Aneesh Kumar K.V Signed-off-by: Ira Weiny --- arch/x86/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pkru.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 8a9432fb3802..cb89f1224d8a 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1357,7 +1357,7 @@ static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd) } #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_WP */ -static inline u16 pte_flags_pkey(unsigned long pte_flags) +static inline u8 pte_flags_pkey(unsigned long pte_flags) { #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS /* ifdef to avoid doing 59-bit shift on 32-bit values */ @@ -1367,7 +1367,7 @@ static inline u16 pte_flags_pkey(unsigned long pte_flags) #endif } -static inline bool __pkru_allows_pkey(u16 pkey, bool write) +static inline bool __pkru_allows_pkey(u8 pkey, bool write) { u32 pkru = read_pkru(); diff --git a/arch/x86/include/asm/pkru.h b/arch/x86/include/asm/pkru.h index 74f0a2d34ffd..06d088f06229 100644 --- a/arch/x86/include/asm/pkru.h +++ b/arch/x86/include/asm/pkru.h @@ -16,13 +16,13 @@ extern u32 init_pkru_value; #define pkru_get_init_value() 0 #endif -static inline bool __pkru_allows_read(u32 pkru, u16 pkey) +static inline bool __pkru_allows_read(u32 pkru, u8 pkey) { int pkru_pkey_bits = pkey * PKRU_BITS_PER_PKEY; return !(pkru & (PKRU_AD_BIT << pkru_pkey_bits)); } -static inline bool __pkru_allows_write(u32 pkru, u16 pkey) +static inline bool __pkru_allows_write(u32 pkru, u8 pkey) { int pkru_pkey_bits = pkey * PKRU_BITS_PER_PKEY; /*