From nobody Sat Apr 20 14:20:37 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=1574667400; cv=none; d=zohomail.com; s=zohoarc; b=D1Hx8aiOGYi6uHQzcSqjBkClHW2V/loXAO9IYKEXBU37M9K7v1oh1RWxXWu0aFdT1DK1VdlwO2xsKvW/T1Xy40Fp1oPkqFqLy61XTvrV/MuJ2WU/vAmkI2c2Y2pDO3d2M6urV8rQ54UQ+DRQbao6kmb/IAnyarVBXTWtOoEaSAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574667400; 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=OLco+mpdJ6Jz09dpOsV2WUZ7cwlngwRbtbqdnCoOqp4=; b=IrvPZY+9UM71aOUs1ItNpwJU6WFjbadSGYn7b5g2k3k26xHy+Dm6ZkDWahoOAfLFeB+Fh6Vbn0xnD/ZLHEwYZmMSg0Pxi5v6FcSiQpR3hBE7l6yoALTOMP5eExw5SkE8yxDjZKiM3IOHop2oJngiRblyGkLOJdhTKSLObDd+fqE= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1574667400091457.74885116788255; Sun, 24 Nov 2019 23:36:40 -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-417-XDG3bu-mO9GxlkAlxI-Jiw-1; Mon, 25 Nov 2019 02:36:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D968A75B1; Mon, 25 Nov 2019 07:36:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC5D860863; Mon, 25 Nov 2019 07:36:26 +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 6425118089CD; Mon, 25 Nov 2019 07:36:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAP7Yvr1005276 for ; Mon, 25 Nov 2019 02:34:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4DC7910D17B9; Mon, 25 Nov 2019 07:34:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48D2A10D17AB for ; Mon, 25 Nov 2019 07:34:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 194B6101564C for ; Mon, 25 Nov 2019 07:34:55 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-3eK5FD4BNOWPdXE7ptg7pQ-1; Mon, 25 Nov 2019 02:34:53 -0500 Received: by mail-pf1-f194.google.com with SMTP id s5so6934561pfh.9; Sun, 24 Nov 2019 23:34:52 -0800 (PST) Received: from localhost.localdomain.localdomain (li541-253.members.linode.com. [198.74.49.253]) by smtp.gmail.com with ESMTPSA id 83sm7195557pgh.12.2019.11.24.23.34.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Nov 2019 23:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574667398; 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=OLco+mpdJ6Jz09dpOsV2WUZ7cwlngwRbtbqdnCoOqp4=; b=SdBjsxvN9UaiBsUi337f7mX6KpBJl9YvaK9aJifT8y+bW/mc44BgcQuipBTm2AFainkFam Cj2CswwSfZZgnqsB+i2cP554f7KvgV2hHsu3G+j0sw5rafwun5awIV0VmHBEHThUWVfkdZ kdcHGZMS7Bv4TvAsDEKXo65XQRS75O8= 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=Yt8kBfJHVnbEiLapxwlh+Ve1YP1rumFfFIGj/W3Stq4=; b=NHkBvGvwA7BwvEp9ogXlVId7oGpNFXzS5aoKYu7JZ6PUbHzgzyli2hMpgjWe71j9o5 M0CYp1yRSFK3L+dK4CCafMwYH8GFnIDqcNXGvZh817MhB3SlXeT5+M0SpUW5YCRoLJT5 Y3Mdn9Pz9NKDAp7kz8pWfp7sGeEmllE0ibchRMsFN7IyO2l00Ome6z+5VXX4BKGrmS9r aFb8YrkWoG01vuedjtz12+uu+uNqQRmaNUoSnqCZxTva5/eWtlm1GguJ5L+OMv8ZLDWZ DjNUjAhABovtDalrBKuZIDv7qOMi9WvUOnpAi+Y4G4Os7kDGqrpUW9Z9biRxDfguw9dd uBLw== X-Gm-Message-State: APjAAAVIOvj6bzXqOKxzKPRqGyzZulU2pceFzzID37ZYfJQ6hRomdjSu mW22Kh9ULHe+1xrImgCNVXEKEI4V X-Google-Smtp-Source: APXvYqxKyGZrCV9ZdPSBauJXBeSel7qmNXIVtaJKbOKtkCXZyh9HsTSPI69gx8EEGq/dHsY2uB0rpw== X-Received: by 2002:a63:da13:: with SMTP id c19mr30132005pgh.435.1574667291415; Sun, 24 Nov 2019 23:34:51 -0800 (PST) From: LanceLiu To: libvir-list@redhat.com Date: Mon, 25 Nov 2019 15:34:39 +0800 Message-Id: <1574667279-80696-1-git-send-email-liu.lance.89@gmail.com> X-MC-Unique: 3eK5FD4BNOWPdXE7ptg7pQ-1 X-MC-Unique: XDG3bu-mO9GxlkAlxI-Jiw-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xAP7Yvr1005276 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.13 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/libvirt_remote.syms | 1 + src/remote/remote_daemon_stream.c | 10 +++++++++- src/rpc/virnetserverclient.c | 12 ++++++++++++ src/rpc/virnetserverclient.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 0493467..c32e234 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -173,6 +173,7 @@ virNetServerClientPreExecRestart; virNetServerClientRemoteAddrStringSASL; virNetServerClientRemoteAddrStringURI; virNetServerClientRemoveFilter; +virNetServerClientCheckFilterExist; virNetServerClientSendMessage; virNetServerClientSetAuthLocked; virNetServerClientSetAuthPendingLocked; 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