From nobody Mon Nov 25 12:46:36 2024 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=sfc.wide.ad.jp ARC-Seal: i=1; a=rsa-sha256; t=1715050349; cv=none; d=zohomail.com; s=zohoarc; b=dh60r+Qkzt6c+iAOLI1d3jnNKPWlK0+r/Lj3x08k/zUyZjBxhp9q2SOrk54bMfryJ9WmrIfEmzVkswE9Dm1JICUoHekNqrTG0U8yTQjJ88EQLUF3u+rBrEDZbAXYIf4B+ldNsd4U+pmvO67GMqsY44uuvpmex1Rk4927cGDzkVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715050349; 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=4squ4scb5ohx+RwROEpIjCsFBk0z8UQzw4TUaM2yQ5o=; b=Tjv+xDeOWcoypzXuvMWsD42tb8qZQ02nRyzMIXsmxU+nGclm34lAxRCVhU0W6G8867cvboBUCNdT0kWga8sOHGXQGTVJQwjOaaub9Io6RcGpI4yiRT9jS/r/RZiRq4r8oNvUGDArlNn6i9+QrL2ykGUvOpxUOtJ4sH9IBJLMeCo= 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 1715050348768458.0086741140401; Mon, 6 May 2024 19:52:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4Avd-00055R-Ag; Mon, 06 May 2024 22:51:41 -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 1s4Avb-000550-Be for qemu-devel@nongnu.org; Mon, 06 May 2024 22:51:39 -0400 Received: from mail1.sfc.wide.ad.jp ([203.178.142.133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4AvZ-0006wg-AM for qemu-devel@nongnu.org; Mon, 06 May 2024 22:51:39 -0400 Received: from k8s-worker-01.tail087753.ts.net (unknown [IPv6:2400:4051:3e03:2d00:1e98:ecff:fe05:4840]) (Authenticated sender: mii) by mail1.sfc.wide.ad.jp (Postfix) with ESMTPSA id C2847C5838; Tue, 7 May 2024 11:51:32 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sfc.wide.ad.jp; s=mail1; t=1715050292; bh=BBFe5LEv4h/iv3i4//v6b2vpeYZ629qoaGvgPLz4eww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ieZGML8OOPXAerCPyfLWs92zvxAF4hab+tE8HFI7fe5CoEK4893pD/FIqJxtrtKFQ +V7ARdUayTJYSsj9Zmxj3rPfOLoznTQpJbmtzpf9tUpZ3s7DNWVK3R+BbRVyXb2Ksz MdnDloBhSDDvNWGtGfbm4ZUMgNhX8s38hv86mhAyVjCoSLbuQXG+Zjhjncnyyp7vrD 1iWQaSW5D8dGPCF1ZJdhhwvySIHKnrYtgDX2rAjpg3NAd/555Jz+0CrK8L7oP4nGG2 MWA/EeS8WWOuTK1o5oKcYkyyyOeWYwY/MhdXjSDHSwyvOQ6GRGgUiCS1fuCzLHqlQc yA20NCv2XDnaQ== From: Masato Imai To: qemu-devel@nongnu.org Cc: Masato Imai , Paolo Bonzini , kvm@vger.kernel.org (open list:Overall KVM CPUs) Subject: [PATCH v3 1/1] accel/kvm: Fix segmentation fault Date: Tue, 7 May 2024 02:50:11 +0000 Message-Id: <20240507025010.1968881-2-mii@sfc.wide.ad.jp> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507025010.1968881-1-mii@sfc.wide.ad.jp> References: <20240507025010.1968881-1-mii@sfc.wide.ad.jp> 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=203.178.142.133; envelope-from=mii@sfc.wide.ad.jp; helo=mail1.sfc.wide.ad.jp X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @sfc.wide.ad.jp) X-ZM-MESSAGEID: 1715050351197100002 Content-Type: text/plain; charset="utf-8" When the KVM acceleration parameter is not set, executing calc_dirty_rate with the -r or -b option results in a segmentation fault due to accessing a null kvm_state pointer in the kvm_dirty_ring_enabled function. This commit adds a null check for kvm_status to prevent segmentation faults. Signed-off-by: Masato Imai Tested-by: Li Zhijian --- accel/kvm/kvm-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index c0be9f5eed..544293be8a 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2329,7 +2329,7 @@ bool kvm_vcpu_id_is_valid(int vcpu_id) =20 bool kvm_dirty_ring_enabled(void) { - return kvm_state->kvm_dirty_ring_size ? true : false; + return kvm_state && kvm_state->kvm_dirty_ring_size; } =20 static void query_stats_cb(StatsResultList **result, StatsTarget target, --=20 2.34.1