From patchwork Wed Mar 9 17:38:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 63721 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2779598lbc; Wed, 9 Mar 2016 09:41:52 -0800 (PST) X-Received: by 10.194.60.100 with SMTP id g4mr36095877wjr.30.1457545312605; Wed, 09 Mar 2016 09:41:52 -0800 (PST) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id ws8si11299153wjc.16.2016.03.09.09.41.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 Mar 2016 09:41:52 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u29Hd7Hi025450; Wed, 9 Mar 2016 12:39:07 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u29Hd6ta024026 for ; Wed, 9 Mar 2016 12:39:06 -0500 Received: from colepc.redhat.com (ovpn-113-126.phx2.redhat.com [10.3.113.126]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u29Hd28l003895; Wed, 9 Mar 2016 12:39:06 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 9 Mar 2016 12:38:58 -0500 Message-Id: <4a3ceade1d4d5921e8e05452b7eadefba1a3a6c2.1457544659.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina Subject: [libvirt] [PATCH 1/3] storage: refresh volume before deletion 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 file volume deletion, via virFileRemove, has some logic that depends on uid/gid owner of the path. This info is cached in the volume XML. We need to be sure we are using up to date uid/gid before attempting to delete the volume, otherwise we can hit a case like this: - test.img created with uid=root - VM starts up using test.img, owner changed to uid=qemu - test.img pool is refreshed, uid=qemu is cached in the volume XML - VM shuts down, volume owner changed to gid=root - vol-delete test.img thinks uid=qemu, virFileRemove does setuid(qemu), fails to delete test.img since it is actually uid=root https://bugzilla.redhat.com/show_bug.cgi?id=1289327 --- src/storage/storage_driver.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 1d96618..ded54c9 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1801,6 +1801,16 @@ storageVolDelete(virStorageVolPtr obj, goto cleanup; } + /* Need to ensure we are using up to date uid/gid for deletion */ + if (backend->refreshVol && + backend->refreshVol(obj->conn, pool, vol) < 0) { + /* The file may have been removed behind libvirt's back. Don't + error here, let the deletion fail or succeed instead */ + VIR_INFO("Failed to refresh volume before deletion: %s", + virGetLastErrorMessage()); + virResetLastError(); + } + if (storageVolDeleteInternal(obj, backend, pool, vol, flags, true) < 0) goto cleanup;