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 17735231829; Tue, 21 Jul 2026 22:40:04 +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=1784673605; cv=none; b=YgBGldsVfcQgJiDSwkPpfM0yXbBtBxlwRWXDMd9IcTbR5og3M219XqdKeKYkdp9GKaM60wfaxAnufYdWkzH42B13I2q+uxuRy5AyVZNof815YVg2S08wTs/oTk1Zcu48gGiN/ksmopl+TH0OCE8XxzED6JziBaMHP0uM2Z+4xvE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784673605; c=relaxed/simple; bh=kq66z4eEFDifXmeJHYE9rfHh/NHbSTUDJ6b132LQQcg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RehN5AzTworxNcnwuD3uy2Ns3P0rzuKz3U/e4bcSzGYlXYMuxf07tm9aFI0+t9gluVDZd7/rdKIkpHUda2/OXNuUT6DqOstKCRKjm4N/RcVi5NQ19imzOYciQzOLSw7gCTr7F1Vqoorg4CqnBfKtJIMdfs/JPW+W4uVkQP5UcLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ve5xNkgW; 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="ve5xNkgW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 785A51F000E9; Tue, 21 Jul 2026 22:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784673604; bh=hnDWGme9JrNO1+AEIr4iz5LkB6qvfgfAhAH+2CxtKRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ve5xNkgW9PR/T8IP9Rcsf+1iYJoeu1ce6vdNUj1BzswzMAO6adPnNXKjz20GWzEnj pqHYOm2d7R2Nv+W1vZDKoAaCM/8A5CewJWZkfQJH8PzqFu6g2C2RWtKGW7wU10eSXe YnrsK530SEgIt1d/0Oud9dv2uL6JctcRMbRPAhvI= 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.10 181/699] crypto: asymmetric_keys - fix OOB read in pefile_digest_pe_contents Date: Tue, 21 Jul 2026 17:19:00 +0200 Message-ID: <20260721152359.781244253@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@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.10-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