From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 0BB5E1FF0AB for ; Mon, 07 Sep 2026 11:48:20 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 7D7012160D; Mon, 07 Sep 2026 11:47:57 +0200 (CEST) From: Erik Fastermann To: pve-devel@lists.proxmox.com Subject: [PATCH qemu v2 3/9] migration/qemu-file: allocate buffer with g_malloc Date: Mon, 7 Sep 2026 11:47:37 +0200 Message-ID: <20260907094744.131193-4-e.fastermann@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260907094744.131193-1-e.fastermann@proxmox.com> References: <20260907094744.131193-1-e.fastermann@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.503 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: O2YZ5636M7KFDZN5KSXACLLSA7JUJKTI X-Message-ID-Hash: O2YZ5636M7KFDZN5KSXACLLSA7JUJKTI X-MailFrom: efastermann@ruth.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Erik Fastermann X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Plain malloc() can fail and the result was never checked, while savevm-async asks for a 4 MiB buffer. g_malloc() exits instead of leaving a NULL buffer for the first write to dereference. Signed-off-by: Erik Fastermann --- .../0018-PVE-add-optional-buffer-size-to-QEMUFile.patch | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch index ab8aac1..b56dd34 100644 --- a/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch +++ b/debian/patches/pve/0018-PVE-add-optional-buffer-size-to-QEMUFile.patch @@ -12,6 +12,8 @@ Signed-off-by: Stefan Reiter Signed-off-by: Thomas Lamprecht [FE: rebase for 10.2.0] Signed-off-by: Fiona Ebner +[EF: allocate buffer with g_malloc] +Signed-off-by: Erik Fastermann --- migration/qemu-file.c | 48 +++++++++++++++++++++++++++------------- migration/qemu-file.h | 2 ++ @@ -19,7 +21,7 @@ Signed-off-by: Fiona Ebner 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c -index 9cf7dc3bd5..4a4de51fd9 100644 +index 9cf7dc3bd5..b1b7aa453e 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -34,8 +34,8 @@ @@ -59,7 +61,7 @@ index 9cf7dc3bd5..4a4de51fd9 100644 f->can_pass_fd = qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_FD_PASS); QTAILQ_INIT(&f->fds); + f->buf_allocated_size = buffer_size; -+ f->buf = malloc(buffer_size); ++ f->buf = g_malloc(buffer_size); return f; } @@ -108,7 +110,7 @@ index 9cf7dc3bd5..4a4de51fd9 100644 } g_clear_pointer(&f->ioc, object_unref); + -+ free(f->buf); ++ g_free(f->buf); + error_free(f->last_error_obj); g_free(f); -- 2.47.3