From nobody Mon May 6 00:47:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536736802481610.5831764223518; Wed, 12 Sep 2018 00:20:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A53A3097043; Wed, 12 Sep 2018 07:20:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F19A61F4D; Wed, 12 Sep 2018 07:19:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 392D24A460; Wed, 12 Sep 2018 07:19:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8C7JuOc007783 for ; Wed, 12 Sep 2018 03:19:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id E29825C224; Wed, 12 Sep 2018 07:19:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DACCF5C223 for ; Wed, 12 Sep 2018 07:19:53 +0000 (UTC) Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.217.80.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F04B77F6B0 for ; Wed, 12 Sep 2018 07:19:51 +0000 (UTC) Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id E5D5E2972A0C599E3B1E for ; Wed, 12 Sep 2018 15:19:49 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w8C7JlOB077585 for ; Wed, 12 Sep 2018 15:19:47 +0800 (GMT-8) (envelope-from wang.yechao255@zte.com.cn) Received: from kvm-146.zte.com.cn ([10.74.120.146]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018091215195617-8561651 ; Wed, 12 Sep 2018 15:19:56 +0800 From: Wang Yechao To: libvir-list@redhat.com Date: Wed, 12 Sep 2018 15:24:25 +0800 Message-Id: <1536737065-5031-1-git-send-email-wang.yechao255@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-09-12 15:19:56, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-09-12 15:19:39, Serialize complete at 2018-09-12 15:19:39 X-MAIL: mse01.zte.com.cn w8C7JlOB077585 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Sep 2018 07:19:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Sep 2018 07:19:52 +0000 (UTC) for IP:'63.217.80.70' DOMAIN:'mxhk.zte.com.cn' HELO:'mxhk.zte.com.cn' FROM:'wang.yechao255@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 63.217.80.70 mxhk.zte.com.cn 63.217.80.70 mxhk.zte.com.cn X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Wang Yechao Subject: [libvirt] [PATCH] numa: fix unsafe access to numa_nodes_ptr X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 12 Sep 2018 07:20:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" numa_nodes_ptr is a global variable in libnuma.so. It is been freed after main thread exits. If we have many running vms, restart the libvirtd service continuously at intervals of a few seconds, the main thread may exit before qemuProcessReconnect thread, and a segfault error occurs. Backstrace as follows: 0 0x00007f40e3d2dd72 in numa_bitmask_isbitset () from /lib64/libnuma.so.1 1 0x00007f40e4d14c55 in virNumaNodeIsAvailable (node=3Dnode@entry=3D0) at = util/virnuma.c:396 2 0x00007f40e4d16010 in virNumaGetHostMemoryNodeset () at util/virnuma.c:1= 011 3 0x00007f40b94ced90 in qemuRestoreCgroupState (vm=3D0x7f407c39df00, vm=3D= 0x7f407c39df00) at qemu/qemu_cgroup.c:877 4 qemuConnectCgroup (driver=3Ddriver@entry=3D0x7f407c21fe80, vm=3D0x7f407c= 39df00) at qemu/qemu_cgroup.c:969 5 0x00007f40b94eef93 in qemuProcessReconnect (opaque=3D) at= qemu/qemu_process.c:3531 6 0x00007f40e4d34bd2 in virThreadHelper (data=3D) at util/v= irthread.c:206 7 0x00007f40e214ee25 in start_thread () from /lib64/libpthread.so.0 8 0x00007f40e1e7c36d in clone () from /lib64/libc.so.6 Signed-off-by: Wang Yechao --- src/util/virnuma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 67e6c86..502b1d5 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -381,7 +381,10 @@ virNumaGetMaxCPUs(void) bool virNumaNodeIsAvailable(int node) { - return numa_bitmask_isbitset(numa_nodes_ptr, node); + if (numa_nodes_ptr) =20 + return numa_bitmask_isbitset(numa_nodes_ptr, node); + else + return false; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list