From nobody Sun May 19 15:58:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1690357723; cv=none; d=zohomail.com; s=zohoarc; b=Ee5xniNw1fdpdtN0KpZ+yvcW+3uTVX11LTx+MDK1YQA6qQb05QRRG29nGvu/ZSF3r6X1FNOBL0JcanhWJhDWZBgBgFlfI+eVeRjuPWyQOj9nnTtxhFAz/Ya0fjQOJ+XgZRM55H410Rd8YFvite2e1hzTvOuUjkJZledhL6ki6hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690357723; 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=YNqo/pjwWY+CF4intgNm9oWTuUWB/9wxMIa7+wEpKZk=; b=C8xctV6/jPs1xi0xjDUFZAL+qAwqnfaC36Zf4f4fhfCEhf6+nt/WufiJSH1KkE65oGbq+C0RmGh0LsG1vP7WwXFYzyt4HIEmrmvYWd7y9O0xC9ftzT4bnTHuoct9yEmg5o8QjCmhBLaRc62pEEHtL6aX9zUvOmr0pg3fiFiOEFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1690357723811631.4621506602501; Wed, 26 Jul 2023 00:48:43 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-RzlMKi8CPRWcp8n8jU7o-A-1; Wed, 26 Jul 2023 03:48:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DEB151C07543; Wed, 26 Jul 2023 07:48:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DCEB2166B25; Wed, 26 Jul 2023 07:48:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BCE3D19465BA; Wed, 26 Jul 2023 07:48:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0EDE61946589 for ; Wed, 26 Jul 2023 07:47:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E2C4E46A3A9; Wed, 26 Jul 2023 07:47:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAED8492C13 for ; Wed, 26 Jul 2023 07:47:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B03A729AB3E2 for ; Wed, 26 Jul 2023 07:47:40 +0000 (UTC) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-dFOrDeeyOCmJZgU2FDzaqg-1; Wed, 26 Jul 2023 03:47:35 -0400 Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=dv..) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qOZDF-00BtLO-15; Wed, 26 Jul 2023 09:47:19 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690357722; 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=YNqo/pjwWY+CF4intgNm9oWTuUWB/9wxMIa7+wEpKZk=; b=BgUcD59NRNDw689tXN8BOiV2BO6oO8hNbg8GQaG5zkHe0U/VLb+35B6i8oEEOFAhNTwjvm Q2fYLgDxcFSj1P57XYGGsq9KnQNK4fC37dcjcvu3P26MeyuF1QnU6o8tjS/fWBaCYldpTN KSiu0LJSchxEbe8vhCnmzFcwTErbk/Y= X-MC-Unique: RzlMKi8CPRWcp8n8jU7o-A-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: dFOrDeeyOCmJZgU2FDzaqg-1 From: Oleg Vasilev To: libvir-list@redhat.com Subject: [PATCH] remote: handle partial data transmission Date: Wed, 26 Jul 2023 13:47:15 +0600 Message-ID: <20230726074722.40979-1-oleg.vasilev@virtuozzo.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Oleg Vasilev , Den Lunev , Nikolai Barybin , =?UTF-8?q?Michal=20Pr=C3=ADvozn=C3=ADk?= Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: virtuozzo.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1690357724439100001 Content-Type: text/plain; charset="utf-8"; x-default="true" A new bug was introduced as a part of use-after-free fix below: commit 411cbe7199ce533ae5fa78f5558dddca6f88ef1a Author: Oleg Vasilev Date: Tue Jul 4 13:10:22 2023 +0600 remote: fix stream use-after-free When the message was processed partially, it is actually supposed to stay in the queue to be processed again. In such case, reinsert it back. Signed-off-by: Oleg Vasilev Reviewed-by: Michal Privoznik --- src/remote/remote_daemon_stream.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index 345c40b48c..f52af790c1 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -775,8 +775,12 @@ daemonStreamHandleWrite(virNetServerClient *client, ret =3D -1; } =20 - if (ret > 0) - break; /* still processing data from msg */ + if (ret > 0) { + /* still processing data from msg, put it back into queue */ + msg->next =3D stream->rx; + stream->rx =3D msg; + break; + } =20 if (ret < 0) { virNetMessageFree(msg); --=20 2.41.0