From nobody Tue May 7 23:48:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600442553; cv=none; d=zohomail.com; s=zohoarc; b=SgATqxDhUfuYjWy0ofDNeFvDKnUNMi6XwwSAI1oyK8otMkkVAhYhmePGhy2z17MDhxVD4HCj4Tv5D1UnzwBuLK21seuPZKsYX2H0utGWncl6wYquAQpFlufHQesU2yR/LBhHp6agSfBh9F+CIhp5luXUDXOmQp46kwgD/0VyFSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600442553; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=SsJ9T03FLpo5/oRUzIMD8dt9gfahzYwEoPIInb5/pLg=; b=Rf1uVJnKLUt8utd+RGMxmFl0xvGXALeOwtWTNc8+2uBpVJWoiAVIPTjYkvbCXxf1hsSR/XG4OKlgPjFgilCbKCQz2PDSLVz46sqvjFGS4uadwDtPflABuqCrC3VgxdCKWj7UsD36QG9s95ik+JXLdlRVT5VTnjeMvAB78VBXr8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1600442553097945.2624891858017; Fri, 18 Sep 2020 08:22:33 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-197-0WheMMb-NU-zI2WA8zyEaA-1; Fri, 18 Sep 2020 11:22:16 -0400 Received: by mail-wr1-f72.google.com with SMTP id l9so2240293wrq.20 for ; Fri, 18 Sep 2020 08:22:15 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (65.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.65]) by smtp.gmail.com with ESMTPSA id l19sm5440401wmi.8.2020.09.18.08.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 08:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600442551; 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=SsJ9T03FLpo5/oRUzIMD8dt9gfahzYwEoPIInb5/pLg=; b=PFxYTrnDd9wJSzrM5vS/MoZyEMIhf9fv0MLZtwmgES7CHkF26IezVkCArvXHMuq5L1IZfF TSahKpPSlCNF74a3pVaL8x8r7Dz9SlT432y08LUeE/ugVNjYXY+qtlI7CBo8tpzzG1L0iu agS2uxuFtfWUUinUt1MH1RwL6P3gJ7g= X-MC-Unique: 0WheMMb-NU-zI2WA8zyEaA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SsJ9T03FLpo5/oRUzIMD8dt9gfahzYwEoPIInb5/pLg=; b=k1yZ5vfnGmbawLdmIIbshRW1X2YNKFGLNTiuVgTc3loFNn1NjTE8Nfu5+8QU26qNpr ObnuhtgjX3m/ij++3D25Vl1eft9f0CinY/CMO7LN/1jIsujJczKOUD+3ECrcBGoNH40I ooIXNIy+POk7/FBWOAIcHZHV5LuDPaFiDxwUrc8D0HiTQyIZAhUqCJKvAguaA7PZsjZR /FsPEQnGgX0UN1q7fg/dfpl2t+e2TV9H71sJfBjEZSxH5kYeHWE5aQjXtHSezjH6c7Dp g8+cCWhQTNiXMnWe1FMXQVesG4KPd4yH1s6qLbS228l9OFTUagn1nvluC7KcPFnW0L9P SHPQ== X-Gm-Message-State: AOAM531NYhYmMc9FVLn8s7q09Mn1W3NJBPQ9GiLRrFaPGu6KKO6/uvqZ /OwEbevJrfN0j2YCdiz6nY0W2b7+8xsKjWm1drrkzBLzH7jM0Q1NUHWjQx/ELTBqPPSsXVYyEC2 fPI+iIXVxF8gxog== X-Received: by 2002:adf:81c6:: with SMTP id 64mr37031757wra.176.1600442534508; Fri, 18 Sep 2020 08:22:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDdirnvEKJHUZ9rncgN/VlrCM7/4hHmSrWx3Ho8whcY8/EY3xim+zmQ/JE5JLx+rtteJWLzw== X-Received: by 2002:adf:81c6:: with SMTP id 64mr37031742wra.176.1600442534330; Fri, 18 Sep 2020 08:22:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laszlo Ersek , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 1/1] hw/nvram/fw_cfg: fix FWCfgDataGeneratorClass::get_data() consumption Date: Fri, 18 Sep 2020 17:22:07 +0200 Message-Id: <20200918152207.157589-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200918152207.157589-1-philmd@redhat.com> References: <20200918152207.157589-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Laszlo Ersek The documentation on g_byte_array_free() says: > Returns > > the element data if free_segment is FALSE, otherwise NULL. The element > data should be freed using g_free(). Because we currently call g_byte_array_free() with free_segment=3DTRUE, we end up passing data=3DNULL to fw_cfg_add_file(). On the plus side, fw_cfg_data_read() and fw_cfg_dma_transfer() both deal with NULL data gracefully: QEMU does not crash when the guest reads such an item, the guest just gets a properly sized, but zero-filled blob. However, the bug breaks UEFI HTTPS boot, as the IANA_TLS_CIPHER array, generated otherwise correctly by the "tls-cipher-suites" object, is in effect replaced with a zero blob. Fix the issue by passing free_segment=3DFALSE to g_byte_array_free(): - the caller (fw_cfg_add_from_generator()) temporarily assumes ownership of the generated byte array, - then ownership of the byte array is transfered to fw_cfg, as fw_cfg_add_file() links (not copies) "data" into fw_cfg. Cc: "Daniel P. Berrang=C3=A9" Cc: "Philippe Mathieu-Daud=C3=A9" Cc: Gerd Hoffmann Fixes: 3203148917d035b09f71986ac2eaa19a352d6d9d Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20200916151510.22767-1-lersek@redhat.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/nvram/fw_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index f3a4728288e..0e95d057fd5 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1056,7 +1056,7 @@ bool fw_cfg_add_from_generator(FWCfgState *s, const c= har *filename, return false; } size =3D array->len; - fw_cfg_add_file(s, filename, g_byte_array_free(array, TRUE), size); + fw_cfg_add_file(s, filename, g_byte_array_free(array, FALSE), size); =20 return true; } --=20 2.26.2