From nobody Tue Feb 10 21:46:09 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=swemel.ru ARC-Seal: i=1; a=rsa-sha256; t=1696935025; cv=none; d=zohomail.com; s=zohoarc; b=mBAm+Jne+30CoXPNC9bQLtfheP4/0DAiVkTwlAnCF3u9kpYcsZtwH0DFiDcbsI7AqsTlRpoCghSwjLgsZVRZD8LTIjtqNSuU/sH4gvlJoHsE0pDDMpJQIvnY4VJkiTeEQvezClNutu6Q27WWdYkMmKjvZ7xpjgXiLdbW4GaGvX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696935025; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ERKNBRgpdrA6t5WeubWreFcdB8u4YHHlL72l5T0lRbg=; b=X4A7LCgN/szcolJxpWrHnos+i7L+2ADAeciDVW2CqZai/Uy5ZHwFCFge0jqq4UoAQ/rhDmSZ2KHWrmoMGbwpwWRFlStdxAMdnIblkAtFll/OwHfYEDhcdfhwzamc+8U61rcXfW/ylvL3FeTqI1ThioGI4OqgW/Kbj/bn5zaAXsw= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696935024626179.29134499364238; Tue, 10 Oct 2023 03:50:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqAJG-0004WZ-15; Tue, 10 Oct 2023 06:49:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qqAJD-0004Ux-4j for qemu-devel@nongnu.org; Tue, 10 Oct 2023 06:49:51 -0400 Received: from mx.swemel.ru ([95.143.211.150]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qqAJA-0007hl-9y for qemu-devel@nongnu.org; Tue, 10 Oct 2023 06:49:50 -0400 From: Dmitry Frolov DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1696934982; 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; bh=ERKNBRgpdrA6t5WeubWreFcdB8u4YHHlL72l5T0lRbg=; b=dEYJD3zpAF2tX5p63xxAEzQgzBLvWzztrQmbdh+r8pHLTXOyVLNl79Myu0urVNL+tfXy5D gIPExUZ65Dtri17pR6pazMJfRqOQUzpJXmHf9zxOkeMKZdq7k8yjL5UoShXKLN/bZXQlw+ f3lH9/EGFxdyfcO1a0qAPa157Le+OzQ= To: Juan Quintela , Peter Xu , Fabiano Rosas , Leonardo Bras , qemu-devel@nongnu.org Cc: sdl.qemu@linuxtesting.org, Dmitry Frolov Subject: [PATCH v1] migration: fix RAMBlock add NULL check Date: Tue, 10 Oct 2023 13:48:53 +0300 Message-Id: <20231010104851.802947-1-frolov@swemel.ru> MIME-Version: 1.0 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=lists.gnu.org; Received-SPF: pass client-ip=95.143.211.150; envelope-from=frolov@swemel.ru; helo=mx.swemel.ru 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-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: 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 @swemel.ru) X-ZM-MESSAGEID: 1696935027804100001 Content-Type: text/plain; charset="utf-8" qemu_ram_block_from_host() may return NULL, which will be dereferenced w/o check. Usualy return value is checked for this function. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: c7c0e72408df5e7821c0e995122fb2fe0ac001f1 ("migration/ram: Handle RAM= block resizes during precopy") Signed-off-by: Dmitry Frolov Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela --- migration/ram.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index e4bfd39f08..bd4b7574e1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4281,6 +4281,11 @@ static void ram_mig_ram_block_resized(RAMBlockNotifi= er *n, void *host, RAMBlock *rb =3D qemu_ram_block_from_host(host, false, &offset); Error *err =3D NULL; =20 + if (!rb) { + error_report("RAM block not found"); + return; + } + if (migrate_ram_is_ignored(rb)) { return; } --=20 2.34.1