Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp705778pxp; Fri, 11 Mar 2022 12:53:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwood7vYn8dPQbgWJfZLJStQcyzZl6Gqo0/KkLvPb2+3yoaAHhwGUAsmkLi7jcIcZcxXbmg X-Received: by 2002:a17:902:e889:b0:151:a56d:eb8f with SMTP id w9-20020a170902e88900b00151a56deb8fmr11920486plg.142.1647031997172; Fri, 11 Mar 2022 12:53:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647031997; cv=none; d=google.com; s=arc-20160816; b=aOKakRqfHh7q7bSuHc1Sx/pp6Jzj3kfWUBrExySl3lLXWiFrD390eUgNzQR18bc4yQ vNg7FoVsKF39oXe8BwdK1V15CEAFZrpJrLy70IljKAQq155ONXFYCkzhLZc0BG+BtE9w DYy6qeTMCVHWwZ8SRxeMTeJBZMj37rbbwacIx6ThWw6Hrzq7C4Q6swZd5UKvlsFyrcaa 5L+7Okz3BaDw1M/4BLskIwTY4YISM+Dj5H1RwaUWqRbT/CVzDzfbytmfJelGXlFnk4Mc cX/E/HOv8PW/8b079GBogeOO0H6kE3cDGtA7G8M4oP/fJ/oyVEWTDKgSI0jKHINowbmm 9HqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mgnu1UIA/QG/FM2bbTSY3pOZEAyVe+PatnLKWDOnX2U=; b=Y3dujkvEIxpv21f1yl62nlgau0/DkMNtJFbqAl3FVaYEk7kcCePatgBgy+aAMLzZ94 hFXflC5qSjGf6uP0srraoCEpkydMiULLpLuVwT7tk1/WbJPfGjlQkPWCultfWFCn09wj fo6fkBh1V4inOVzGuxRs/BZBoRx3ilPzRmau6C85zOYxItJXRQrZM/zYBanSXd6PUnmF 5cZZ7Z/IEW8q2FJqFrihRoPXo4xbnaWDELIW+U8897Myh0datZoE5Nr7ffnE/HFvrRNj vVHzRcg/YocBN1uIyYs6NKO6NGWT0slO2sC7Q1aDOpHqoK/3FrRvU1kcgVEdZlwkSVec nsbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ebc6/R9J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f1-20020a636a01000000b0037c5bb9e12dsi8623399pgc.170.2022.03.11.12.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 12:53:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ebc6/R9J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 836341DF856; Fri, 11 Mar 2022 12:45:07 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345250AbiCKA7q (ORCPT + 99 others); Thu, 10 Mar 2022 19:59:46 -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 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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