From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9FEFC35962; Fri, 3 Oct 2025 16:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759507729; cv=none; b=dTaUbkYwyIZT4Nssmetm0RQKb6JAmnZD4uYkIucEkxG5uZVqRsyT5c4cVOwMZZEfTKQQh7/36zb2h+xHOFgsAWZ0b3OX9Hm13NmdPUIO8gLtl5E1mJr+UV7edPBPIK44sHhYlZ+KHq5JCwDBWzR1Tlzl6buNfNhJPTfYSNVK+co= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759507729; c=relaxed/simple; bh=/CqUqbS7XWVd0eZB+R1ast799af3Z8u8QVYs6Q0qHuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KQQNrYcl0JPLzypm4ZHSV74Qa6rICy5LKQKuBarU0kx5gtc8TLsyA25Y5QJLLKQiyMEsNboc0aktiB1rN5g2dWiZYrDackPVDKw5D6VyiNbFORxePqbFYVNY5AJ6OpY5g4kcPNhw/v3qF4D7A6Yzjc0js6rnPMoT+1//6nW+SJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MJUuojee; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MJUuojee" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8D7FC4CEF7; Fri, 3 Oct 2025 16:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759507729; bh=/CqUqbS7XWVd0eZB+R1ast799af3Z8u8QVYs6Q0qHuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJUuojee3JDrkxr4mVzTXxNsxeGc/V617/nZhNHesNpS3ief0hvzpBd414nAHNv1w uLTvf3vIqiSk74+dhZi3uVUfNCaP/jGjRuQ4aLnJMTt4pCrEpSqIOVnn4XggRXBCH2 4Dr/X//0n2AYJQQbrG9otLo1ioISbn7spnWROryI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Breno Leitao , Michael van der Westhuizen , Tobias Fleig , Eric Biggers Subject: [PATCH 6.6 1/7] crypto: sha256 - fix crash at kexec Date: Fri, 3 Oct 2025 18:06:09 +0200 Message-ID: <20251003160331.533677677@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251003160331.487313415@linuxfoundation.org> References: <20251003160331.487313415@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Breno Leitao Loading a large (~2.1G) files with kexec crashes the host with when running: # kexec --load kernel --initrd initrd_with_2G_or_more UBSAN: signed-integer-overflow in ./include/crypto/sha256_base.h:64:19 34152083 * 64 cannot be represented in type 'int' ... BUG: unable to handle page fault for address: ff9fffff83b624c0 sha256_update (lib/crypto/sha256.c:137) crypto_sha256_update (crypto/sha256_generic.c:40) kexec_calculate_store_digests (kernel/kexec_file.c:769) __se_sys_kexec_file_load (kernel/kexec_file.c:397 kernel/kexec_file.c:332) ... (Line numbers based on commit da274362a7bd9 ("Linux 6.12.49") This started happening after commit f4da7afe07523f ("kexec_file: increase maximum file size to 4G") that landed in v6.0, which increased the file size for kexec. This is not happening upstream (v6.16+), given that `block` type was upgraded from "int" to "size_t" in commit 74a43a2cf5e8 ("crypto: lib/sha256 - Move partial block handling out") Upgrade the block type similar to the commit above, avoiding hitting the overflow. This patch is only suitable for the stable tree, and before 6.16, which got commit 74a43a2cf5e8 ("crypto: lib/sha256 - Move partial block handling out"). This is not required before f4da7afe07523f ("kexec_file: increase maximum file size to 4G"). In other words, this fix is required between versions v6.0 and v6.16. Signed-off-by: Breno Leitao Fixes: f4da7afe07523f ("kexec_file: increase maximum file size to 4G") # Before v6.16 Reported-by: Michael van der Westhuizen Reported-by: Tobias Fleig Reviewed-by: Eric Biggers Signed-off-by: Greg Kroah-Hartman --- include/crypto/sha256_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/crypto/sha256_base.h +++ b/include/crypto/sha256_base.h @@ -44,7 +44,7 @@ static inline int lib_sha256_base_do_upd sctx->count += len; if (unlikely((partial + len) >= SHA256_BLOCK_SIZE)) { - int blocks; + unsigned int blocks; if (partial) { int p = SHA256_BLOCK_SIZE - partial;