From nobody Sat May 11 17:06: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=1694077571; cv=none; d=zohomail.com; s=zohoarc; b=f4IquAleVH6UxHjpbrTgfwsrLYphMtuvKsHsPoMgw9DGG4GBEkB7t5kudAf81Babk8NKZt6dmfPsxpW8J0Nuy7FS5Ocu22ct6lxsm6F2I5K/3YdcCYo3Eg7bDphCq+66+0H6FNNtip9aiXYXQHgmYOnm3GIrf/CpYBamzk3YOOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694077571; 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=AxdL6hTXyegjdZvErfSSCApLsYYkA9fUuHwLWMwfaag=; b=IH4R+oPlmE6SSju6tvpVdNgIoJ3EowY9va2cQJRE3Ycdvj2LFFwRBNYkSrQzVjbmqcluYwX982Qv8m1OfiKyJW2FRAqPD4VP5tNm16IZvswQKIOfmrRojuTdfdHiQaIgUP7S8To7CqgOokBuyVcK/QAXP1Bsjiu3JLKlc7QTsws= 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 1694077571593396.2316810117251; Thu, 7 Sep 2023 02:06:11 -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-653-Mn-RjZCFMwuPJNIjWp3z_Q-1; Thu, 07 Sep 2023 05:06:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0EC029AB3E0; Thu, 7 Sep 2023 09:06:02 +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 DCA7163F6C; Thu, 7 Sep 2023 09:06:02 +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 B0DFD194658F; Thu, 7 Sep 2023 09:06:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB652194658C for ; Thu, 7 Sep 2023 09:06:00 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B6F8440C2070; Thu, 7 Sep 2023 09:06:00 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFAF540C84A6 for ; Thu, 7 Sep 2023 09:06: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 95D81816525 for ; Thu, 7 Sep 2023 09:06: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-690-73SMDlGFNtGhGZQS4RYEjA-1; Thu, 07 Sep 2023 05:05:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694077570; 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=AxdL6hTXyegjdZvErfSSCApLsYYkA9fUuHwLWMwfaag=; b=XuvwyNY8Ta4PHm/DtDnAA3dhytNpDVizfrIpluhKWZ2cKf2dAhqD+78EaeFZdO0kFC8/Ql HqyQTe3VsyrDHzMxYfgZUP5o0DAft/wcDx937s/6a0oZHuT11dE8/gl6OlqnSgUn704SKh IIJCHZGQJA5pQAAsgj0U8t7iYUn5oTA= X-MC-Unique: Mn-RjZCFMwuPJNIjWp3z_Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 73SMDlGFNtGhGZQS4RYEjA-1 From: Dmitry Frolov To: libvir-list@redhat.com Subject: [PATCH v2] lxc: fix lxcContainerMountAllFS() DEREF_BEFORE_CHECK Date: Thu, 7 Sep 2023 12:04:57 +0300 Message-Id: <20230907090456.563322-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.1 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.5 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: 1694077573769100001 Content-Type: text/plain; charset="utf-8"; x-default="true" vmDef->fss[i]->src->path may be NULL, so check is needed before passing it to VIR_DEBUG. Also removed checking vmDef->fss[i]->src for NULL, since it may not be NULL. Fixes: 57487085dc ("lxc: don't try to reference NULL when mounting filesyst= ems") Signed-off-by: Dmitry Frolov Reviewed-by: Michal Privoznik --- src/lxc/lxc_container.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 21220661f7..9601061b23 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1467,12 +1467,12 @@ static int lxcContainerMountAllFS(virDomainDef *vmD= ef, if (STREQ(vmDef->fss[i]->dst, "/")) continue; =20 - VIR_DEBUG("Mounting '%s' -> '%s'", vmDef->fss[i]->src->path, vmDef= ->fss[i]->dst); + VIR_DEBUG("Mounting '%s' -> '%s'", NULLSTR(vmDef->fss[i]->src->pat= h), 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 && + if (!(vmDef->fss[i]->src->path && STRPREFIX(vmDef->fss[i]->src->path, vmDef->fss[i]->dst)) && lxcContainerUnmountSubtree(vmDef->fss[i]->dst, false) < 0) return -1; --=20 2.34.1