From nobody Fri Apr 26 09:14:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1574594110; cv=none; d=zohomail.com; s=zohoarc; b=hltvkwDfS5Xejss/OtuF7pxh5GpVaHbWxhoWiit+dD/e5ydo8RS22EayzNNfXuDb116bG87EhcFCY+Xiie/RwU+dFyNRN7eYUjde6UMP8L96QPVCo+axiJ+rduh4id6AvuCV2cDiQZYNw5PSKAZrPY49vfPQ/98iDc2697hSqQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574594110; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Cj7FyO5ucezE2rxsbeKoPAw6KKDX7nrPmi9r3eihn60=; b=IIv49G346nAnIRP07rS9dYzl8xfUkK/VmJ+L7IHi79gMmEBKM0VnJDkCE/zjAWSwbEnwbj6R3CPRPENdSDZLYrZNtnm3VrqVIwZOqT5tobDszz1pPpyI3lS+iJcVl5AJVUFGRqOerUmQs3OQ28qmBUtzJj6G0YtY+lSq4h60C+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1574594110689790.103329337097; Sun, 24 Nov 2019 03:15:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-M2Th1vnXOeWA4-uVK5bzZA-1; Sun, 24 Nov 2019 06:15:06 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D089E18037F8; Sun, 24 Nov 2019 11:14:57 +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 2E1C460BF4; Sun, 24 Nov 2019 11:14:56 +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 8E3254BB65; Sun, 24 Nov 2019 11:14:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAOBEkGu009618 for ; Sun, 24 Nov 2019 06:14:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 11C89107512; Sun, 24 Nov 2019 11:14:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D84B100D92 for ; Sun, 24 Nov 2019 11:14:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF3519018E7 for ; Sun, 24 Nov 2019 11:14:43 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-P9nSLsWWNC2C6xh8sbYV2g-1; Sun, 24 Nov 2019 06:14:41 -0500 Received: by mail-pf1-f195.google.com with SMTP id p24so5875472pfn.4; Sun, 24 Nov 2019 03:14:41 -0800 (PST) Received: from localhost.localdomain.localdomain (li541-253.members.linode.com. [198.74.49.253]) by smtp.gmail.com with ESMTPSA id s24sm4415712pgm.79.2019.11.24.03.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Nov 2019 03:14:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574594109; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Cj7FyO5ucezE2rxsbeKoPAw6KKDX7nrPmi9r3eihn60=; b=R+TL/erAPCKPAH0z6SLbN2aPaVW3bC7tBrgteVPTRmzGaUQ4Jw5d8I3Azj+Oko6JkYevgI QEvz6hkSRu+digHa8vkprI9b0SR8ltco0FmzxxCZA+dqKN09Or84Tjr/g6P/U8IRtrRMTq 9umbGn2oyxHnHFN5W8xd6eq5vqytE+I= 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; bh=lWCeT8iH9AwwXzQ8J7L4ED1WfP5NqJ5M2hzCPEEMeck=; b=cSnsfA9mTLRumnf1Ht5sdTbQy/2bMDcuOfyW6GibCHkBxSFFh+ClGW6Clhjm6XELAt oLfuHxDsLFaMwP37I6I8ucWPT42YMNx4W/PrX9mHq8DUU9KAH8/0pM9S+LgGSQeJOfz6 YSWR7EwTdoSUbeyPgzoDWjGcmbdE9mfZo/leDPYKu1cmbNV6mrBsC3XxtKAc8kSGpuL9 jSdrIBzwqytKq40Uh+hFVeU/SSDMn+Pj9fJq9dNoUmhkuwPTEvw/VIR7gkQ3ytlX2P+1 0J/i0VNNQgTgPUrxV89m/dfriq93KNcHXfR6bQJbrMkH5b2KeFCK6xrSdmB0we+xF7a6 kGTw== X-Gm-Message-State: APjAAAWyGYL1f7qz6EJlRyfHuVUGhsP6eZhAnmhyO2vUkYu3xIuzQoWL wi+zDgDawXMHG3OByEFWF/bbFTVF X-Google-Smtp-Source: APXvYqx2x0CmbNY8nOptNVOB3mvd69gyyzDnPDeAuZAaWef2/4f4s0+7801LmVEH2eALpP8exGiW7A== X-Received: by 2002:a63:ce12:: with SMTP id y18mr25219390pgf.186.1574594079926; Sun, 24 Nov 2019 03:14:39 -0800 (PST) From: LanceLiu To: libvir-list@redhat.com Date: Sun, 24 Nov 2019 19:14:25 +0800 Message-Id: <1574594065-106523-1-git-send-email-liu.lance.89@gmail.com> X-MC-Unique: P9nSLsWWNC2C6xh8sbYV2g-1 X-MC-Unique: M2Th1vnXOeWA4-uVK5bzZA-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAOBEkGu009618 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, LanceLiu Subject: [libvirt] [PATCH] Fix bug libvirt daemon segfault when new force console vm session break down existed console session. When force console vm command arrived, libvirtd will break down existed console session, and in this procedure, it will call daemonStreamEvent() to release resources , so daemonStreamFilter() need to check if stream filter existed when get client object lock and client->privData's lock, if not existed, just return -1 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 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" --- src/remote/remote_daemon_stream.c | 10 +++++++++- src/rpc/virnetserverclient.c | 12 ++++++++++++ src/rpc/virnetserverclient.h | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index 82cadb6..de0dca3 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -292,10 +292,18 @@ daemonStreamFilter(virNetServerClientPtr client, { daemonClientStream *stream =3D opaque; int ret =3D 0; + daemonClientPrivatePtr priv =3D NULL; + int filter_id =3D stream->filterID; =20 virObjectUnlock(client); + priv =3D virNetServerClientGetPrivateData(client); virMutexLock(&stream->priv->lock); virObjectLock(client); + if (!virNetServerClientCheckFilterExist(client, filter_id)) { + VIR_WARN("this daemon stream filter: %d have been deleted!", filte= r_id); + ret =3D -1; + goto cleanup; + } =20 if (msg->header.type !=3D VIR_NET_STREAM && msg->header.type !=3D VIR_NET_STREAM_HOLE) @@ -317,7 +325,7 @@ daemonStreamFilter(virNetServerClientPtr client, ret =3D 1; =20 cleanup: - virMutexUnlock(&stream->priv->lock); + virMutexUnlock(&priv->lock); return ret; } =20 diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 67b3bf9..f80f493 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -287,6 +287,18 @@ void virNetServerClientRemoveFilter(virNetServerClient= Ptr client, virObjectUnlock(client); } =20 +int virNetServerClientCheckFilterExist(virNetServerClientPtr client, + int filterID) +{ + virNetServerClientFilterPtr tmp; + + tmp =3D client->filters; + while(tmp && tmp->id !=3D filterID) { + tmp =3D tmp->next; + } + + return (tmp !=3D NULL); +} =20 /* Check the client's access. */ static int diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h index 7a3061d..85fda39 100644 --- a/src/rpc/virnetserverclient.h +++ b/src/rpc/virnetserverclient.h @@ -93,6 +93,8 @@ int virNetServerClientAddFilter(virNetServerClientPtr cli= ent, =20 void virNetServerClientRemoveFilter(virNetServerClientPtr client, int filterID); +int virNetServerClientCheckFilterExist(virNetServerClientPtr client, + int filterID); =20 int virNetServerClientGetAuth(virNetServerClientPtr client); void virNetServerClientSetAuthLocked(virNetServerClientPtr client, int aut= h); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list