From nobody Fri Aug 28 00:13:43 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1779486675; cv=none; d=zohomail.com; s=zohoarc; b=OIBnBJ81SVOfNi7xUAFsq28TDsMToPfLwtvNfO9VoFbVEOhodFbPfg01IvRq0NFRRclaUWzG4JkX42JDxdkpu1K9JOc7pqAqojPvF6HgLZLk4DHcG0hMvC1MTjyX8+byEf6g7s8HzhQWiXa0ZV6dKS87+NhDIOi/EgALZVpMmU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779486675; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mqcF6NEzXBCLIyliAT4L8cKRuAhuJjFus3rhVTtv5T4=; b=lV0I8cB501QoxLR/8VqfDcki+HsOp6A3+15YIZPsXGUgp67s4rpV0tjJsn3UyWvhM1Qv8Za4+3v2eRltcCJ4e6oOkHX+2ZWJR9o0lccMZKIIrr+4dlSd6yeFmIGpD6o3wDJpoD2WiG6FuRKyLFWkPjrILGjEGNApSqRfAXVU/GU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779486675093709.4104731407236; Fri, 22 May 2026 14:51:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQXlk-0001FX-W4; Fri, 22 May 2026 17:51:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQXlU-0008Rm-QI; Fri, 22 May 2026 17:50:45 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQXlS-0003Vl-LO; Fri, 22 May 2026 17:50:44 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 4F5871AFB6C; Sat, 23 May 2026 00:49:20 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 762393B71BB; Sat, 23 May 2026 00:49:24 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1779486560; bh=UhI+KDjAYlhcfCiXgj3KBHxzGA1hM+W7e3Oe7frWppQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f9OPfOvnoA+u62/6PyOHpmqrDV80vyeQH253e8hd+l/DgwQfP2IX+sqENxWCkTdBD AhJ36ZMhkdpFuXu1nA79X7VMYqFDHKoMcXYi5nwLxt6YVtqpa0x+fxWzn55EksU2w8 Hhnic9vzkT+ZQdKBJlXCNxhkQfmv90LLXpulYT9sHD6PoNGduEVErKYJb9Rvgzi92l olo/EAsVwbpZhNJYhzP1zUHtT0u1IKgEJyKC10/p8JDhshwlC8KHYEJlvzTdkmAi0k UZai5JrZilKMoIks0KVqIxlSpLZjXMMqLMz9ZBPotcuZy4eQhrMexniIYgbjtXiKgs 07zjPERoeMtBA== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Gerd Hoffmann , Feifan Qian , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Michael Tokarev Subject: [Stable-10.2.3 118/149] hw/uefi: check auth.hdr_length minimum size Date: Sat, 23 May 2026 00:48:50 +0300 Message-ID: <20260522214923.807017-19-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @tls.msk.ru) X-ZM-MESSAGEID: 1779486675434158500 From: Gerd Hoffmann auth.hdr_length maximum is already checked (against buffer size). The header has some fixed fields which are included in the header length, so there also is a minimum size which must be verified. Add a check for that. Fixes possible integer underflow. While being at it replace the magic number '24' with sizeof calculations for better code documentation. Fixes: CVE-2026-8341 Fixes: f1488fac0584 ("hw/uefi: add var-service-auth.c") Reported-by: Feifan Qian Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Gerd Hoffmann Message-ID: <20260512060523.17493-1-kraxel@redhat.com> (cherry picked from commit b33fd8ab1caa07aeb290ef5dac44a4e7fd4be02b) Signed-off-by: Michael Tokarev diff --git a/hw/uefi/var-service-auth.c b/hw/uefi/var-service-auth.c index 795f2f54e4..f3dc9c6ca6 100644 --- a/hw/uefi/var-service-auth.c +++ b/hw/uefi/var-service-auth.c @@ -194,7 +194,7 @@ static efi_status uefi_vars_check_auth_2_sb(uefi_vars_s= tate *uv, return EFI_SUCCESS; } =20 - if (auth.hdr_length =3D=3D 24) { + if (auth.hdr_length =3D=3D (sizeof(auth) - sizeof(auth.timestamp))) { /* no signature (auth->cert_data is empty) */ return EFI_SECURITY_VIOLATION; } @@ -228,6 +228,9 @@ efi_status uefi_vars_check_auth_2(uefi_vars_state *uv, = uefi_variable *var, } memcpy(&auth, data, sizeof(auth)); =20 + if (auth.hdr_length < (sizeof(auth) - sizeof(auth.timestamp))) { + return EFI_SECURITY_VIOLATION; + } if (uadd64_overflow(sizeof(efi_time), auth.hdr_length, &data_offset)) { return EFI_SECURITY_VIOLATION; } diff --git a/hw/uefi/var-service-pkcs7.c b/hw/uefi/var-service-pkcs7.c index c859743e86..8a1f1395a2 100644 --- a/hw/uefi/var-service-pkcs7.c +++ b/hw/uefi/var-service-pkcs7.c @@ -113,9 +113,9 @@ static gnutls_datum_t *build_pkcs7(void *data) =20 memcpy(&auth, data, sizeof(auth)); pkcs7 =3D g_new(gnutls_datum_t, 1); - pkcs7->size =3D auth.hdr_length - 24; + pkcs7->size =3D auth.hdr_length - (sizeof(auth) - sizeof(auth.timestam= p)); pkcs7->data =3D g_malloc(pkcs7->size); - memcpy(pkcs7->data, data + 16 + 24, pkcs7->size); + memcpy(pkcs7->data, data + sizeof(auth), pkcs7->size); =20 wrap_pkcs7(pkcs7); =20 --=20 2.47.3