From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4C22C433EF for ; Fri, 11 Mar 2022 00:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345254AbiCKA7s (ORCPT ); Thu, 10 Mar 2022 19:59:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241066AbiCKA7j (ORCPT ); Thu, 10 Mar 2022 19:59:39 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8F93E98D4 for ; Thu, 10 Mar 2022 16:58:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646960316; x=1678496316; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wzyA39JwdZxDDT/IXqrk8/yZKwNXu3aWKvXpfEakV14=; b=Ebc6/R9JQ6ah3AAIAy5kxC4//PxF+ZzB6ZZUIaRGGRyks/phEP7wXJYX sPJauC6h0bOZjm3+UwjnVKcY5cx/04RNZ+XeoF57QJMBkhgWrgAdTuSV4 BWGofFUMnVT4NiJ7spMw6uaYYGXZSCh35bXL1sDkaAZmE/1qtwbNUxYJG eAYuCA+f5D0DGAUPJJXOkfNojoLILA9FnemT1e4HBelRNI6j9fwLsWX/7 SF7vU+ssBVrKDeOVw6KiWovI/UK9i+spZLdNfqQ2erqtBbOsacD/Z2GnU RpOhCQLJcxV56nhhsi1aPuDHucm+pS6vdemUvYpoqZ4eIQpmhU5w5t+A3 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="255405810" X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="255405810" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.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" Cc: Ira Weiny , "Edgecombe, Rick P" , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)); -- 2.35.1