From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 621E439D6D1 for ; Wed, 20 May 2026 09:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779267642; cv=none; b=Iv0HwYoWWkctJ+BlWvUDzekkw4QMLa6JXKoa4RUOfnBgZ6Bj0gDzY1UCSQ2ySK9X8brhLn6EeGe/12nIQC/ufynQlsgDhTusCr6Bi+zRb87kJ7G9VLKBTbKXVMsCJOa7P8atwU6tKvslCYNSqbI36J5XhejVJ2Vtw1N9vGyDJrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779267642; c=relaxed/simple; bh=L0TGqJKxlkbSr9SQf0oWqF8NyosWX+POLs/n0MUb+Qk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=upceTmJloKncINFtOvWg3OM0mBXuHfwHQyIvsY5kW9v9R+ZIddIyzYJulXSiTOs+Uqug+qqTD4xgU2m33Gi7/uPJZrnEbxZE3xAdZ9xHOpM/qOtzbjS8o6TLd/lxJPxWC9bezQ+IiiwqXEt1I42TvxH+Z6uL5KokhvWMlmyimrc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zxvd0ZXX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Zxvd0ZXX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5EA21F000E9; Wed, 20 May 2026 09:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779267639; bh=3r35QlQQ7TVEOX/HVqaknByeqpHK8Sp/8ygLvIHXW40=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=Zxvd0ZXXHWPrUMd5OxQIuQiPjuKEni06e9W8mRbiKmKS+8/nbO8T6FJPgq40Ae+4k z5E197CXleBwiC0hakD0mGymc68UyZDEQ8klbeGEwX+wFVhs969H//t1iSHmlvnMD4 L9y0aR69J4xNbEnULij+cJGsOfCU3bhxoVxmUbJumIO755gpntqCd3m5HadNuV4eF5 hOJ6qZaTQ9NY9ZJuzejnxs5cyMiefQCPLB3KG3GhZAzIQ+EK1iATYuvaWYKnf5T2WN QkdIJ9I8uvV2KCErOXqbU+iMK0EWod2dB7j7glr5+BxmcdFWMVhG+dgbs/7tXH5k/P eUorffZ3mjjxg== Message-ID: Date: Wed, 20 May 2026 11:00:35 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] powerpc/fadump: fix integer overflow in MIN_RMA size check To: Sayali Patil , linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com, Michael Ellerman , Nicholas Piggin Cc: linux-kernel@vger.kernel.org, Ritesh Harjani , Mahesh Salgaonkar , Sourabh Jain References: <00e9b516b13316f7ce81b651957dad0441e56006.1779255851.git.sayalip@linux.ibm.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <00e9b516b13316f7ce81b651957dad0441e56006.1779255851.git.sayalip@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 20/05/2026 à 07:53, Sayali Patil a écrit : > The MIN_RMA size checks in fadump_setup_param_area() use > (MIN_RMA * 1024 * 1024), which is evaluated in int and can > overflow when MIN_RMA is 2048 or larger. This triggers compiler > warnings such as: > > warning: integer overflow in expression of type 'int' > results in '0' [-Woverflow] > > Promote MIN_RMA to u64 before the multiplication so the expression > is evaluated in 64-bit and matches the surrounding physical address > and memory size calculations. > > This fixes both the comparison against ppc64_rma_size and the > assignment to range_start. How do you create that problem ? MIN_RMA has a fixed value of 768 which is defined in asm/prom.h > > Fixes: b7bb46062457 ("powerpc/fadump: fix additional param memory reservation for HASH MMU") > Signed-off-by: Sayali Patil > --- > arch/powerpc/kernel/fadump.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c > index 501d43bf18f3..dea7f7105e42 100644 > --- a/arch/powerpc/kernel/fadump.c > +++ b/arch/powerpc/kernel/fadump.c > @@ -1759,10 +1759,10 @@ void __init fadump_setup_param_area(void) > * 2. The range should be between MIN_RMA and RMA size (ppc64_rma_size) > * 3. It must not overlap with the fadump reserved area. > */ > - if (ppc64_rma_size < MIN_RMA*1024*1024) > + if (ppc64_rma_size < (u64)MIN_RMA * 1024 * 1024) As you are modifying that line, please use SZ_1M instead of keeping opencoded 1024 * 1024. > return; > > - range_start = MIN_RMA * 1024 * 1024; > + range_start = (u64)MIN_RMA * 1024 * 1024; Same. > range_end = min(ppc64_rma_size, fw_dump.boot_mem_top); > } > Maybe the best would be to define MIN_RMA as a bytes value in asm/prom.h and to divide the value by SZ_1M in kernel/prom_init.c when initialising ibm_architecture_vec_template. That way you could just define it as SZ_2G instead of the problematic 2048 you mention.