From patchwork Tue Oct 8 16:22:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175522 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5922043ill; Tue, 8 Oct 2019 09:26:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqynjQ2uJh6SOmxOsdjfKuM4lG436sVmQ7NI5O5iRUC50xQ683vJdsY4jL58VLcLmRxJLw13 X-Received: by 2002:a6b:da1a:: with SMTP id x26mr7362478iob.63.1570551981400; Tue, 08 Oct 2019 09:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570551981; cv=none; d=google.com; s=arc-20160816; b=NDsRtOWBaFLbv35s/OJRN5qTbXObjdqBVC6KlpfdRRmMkuWQqSBMs7ydWIMaWhOooj m6k9Mx8N6sS9wE2R2HluMyUHhewgaYGzr3VaBeM5FR1d3odr+o4uQ/alv9Ub7ZRy4jL9 uj/xqiGC3Vu/NUO/FwdQSYc/l/9dFk6nFs3WmnKxCMtLfnrenY3E/R1la4Iz9ymaOoKJ K/2AWGJY/XYtxRdhg6clFwd0vo8pdK4tv1wljNx071aouneA3hFHMgcRiUyxJkzHGw+c nP30TbsQqcwGwPUm4LJOlGk5wrQwUhmyFobja0ui87aoCezlSRMPXVdUYKF4H+QVDrCX w4UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=YCEIDbDZ9L1RnMvw7Mc08Y1Efd3yfYbSUiyEFsGfnIM=; b=icr9fQx/8UwljMUzdHTTbeQ9hV2QlZwf0rgjKlRat13JpSbuF6d4GtlZl9II7tnDwt +/ABRINoVm6qs76telPMf8m977JK2NN5PquOoI8E4Ncj2DQzvB4GgDdJzurGtroq3JFr BrFZL47IeXO9sSA1Z+G5If/JoyWakxV1Wo3PJuuNGhWKdbYXg7McR/CMgD39EOF9MC8O Ad+NiLNTwA4LGusg/b0AyCTRB6fCQiBFbVY8EHMvC6nxYS5JlDSCmlbnsCbHgj/A5xNd pDF4Av7PndhsK0IVZpAdsImkUL9MnvvajBznc8parBFChB7fFyUj2uTjgws+qnupr/zq uIAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id d62si22622056iog.25.2019.10.08.09.26.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 09:26:21 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CEEF30941C4; Tue, 8 Oct 2019 16:26:20 +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 E873260166; Tue, 8 Oct 2019 16:26:19 +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 9C68A4EE6D; Tue, 8 Oct 2019 16:26:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x98GM1bt008690 for ; Tue, 8 Oct 2019 12:22:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C7D160606; Tue, 8 Oct 2019 16:22:01 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.bos.redhat.com (dhcp-17-175.bos.redhat.com [10.18.17.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23FAF60A9F; Tue, 8 Oct 2019 16:22:01 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 8 Oct 2019 12:22:25 -0400 Message-Id: <8392bd203a3b24d7e07a4544c7ddf122abe6a5ec.1570551720.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: christian.ehrhardt@canonical.com Subject: [libvirt] [PATCH 5/7] security: apparmor: Push virStorageSource checks to add_file_path 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 08 Oct 2019 16:26:20 +0000 (UTC) This mirrors the code layout in security_selinux.c. It will also make it easier to share the checks for qcow2 external data_file support eventually Signed-off-by: Cole Robinson --- src/security/virt-aa-helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 9f39eb2e2b..20281c38b7 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -917,6 +917,10 @@ add_file_path(virStorageSourcePtr src, { int ret; + /* execute the callback only for local storage */ + if (!src->path || !virStorageSourceIsLocalStorage(src)) + return 0; + if (depth == 0) { if (src->readonly) ret = vah_add_file(buf, src->path, "rk"); @@ -941,12 +945,8 @@ disk_add_files(virDomainDiskDefPtr disk, virStorageSourcePtr tmp; for (tmp = disk->src; virStorageSourceIsBacking(tmp); tmp = tmp->backingStore) { - /* execute the callback only for local storage */ - if (virStorageSourceIsLocalStorage(tmp) && - tmp->path) { - if (add_file_path(tmp, depth, buf) < 0) - return -1; - } + if (add_file_path(tmp, depth, buf) < 0) + return -1; depth++; }