SHA256
1
0
forked from pool/libvirt
libvirt/e0025d29-storage-mode-check.patch
Cédric Bosdonnat ee07210d25 Accepting request 330855 from home:cbosdonnat:branches:Virtualization
- CVE-2015-5247 - denial of service through root-squash NFS storage
  3468542f-virFileUnlink.patch
  8b1d84e6-refreshVol-failure.patch
  e0025d29-storage-mode-check.patch

OBS-URL: https://build.opensuse.org/request/show/330855
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=484
2015-09-14 08:45:45 +00:00

50 lines
2.0 KiB
Diff

From e0025d2967bbe3f283937216c9e2c12b6e9d1010 Mon Sep 17 00:00:00 2001
From: John Ferlan <jferlan@redhat.com>
Date: Mon, 24 Aug 2015 12:48:40 -0400
Subject: [PATCH] storage: Correct the 'mode' check
Commit id '7c2d65dde2' changed the default value of mode to be -1 if not
supplied in the XML, which should cause creation of the volume using the
default mode of VIR_STORAGE_DEFAULT_VOL_PERM_MODE; however, the check
made was whether mode was '0' or not to use default or provided value.
This patch fixes the issue to check if the 'mode' was provided in the XML
and use that value.
(cherry picked from commit 691dd388aee99f8b06177540303b690586d5f5b3)
---
src/storage/storage_backend.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 0418473..6a3146c 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -486,6 +486,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
int fd = -1;
int operation_flags;
bool reflink_copy = false;
+ mode_t open_mode = VIR_STORAGE_DEFAULT_VOL_PERM_MODE;
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
VIR_STORAGE_VOL_CREATE_REFLINK,
@@ -518,11 +519,12 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
if (pool->def->type == VIR_STORAGE_POOL_NETFS)
operation_flags |= VIR_FILE_OPEN_FORK;
+ if (vol->target.perms->mode != (mode_t) -1)
+ open_mode = vol->target.perms->mode;
+
if ((fd = virFileOpenAs(vol->target.path,
O_RDWR | O_CREAT | O_EXCL,
- (vol->target.perms->mode ?
- VIR_STORAGE_DEFAULT_VOL_PERM_MODE :
- vol->target.perms->mode),
+ open_mode,
vol->target.perms->uid,
vol->target.perms->gid,
operation_flags)) < 0) {
--
2.1.4