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 E312544AB7B; Tue, 21 Jul 2026 22:03:12 +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=1784671394; cv=none; b=kWdvlpfYRM0PEXtTDLy4+1JU8yfU4H8OZFcyeyHt71/8fjcp3WrK9wmUZNH344As3Z0Oe8u6rw+8DUNZyrVB280mc44TzOcGA8TamWZf9OTLTT6fXrXkdj7olCbYrjSYh6gdOJK13E99Uxw0HafNeKEAhorPK6eDlxvBrvrWbBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671394; c=relaxed/simple; bh=zFPquqL9gql7pvOstPRcphMQBx/g9GcCdwjwAcxZZVc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XrFolFEQEQmXLFLX2ukUYwBwVSWa4ZOpaAKYomF9lw+QcW4nai7qV66SRsQnvFvMq0D7ptcHV3j2nSjpQWDL9fkLvfz6WVXAOtAHqrfhL3+XWLy2QwuPxP8EERqpW/Cwo/LCfMdnZuLSshIXMMG+FsGwjMmWrlQVzlkJ9W7YvBQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GcEt2GfU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GcEt2GfU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54DBC1F000E9; Tue, 21 Jul 2026 22:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671392; bh=vmg4Af10955rOZ4VvCvw7ThRzqou5uZSriyFPPG4YIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GcEt2GfUnN5Yfdx2+fggjh7rtaJqOKPI05r0aylxJngHap5X7M3oMM353tE6YHK96 K0SFjy0Cf18AiS+obiAVkJPzMVQn9WcBOedNTCrD/Tx3cWh3u+iMmavwEooJ75Z7EN /RkfFSU2bjd3M4sDaT35D9BSoJ7bghPzirb71MTU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiang Mei , Weiming Shi , Herbert Xu , Sasha Levin Subject: [PATCH 5.15 230/843] crypto: asymmetric_keys - fix OOB read in pefile_digest_pe_contents Date: Tue, 21 Jul 2026 17:17:45 +0200 Message-ID: <20260721152411.192123320@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi [ Upstream commit f7dd32c5179d7755de18e21d5674b08f9e5cb180 ] pefile_digest_pe_contents() computes the trailing-data hash length as pelen - (hashed_bytes + certs_size). A crafted PE can make the addition exceed pelen, causing the unsigned subtraction to underflow to ~4 GiB. This is passed to crypto_shash_update() which reads out of bounds and panics on unmapped vmalloc guard pages. BUG: unable to handle page fault for address: ffffc900038d8000 Oops: Oops: 0000 [#1] SMP KASAN NOPTI RIP: 0010:sha256_blocks_generic (lib/crypto/sha256.c:152) Call Trace: __sha256_update (lib/crypto/sha256.c:208) crypto_sha256_update (crypto/sha256.c:142) verify_pefile_signature (crypto/asymmetric_keys/verify_pefile.c:436) kexec_kernel_verify_pe_sig (kernel/kexec_file.c:151) __do_sys_kexec_file_load (kernel/kexec_file.c:406) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception Validate that the addition does not overflow and the result does not exceed pelen before the subtraction. Return -ELIBBAD on failure. Fixes: af316fc442ef ("pefile: Digest the PE binary and compare to the PKCS#7 data") Reported-by: Xiang Mei Signed-off-by: Weiming Shi Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- crypto/asymmetric_keys/verify_pefile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto/asymmetric_keys/verify_pefile.c b/crypto/asymmetric_keys/verify_pefile.c index 22beaf2213a224..7e5b392dcac79a 100644 --- a/crypto/asymmetric_keys/verify_pefile.c +++ b/crypto/asymmetric_keys/verify_pefile.c @@ -305,6 +305,8 @@ static int pefile_digest_pe_contents(const void *pebuf, unsigned int pelen, if (pelen > hashed_bytes) { tmp = hashed_bytes + ctx->certs_size; + if (tmp <= hashed_bytes || pelen < tmp) + return -ELIBBAD; ret = crypto_shash_update(desc, pebuf + hashed_bytes, pelen - tmp); -- 2.53.0