From nobody Sat Jul 25 08:04:50 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784728723; cv=none; d=zohomail.com; s=zohoarc; b=MUsywuo6tOEj8ytxgNPRPcsl+FKjfd+gA4YPoxpYRr5+7BWnSloi8WdTYQhrQBV6poDXYWTO8DlxJJXLafgnu5HTr7PzLiINqM44VHtZW7BZLJej8/u0oxGPGH/vqtqLO1WpaBnUXtF6AHv80PFSBTkAz3sdJhxTju6BoMs5XNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784728723; h=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=JAcZQvx2oB/ImzZjC3Kl2/zA7HVpTnoUrfWmzP20AbQ=; b=jKEc8AieAJs8egFZ5n/J2hq0nt90bWeoS8d8ZDUhdWHcTcXzvS2gsDhUfpQ2h2wCSvprBDCTiULolUSDVg8nfFTMgC/45LqDEDGlbXl+L/cVEbOURd67zxK+R1tkJV9db08seJLbeEk57+ueAYyk0pMX6VgK2UDOIV/9TIhAf6g= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784728723860795.3967753349464; Wed, 22 Jul 2026 06:58:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmXSc-0007he-LB; Wed, 22 Jul 2026 09:58:10 -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 1wmXSV-0007eq-2P for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmXSR-0006sU-TA for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:02 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660--3MgQTTvOS-iimQY1Ssdxw-1; Wed, 22 Jul 2026 09:57:55 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5CD4318E6A53 for ; Wed, 22 Jul 2026 13:57:54 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.49.247]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ADB633004082; Wed, 22 Jul 2026 13:57:53 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 60384182548A; Wed, 22 Jul 2026 15:57:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784728677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JAcZQvx2oB/ImzZjC3Kl2/zA7HVpTnoUrfWmzP20AbQ=; b=BO8hqC1N3Ksfyr+hHXjasy4kJCu7VxBVXrV6YO+43ArHdqZCQeJxjmqjpryCjJpDyzu2dg 5TQsMFNt7mO9Rpr/NDCiyjI7sGaAoU5spHeg9ioGddUZw7WITYLec91HxxQpA5KEQ/A3qJ 4AGQrsNRTCp6OkhSX/GOhF00ONqENQc= X-MC-Unique: -3MgQTTvOS-iimQY1Ssdxw-1 X-Mimecast-MFC-AGG-ID: -3MgQTTvOS-iimQY1Ssdxw_1784728674 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Luigi Leonardi Subject: [PULL 1/6] hw/uefi: add sanity check Date: Wed, 22 Jul 2026 15:57:45 +0200 Message-ID: <20260722135752.1264244-2-kraxel@redhat.com> In-Reply-To: <20260722135752.1264244-1-kraxel@redhat.com> References: <20260722135752.1264244-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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: permerror client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1784728726186158500 Content-Type: text/plain; charset="utf-8" Verify the passed buffer has the minimal required length before reading the size field + verifying the total length. Fixes: CVE-2026-58581 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3614 Acked-by: Luigi Leonardi Signed-off-by: Gerd Hoffmann Message-ID: <20260720143244.821889-2-kraxel@redhat.com> --- hw/uefi/var-service-policy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/uefi/var-service-policy.c b/hw/uefi/var-service-policy.c index 58da4adbebaf..989bf87ddb86 100644 --- a/hw/uefi/var-service-policy.c +++ b/hw/uefi/var-service-policy.c @@ -276,6 +276,9 @@ static uint32_t uefi_vars_mm_check_policy_register(uefi= _vars_state *uv, uefi_var_policy *pol; uint64_t length; =20 + if (mhdr->length < sizeof(*mchk) + sizeof(*pe)) { + return uefi_vars_mm_policy_error(mhdr, mchk, EFI_BAD_BUFFER_SIZE); + } if (uadd64_overflow(sizeof(*mchk), pe->size, &length)) { return uefi_vars_mm_policy_error(mhdr, mchk, EFI_BAD_BUFFER_SIZE); } --=20 2.55.0 From nobody Sat Jul 25 08:04:50 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784728731; cv=none; d=zohomail.com; s=zohoarc; b=YxLAsQ4Tav4/63eHsXrxgdE2Y/7RozqGWmXtW2rfp8FMeGQw7ZWeNR66HYHOhGfzlb0YbME0FROU8rLQEh1aNrpgEKC/uHu4BU+96L2zc2tR/0MgRslhEHrbKfAZmWL/3bbzdNcwdhXd++ulc79BeKVEOwRavPBicLUfoX3ipQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784728731; 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=EwQFwOW/HIFKnZsk84WExTJ36qy155g9GEgc3zsJ0dw=; b=Q2p5DqF+qqTuWjyrdg5/I+yO15jeJ6Ikau7iBQAAqBhruxtoFzHnS+MKgqmhhGkIjN6ESQ2yjlQFeat56nLQqpnKFURQYOEBpaUJV5kwrxnSAM4VDkLykfbt2s+S3wQ7lL8RZmv2UFbCd5t9SAz7n2O5aaEqjKGJQmq3oTYOe0g= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784728731014897.4736062648356; Wed, 22 Jul 2026 06:58:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmXSX-0007fN-0h; Wed, 22 Jul 2026 09:58:05 -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 1wmXSU-0007eY-EL for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmXSR-0006sg-TA for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:02 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-2P3WtHl_O92jt-jDRAi3nQ-1; Wed, 22 Jul 2026 09:57:56 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9F6C8180074A for ; Wed, 22 Jul 2026 13:57:55 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.49.247]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5CBA730041A0; Wed, 22 Jul 2026 13:57:55 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6FBD9182548B; Wed, 22 Jul 2026 15:57:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784728678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EwQFwOW/HIFKnZsk84WExTJ36qy155g9GEgc3zsJ0dw=; b=eNc+mSLpm+7oz0WeIz7emhxbZK/cLAXBebekzuettHYhyIAMBUEQqq5pWx8TanZNIGNwxF LceAascxPS+DfLSUvFv+TMyMrpX4lsSzHZKGd5nSTovI0rF00oZOAMrrx14rENwzSs84hF gbCuOlrMYCx3Jhm2DGeDh6sVzGlhePM= X-MC-Unique: 2P3WtHl_O92jt-jDRAi3nQ-1 X-Mimecast-MFC-AGG-ID: 2P3WtHl_O92jt-jDRAi3nQ_1784728675 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Luigi Leonardi Subject: [PULL 2/6] hw/uefi: remove debug function Date: Wed, 22 Jul 2026 15:57:46 +0200 Message-ID: <20260722135752.1264244-3-kraxel@redhat.com> In-Reply-To: <20260722135752.1264244-1-kraxel@redhat.com> References: <20260722135752.1264244-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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: permerror client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 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 @redhat.com) X-ZM-MESSAGEID: 1784728733688158500 This was never meant to be present in production builds. It's a code path not hit on a normal boot (OVMF wouldn't try variable updates which are not allowed), so this went unnoticed. Remove the function. If needed for debugging the git log is your friend. Fixes: CVE-2026-58582 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3615 Acked-by: Luigi Leonardi Signed-off-by: Gerd Hoffmann Message-ID: <20260720143244.821889-3-kraxel@redhat.com> --- hw/uefi/var-service-policy.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/hw/uefi/var-service-policy.c b/hw/uefi/var-service-policy.c index 989bf87ddb86..0880bfe074a6 100644 --- a/hw/uefi/var-service-policy.c +++ b/hw/uefi/var-service-policy.c @@ -37,37 +37,6 @@ const VMStateDescription vmstate_uefi_var_policy =3D { }, }; =20 -static void print_policy_entry(variable_policy_entry *pe) -{ - uint16_t *name =3D (void *)pe + pe->offset_to_name; - - fprintf(stderr, "%s:\n", __func__); - - fprintf(stderr, " name =C2=B4"); - while (*name) { - fprintf(stderr, "%c", *name); - name++; - } - fprintf(stderr, "', version=3D%d.%d, size=3D%d\n", - pe->version >> 16, pe->version & 0xffff, pe->size); - - if (pe->min_size) { - fprintf(stderr, " size min=3D%d\n", pe->min_size); - } - if (pe->max_size !=3D UINT32_MAX) { - fprintf(stderr, " size max=3D%u\n", pe->max_size); - } - if (pe->attributes_must_have) { - fprintf(stderr, " attr must=3D0x%x\n", pe->attributes_must_have= ); - } - if (pe->attributes_cant_have) { - fprintf(stderr, " attr cant=3D0x%x\n", pe->attributes_cant_have= ); - } - if (pe->lock_policy_type) { - fprintf(stderr, " lock policy type %d\n", pe->lock_policy_type); - } -} - static gboolean wildcard_str_equal(uefi_var_policy *pol, uefi_variable *var) { @@ -173,7 +142,6 @@ efi_status uefi_vars_policy_check(uefi_vars_state *uv, pe =3D pol->entry; =20 uefi_trace_variable(__func__, var->guid, var->name, var->name_size); - print_policy_entry(pe); =20 if ((var->attributes & pe->attributes_must_have) !=3D pe->attributes_m= ust_have) { trace_uefi_vars_policy_deny("must-have-attr"); --=20 2.55.0 From nobody Sat Jul 25 08:04:50 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784728736; cv=none; d=zohomail.com; s=zohoarc; b=gUGZo8NoLjfecUGy2gkIRpgroJCMEdMVuKTx0vdDoH1BSG7ni624QpF5K57OL/V+6abAg2SEcjpjdBRVzdtbKzercBCaLneF/iyr/LTbvcgN7HtlMmJbU3Im2KyHG/gf8CseL7RCYVPod4g0Mm8DyKVyM/BG3V3MlPC3G3TWbsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784728736; h=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=ekYIJUwt8k4X/L/ol1xvW5YgXjJdeKPU66+gEoHwRYI=; b=V6MKz9z5jTmGU0r+BaGDQuaWwCTplyy5bRdVuUCsNVbEeu/vf9vUnQVe2V/QdiWO9y2M+qlIqZbSH6oRhAsssBf8yUeA6CSgBXvE2y/68ctTf/MMHeKrM2cKfVgyClH7m+vcSDJcO6cl3sZXkyzyYgbRZHVzEc/nALpq8DG5fQU= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784728736480454.241963829425; Wed, 22 Jul 2026 06:58:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmXSY-0007fg-8j; Wed, 22 Jul 2026 09:58:06 -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 1wmXSU-0007eX-CG for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmXSR-0006sv-Tv for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:01 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-RQHwQSMIPJCD8iaBxfxchA-1; Wed, 22 Jul 2026 09:57:57 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 451A7195FDCA for ; Wed, 22 Jul 2026 13:57:56 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.49.247]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A691180056E; Wed, 22 Jul 2026 13:57:55 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8593F1826B11; Wed, 22 Jul 2026 15:57:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784728678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ekYIJUwt8k4X/L/ol1xvW5YgXjJdeKPU66+gEoHwRYI=; b=hOmEuna+UkkJM/9bOlM127kfKdLziHOepw7Y1ROoonxv5BNvHTDebJFjleOZAEDbCZduCs WJirRumqnfa/YhFpeN5Qvy6C0PHBPR07AyIIPMbdO5DFqkslFRJv183yFbndw9KEmNx+6A JPr3b9o22pECz3VKM54o3XQ9HKNn1tE= X-MC-Unique: RQHwQSMIPJCD8iaBxfxchA-1 X-Mimecast-MFC-AGG-ID: RQHwQSMIPJCD8iaBxfxchA_1784728676 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Luigi Leonardi Subject: [PULL 3/6] hw/uefi: check lower limit for signature list size Date: Wed, 22 Jul 2026 15:57:47 +0200 Message-ID: <20260722135752.1264244-4-kraxel@redhat.com> In-Reply-To: <20260722135752.1264244-1-kraxel@redhat.com> References: <20260722135752.1264244-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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: permerror client-ip=170.10.129.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1784728737703158500 Content-Type: text/plain; charset="utf-8" Specifically disallow zero which can lead to an endless loop. Fixes: CVE-2026-61406 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3899 Acked-by: Luigi Leonardi Signed-off-by: Gerd Hoffmann Message-ID: <20260720143244.821889-4-kraxel@redhat.com> --- hw/uefi/var-service-siglist.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/uefi/var-service-siglist.c b/hw/uefi/var-service-siglist.c index 8948f1b78471..9e03a4dc0c28 100644 --- a/hw/uefi/var-service-siglist.c +++ b/hw/uefi/var-service-siglist.c @@ -94,6 +94,9 @@ void uefi_vars_siglist_parse(uefi_vars_siglist *siglist, break; } efilist =3D data; + if (efilist->siglist_size < sizeof(*efilist)) { + break; + } if (size < efilist->siglist_size) { break; } --=20 2.55.0 From nobody Sat Jul 25 08:04:50 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784728742; cv=none; d=zohomail.com; s=zohoarc; b=N1vTo+W6ng2kK8OHfT6tDCHMtTpEa7Zrb/16ucITJ5n1+/W5532GUuMOGLa4VMA3GKCuo1PblvtcFiXpx59PyTIzMJXHfblYSX1DXRho0jdLgfMWUAKzPMVp20YtWRJZwLCxV2ctfFLXHsHXQRMC5nwP7mHvNNJ43/hSqJkQZcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784728742; h=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=GjAKuZGD/e3TUI8K9fZukuAlvtrrLMVlz77kvZ/XcBE=; b=bTu/hUkGVHRtd7ktR/ECUKFlxwcMPMEMmpsIe6bh64DC8iMSsnSaAYUpa8dxAeZp1q2tq9QSLg/gJNGXVQppSpv75fWi1b3BzJFFj8WFoGVFx8ktIWr2CJlXOAo5AbPjbXj96p/oEtAfinsGaeL1eCY6dlY09VjoDTzjVWyqr8E= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784728741990816.7161153324973; Wed, 22 Jul 2026 06:59:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmXSZ-0007gG-1y; Wed, 22 Jul 2026 09:58:07 -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 1wmXSV-0007f0-L8 for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmXSU-0006t6-4X for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:03 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-66-eAfiO2UcN5Sj6ebwlcc3AQ-1; Wed, 22 Jul 2026 09:57:57 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 84E4A1954111 for ; Wed, 22 Jul 2026 13:57:56 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.49.247]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 417983004082; Wed, 22 Jul 2026 13:57:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9A2071826B12; Wed, 22 Jul 2026 15:57:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784728681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GjAKuZGD/e3TUI8K9fZukuAlvtrrLMVlz77kvZ/XcBE=; b=GPl1opKXd1LHSLTIvk8pamOcCvdFdDJDGkrBTRLt3ui+uyIk6mlMd/sDGmxEe0LvDhyQ6k UMmng7GPxdArEjpRvZeCFs5eQo2Q01PHdLJ5fzX2BuQIgqieDnFMXG8dFXHaUeqhZ7fzKS 4PRAYYNd8ntRlnBoiZ3KEAamoQcFpeI= X-MC-Unique: eAfiO2UcN5Sj6ebwlcc3AQ-1 X-Mimecast-MFC-AGG-ID: eAfiO2UcN5Sj6ebwlcc3AQ_1784728676 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Luigi Leonardi Subject: [PULL 4/6] hw/uefi: account variable policy entries against storage size Date: Wed, 22 Jul 2026 15:57:48 +0200 Message-ID: <20260722135752.1264244-5-kraxel@redhat.com> In-Reply-To: <20260722135752.1264244-1-kraxel@redhat.com> References: <20260722135752.1264244-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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: permerror client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1784728743727158500 Content-Type: text/plain; charset="utf-8" uefi-vars already tracks (and limits) the memory footprint of UEFI variables. Do that for variable policies too. Fixes: CVE-2026-61405 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3890 Acked-by: Luigi Leonardi Signed-off-by: Gerd Hoffmann Message-ID: <20260720143244.821889-5-kraxel@redhat.com> --- hw/uefi/var-service-policy.c | 5 +++++ hw/uefi/var-service-vars.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/hw/uefi/var-service-policy.c b/hw/uefi/var-service-policy.c index 0880bfe074a6..46c4ff2dacae 100644 --- a/hw/uefi/var-service-policy.c +++ b/hw/uefi/var-service-policy.c @@ -283,7 +283,12 @@ static uint32_t uefi_vars_mm_check_policy_register(uef= i_vars_state *uv, return uefi_vars_mm_policy_error(mhdr, mchk, EFI_ALREADY_STARTED); } =20 + if (uv->used_storage + pe->size > uv->max_storage) { + return uefi_vars_mm_policy_error(mhdr, mchk, EFI_OUT_OF_RESOURCES); + } + uefi_vars_add_policy(uv, pe); + uv->used_storage +=3D pe->size; =20 mchk->result =3D EFI_SUCCESS; return sizeof(*mchk); diff --git a/hw/uefi/var-service-vars.c b/hw/uefi/var-service-vars.c index 2c83130ebf63..fd07782f1e0d 100644 --- a/hw/uefi/var-service-vars.c +++ b/hw/uefi/var-service-vars.c @@ -201,11 +201,15 @@ void uefi_vars_clear_all(uefi_vars_state *uv) void uefi_vars_update_storage(uefi_vars_state *uv) { uefi_variable *var; + uefi_var_policy *pol; =20 uv->used_storage =3D 0; QTAILQ_FOREACH(var, &uv->variables, next) { uv->used_storage +=3D variable_size(var); } + QTAILQ_FOREACH(pol, &uv->var_policies, next) { + uv->used_storage +=3D pol->entry->size; + } } =20 static gboolean check_access(uefi_vars_state *uv, uefi_variable *var) --=20 2.55.0 From nobody Sat Jul 25 08:04:50 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784728740; cv=none; d=zohomail.com; s=zohoarc; b=ELe+Y0G31DaTIzScFWds8y3sjH2mW8Vl1eQM8bjtLc6EGgSRpcnOSGfunKZzvEFd4Zvo95CGol98w3Synq0l1T/uh/mv2dbJklaYEMoRqnxKbfzphKF8ip4Q80lXL0o9A2B6XMXTk/c01cnTh7dsrTPuxGj5DaC19GUlrybVr/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784728740; h=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=lSDB2mjEKj7UE01c3nV5okLmrjxHSLhO7IXdrGfAoSw=; b=LoAmFJ4XaiKhQyuMqkUcvkbeYngfqsotNBJ/BPuBNb4DD+OFOysgM1n41Xkl0zxhORS71LPZJlRmsCrTpY6IwZY02S0erAP0u89RQg+qcWgSQEgmn/irzvyOohND7HQILsOftMyHI2qjBHwXWOE8rF4JDdyYxB3qJSY8ogLJmZc= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784728740585406.1740663050464; Wed, 22 Jul 2026 06:59:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmXSZ-0007gH-8L; Wed, 22 Jul 2026 09:58:07 -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 1wmXSV-0007ey-DE for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmXSS-0006t0-Le for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:03 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626--a2yE4UPNdK30pQ43LCjdg-1; Wed, 22 Jul 2026 09:57:58 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3B035182A13D for ; Wed, 22 Jul 2026 13:57:57 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.49.247]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EE8FC1800904; Wed, 22 Jul 2026 13:57:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B69621826B13; Wed, 22 Jul 2026 15:57:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784728679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lSDB2mjEKj7UE01c3nV5okLmrjxHSLhO7IXdrGfAoSw=; b=ZhAlpcQZ9E3NlqAcDLZmvaa8oawxsOjSAZ/X18p/RR8rhmv94yliPcQMkgfTYbGGSjQ+gb B1hfJVYiFon0zZLqtW+r84Ogg0qE/xcAR3doxE1G2bna6d5PKjq0r+PFYxHrxrBXLHcuFw kvJgrWojbZEyoq1FMtZ3lBGddK6jhjA= X-MC-Unique: -a2yE4UPNdK30pQ43LCjdg-1 X-Mimecast-MFC-AGG-ID: -a2yE4UPNdK30pQ43LCjdg_1784728677 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Luigi Leonardi Subject: [PULL 5/6] hw/uefi: add post_load checks Date: Wed, 22 Jul 2026 15:57:49 +0200 Message-ID: <20260722135752.1264244-6-kraxel@redhat.com> In-Reply-To: <20260722135752.1264244-1-kraxel@redhat.com> References: <20260722135752.1264244-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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: permerror client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 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 @redhat.com) X-ZM-MESSAGEID: 1784728741634158500 Content-Type: text/plain; charset="utf-8" Add sanity checks to uefi-vars state loaded from live migration data stream. Fail migration if invalid data or inconsistencies are found. Fixes: CVE-2026-61404 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3837 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3838 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3839 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3885 Acked-by: Luigi Leonardi Signed-off-by: Gerd Hoffmann Message-ID: <20260720143244.821889-6-kraxel@redhat.com> --- hw/uefi/var-service-core.c | 14 +++++++++++++- hw/uefi/var-service-json.c | 5 +++++ hw/uefi/var-service-policy.c | 28 +++++++++++++++++++++++----- hw/uefi/var-service-vars.c | 15 +++++++++++++++ 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/hw/uefi/var-service-core.c b/hw/uefi/var-service-core.c index 828d76007318..65da71029a60 100644 --- a/hw/uefi/var-service-core.c +++ b/hw/uefi/var-service-core.c @@ -5,6 +5,7 @@ */ #include "qemu/osdep.h" #include "qemu/crc32c.h" +#include "qemu/error-report.h" #include "system/dma.h" #include "migration/vmstate.h" =20 @@ -28,9 +29,20 @@ static int uefi_vars_post_load(void *opaque, int version= _id) { uefi_vars_state *uv =3D opaque; =20 + if (uv->buf_size > MAX_BUFFER_SIZE) { + error_report("invalid buffer size"); + return -1; + } + uv->buffer =3D g_malloc(uv->buf_size); + uefi_vars_update_storage(uv); + if (uv->used_storage > uv->max_storage) { + error_report("out of variable memory (%" PRId64 " > %" PRId64 ")", + uv->used_storage, uv->max_storage); + return -1; + } + uefi_vars_json_save(uv); - uv->buffer =3D g_malloc(uv->buf_size); return 0; } =20 diff --git a/hw/uefi/var-service-json.c b/hw/uefi/var-service-json.c index 8621b86c5c5f..88757d58b6f2 100644 --- a/hw/uefi/var-service-json.c +++ b/hw/uefi/var-service-json.c @@ -18,6 +18,7 @@ #include "qobject/qobject.h" #include "qobject/qjson.h" =20 +#include "qapi/error.h" #include "qapi/dealloc-visitor.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" @@ -249,6 +250,10 @@ void uefi_vars_json_load(uefi_vars_state *uv, Error **= errp) if (!(*errp)) { uefi_vars_from_qapi(uv, vs); uefi_vars_update_storage(uv); + if (uv->used_storage > uv->max_storage) { + error_setg(errp, "out of variable memory (%" PRId64 " > %" PRI= d64 ")", + uv->used_storage, uv->max_storage); + } } =20 qapi_free_UefiVarStore(vs); diff --git a/hw/uefi/var-service-policy.c b/hw/uefi/var-service-policy.c index 46c4ff2dacae..d43cc9b2500b 100644 --- a/hw/uefi/var-service-policy.c +++ b/hw/uefi/var-service-policy.c @@ -7,6 +7,7 @@ * https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Library/Vari= ablePolicyLib/ReadMe.md */ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "system/dma.h" #include "migration/vmstate.h" =20 @@ -16,14 +17,18 @@ =20 #include "trace.h" =20 -static void calc_policy(uefi_var_policy *pol); +static int check_calc_policy(uefi_var_policy *pol); =20 static int uefi_var_policy_post_load(void *opaque, int version_id) { uefi_var_policy *pol =3D opaque; + int rc; =20 - calc_policy(pol); - return 0; + rc =3D check_calc_policy(pol); + if (rc !=3D 0) { + error_report("invalid uefi variable policy"); + } + return rc; } =20 const VMStateDescription vmstate_uefi_var_policy =3D { @@ -80,32 +85,45 @@ static uefi_var_policy *wildcard_find_policy(uefi_vars_= state *uv, return NULL; } =20 -static void calc_policy(uefi_var_policy *pol) +static int check_calc_policy(uefi_var_policy *pol) { variable_policy_entry *pe =3D pol->entry; unsigned int i; =20 + if (pol->entry_size !=3D pe->size || + pe->offset_to_name >=3D pe->size) { + return -1; + } + pol->name =3D (void *)pol->entry + pe->offset_to_name; pol->name_size =3D pe->size - pe->offset_to_name; =20 + if (!uefi_str_is_valid(pol->name, pol->name_size, false)) { + return -1; + } + for (i =3D 0; i < pol->name_size / 2; i++) { if (pol->name[i] =3D=3D '#') { pol->hashmarks++; } } + + return 0; } =20 uefi_var_policy *uefi_vars_add_policy(uefi_vars_state *uv, variable_policy_entry *pe) { uefi_var_policy *pol, *p; + int rc; =20 pol =3D g_new0(uefi_var_policy, 1); pol->entry =3D g_malloc(pe->size); memcpy(pol->entry, pe, pe->size); pol->entry_size =3D pe->size; =20 - calc_policy(pol); + rc =3D check_calc_policy(pol); + g_assert(rc =3D=3D 0); =20 /* keep list sorted by priority, add to tail of priority group */ QTAILQ_FOREACH(p, &uv->var_policies, next) { diff --git a/hw/uefi/var-service-vars.c b/hw/uefi/var-service-vars.c index fd07782f1e0d..e0ea3d532eb6 100644 --- a/hw/uefi/var-service-vars.c +++ b/hw/uefi/var-service-vars.c @@ -47,6 +47,20 @@ static int uefi_vars_pre_load(void *opaque) return 0; } =20 +static int uefi_vars_post_load(void *opaque, int version_id) +{ + uefi_variable *var =3D opaque; + + if (!uefi_str_is_valid(var->name, var->name_size, true) || + var->attributes & ~EFI_VARIABLE_ATTRIBUTE_SUPPORTED || + (var->digest_size !=3D 0 && + var->digest_size !=3D 32 /* AUTHVAR_DIGEST_SIZE */)) { + error_report("invalid uefi variable"); + return -1; + } + return 0; +} + static bool uefi_vars_digest_is_needed(void *opaque) { uefi_variable *var =3D opaque; @@ -72,6 +86,7 @@ const VMStateDescription vmstate_uefi_variable_digest =3D= { const VMStateDescription vmstate_uefi_variable =3D { .name =3D "uefi-variable", .pre_load =3D uefi_vars_pre_load, + .post_load =3D uefi_vars_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINT8_ARRAY_V(guid.data, uefi_variable, sizeof(QemuUUID), = 0), VMSTATE_UINT32(name_size, uefi_variable), --=20 2.55.0 From nobody Sat Jul 25 08:04:50 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784728729; cv=none; d=zohomail.com; s=zohoarc; b=a7tHW6paH/iFquZiHtgqbXmfT0TLQyuDUXe6oCphTHoehFXqYx3zZ1dRQS9aIpEUAYNx4Tui036GjpHic7w6pf5IbdhHnyD7133ZQ+sx/RJ1y8xJhUopPjZPBBo9Zw5kDxceQoxhPRy5t8U5kLz65bksJG8ucWRYxUL7kwCN6SI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784728729; h=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=qnhe/K/CSnKFF9lkiIC7iZSwbav49Tu/KtUY5ACFBZ0=; b=JNjINIGTMb1bPUdi/XYyfdcBn/FCoGG0Lj/Z9omxFZD1+vWZpOSINN4H7lWrHCq7VsTs/W4LL+n0SvDQaYeHCLihd3H9vN+hQIvDDbUZZn+UFkXu6xkFepXg+fOJspLEagfYb0JalXWbuhnPfYoqtUP7wSRV8R1vxQmxcO9jPBA= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784728729161595.3196733988727; Wed, 22 Jul 2026 06:58:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmXSf-0007iV-K5; Wed, 22 Jul 2026 09:58:13 -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 1wmXSd-0007hv-Pp for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmXSc-0006tv-Cw for qemu-devel@nongnu.org; Wed, 22 Jul 2026 09:58:11 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-dAWsfpg-Plu0jthF9DIOnA-1; Wed, 22 Jul 2026 09:57:58 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 432D11956044 for ; Wed, 22 Jul 2026 13:57:57 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.44.49.247]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 003F03004082; Wed, 22 Jul 2026 13:57:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CC8CD1826B15; Wed, 22 Jul 2026 15:57:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784728686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qnhe/K/CSnKFF9lkiIC7iZSwbav49Tu/KtUY5ACFBZ0=; b=EfHErmm9QTBLR2/RN2jMf2sRTfHK88FrEMH7KSPv91TAy7Y6J3cFBsUINK+iVdntOMBRWB tBlwfXmIYVsCIFaSUtq79ta+T9xMSHtUc4u6MQHVUgPkxREgkKkBtjuRKiVwX4wo/K+dOy xvHpeXSXq+TY+qyc+ZwfyxqILRsB4UU= X-MC-Unique: dAWsfpg-Plu0jthF9DIOnA-1 X-Mimecast-MFC-AGG-ID: dAWsfpg-Plu0jthF9DIOnA_1784728677 From: Gerd Hoffmann To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Luigi Leonardi Subject: [PULL 6/6] hw/uefi: make SetupMode read-only Date: Wed, 22 Jul 2026 15:57:50 +0200 Message-ID: <20260722135752.1264244-7-kraxel@redhat.com> In-Reply-To: <20260722135752.1264244-1-kraxel@redhat.com> References: <20260722135752.1264244-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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: permerror client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1784728729616158500 Content-Type: text/plain; charset="utf-8" This is read-only variable which informs the OS about the secure boot state. Reject any attempts to write to it. Fixes: CVE-2026-16288 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4039 Acked-by: Luigi Leonardi Signed-off-by: Gerd Hoffmann Message-ID: <20260720143244.821889-7-kraxel@redhat.com> --- hw/uefi/var-service-auth.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/uefi/var-service-auth.c b/hw/uefi/var-service-auth.c index f3dc9c6ca608..899444af12df 100644 --- a/hw/uefi/var-service-auth.c +++ b/hw/uefi/var-service-auth.c @@ -298,6 +298,13 @@ efi_status uefi_vars_check_secure_boot(uefi_vars_state= *uv, uefi_variable *var) return EFI_WRITE_PROTECTED; } =20 + /* reject SetupMode updates */ + if (qemu_uuid_is_equal(&var->guid, &EfiGlobalVariable) && + uefi_str_equal(var->name, var->name_size, + name_setup_mode, sizeof(name_setup_mode))) { + return EFI_WRITE_PROTECTED; + } + return EFI_SUCCESS; } =20 --=20 2.55.0