From nobody Wed Oct 9 01:28:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=swemel.ru ARC-Seal: i=1; a=rsa-sha256; t=1694014524; cv=none; d=zohomail.com; s=zohoarc; b=UHM2jvTd4nFjc70NSqbcskfXOQM4c0O3fjsLgEu52LtVuuFjjMSEqUqLS2znXYQ29fc40lHAQ0qBUufZRVd+5jZZtAg1UTFLbuzsZ21rXtrM9Ilg/cs9b29FeOzdnkAtoVCkU6iFBYrPqTK3Kd/8KeLaHv6wPjKWEUmGVpLZkfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694014524; 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=2kHm729p+r4td762EqeqZgEjbyhmhzU53SHD/hu09jM=; b=Yu3IbF3obZu5WgRNqJbQ+NzqWe01Jk91JEyOaWq+uPkYxL2LnazEO80vcsmAROY1gLy5uo9wxs/EIaQf6mH0fM3wSzmDT72C3yFEXcBtwyMcqvCYkFyF+iBuG595N3vMtVy7nvc26IlEHTASj1Ocy7vWNItQ6gatQMH2EoQS0LE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1694014523653453.34238909134854; Wed, 6 Sep 2023 08:35:23 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [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-127-4OmRzW5_OdOpE1En22Ej5A-1; Wed, 06 Sep 2023 11:35:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26DF91C07259; Wed, 6 Sep 2023 15:35:15 +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 9C84140C2070; Wed, 6 Sep 2023 15:35:13 +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 25CFF194658D; Wed, 6 Sep 2023 15:35:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5807F194658C for ; Wed, 6 Sep 2023 15:35:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 035642026D68; Wed, 6 Sep 2023 15:35:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF9F22026D4B for ; Wed, 6 Sep 2023 15:35:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [205.139.110.61]) (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 B2FDB3C1937B for ; Wed, 6 Sep 2023 15:35:00 +0000 (UTC) Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-ZWovrdhPMCCo49Wa0iycEQ-1; Wed, 06 Sep 2023 11:34:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694014522; 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=2kHm729p+r4td762EqeqZgEjbyhmhzU53SHD/hu09jM=; b=TW/o7Sghp9j7PC4QNudIyxCB33R7yM97snnTgfu7ksZRNC+cItz/zzyg6nxDa+lvVg2NpZ CGJcXJKmCY1C3j+wx+mjPHb/k8OmDJt1JAxOifLp/2Gi5eW5LhQ/8y7L1wNpeecJZ3+fPD SAksKeyzRLISGXdh94MqlgnFZ9FRS5Q= X-MC-Unique: 4OmRzW5_OdOpE1En22Ej5A-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ZWovrdhPMCCo49Wa0iycEQ-1 From: Dmitry Frolov To: libvir-list@redhat.com Subject: [PATCH] lxc: fix lxcContainerMountAllFS() DEREF_BEFORE_CHECK Date: Wed, 6 Sep 2023 18:34:42 +0300 Message-Id: <20230906153443.207740-1-frolov@swemel.ru> 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.4 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: Dmitry Frolov Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: swemel.ru Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694014527214100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Reviewing the sources, I found, that in function lxcContainerMountAllFS() pointers vmDef->fss[i]->src and vmDef->fss[i]->src->path are checked for NULL after dereferencing in VIR_DEBUG() macro. Fixes: 57487085dc ("lxc: don't try to reference NULL when mounting filesyst= ems") --- src/lxc/lxc_container.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 21220661f7..58a6695458 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1467,13 +1467,15 @@ static int lxcContainerMountAllFS(virDomainDef *vmD= ef, if (STREQ(vmDef->fss[i]->dst, "/")) continue; =20 + if (!(vmDef->fss[i]->src && vmDef->fss[i]->src->path)) + return -1; + VIR_DEBUG("Mounting '%s' -> '%s'", vmDef->fss[i]->src->path, vmDef= ->fss[i]->dst); =20 if (lxcContainerResolveSymlinks(vmDef->fss[i], false) < 0) return -1; =20 - if (!(vmDef->fss[i]->src && vmDef->fss[i]->src->path && - STRPREFIX(vmDef->fss[i]->src->path, vmDef->fss[i]->dst)) && + if (!STRPREFIX(vmDef->fss[i]->src->path, vmDef->fss[i]->dst) && lxcContainerUnmountSubtree(vmDef->fss[i]->dst, false) < 0) return -1; =20 --=20 2.34.1