vddk: Fix use of uninitialized memory when computing block size
resolves: rhbz#2066655
This commit is contained in:
parent
02f2730051
commit
4a8d800b4f
@ -0,0 +1,71 @@
|
||||
From 3578c005c8a2f479eb223bb89f7b0fba22d13766 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Tue, 22 Mar 2022 11:04:56 +0000
|
||||
Subject: [PATCH] vddk: Don't use uninitialized values when computing preferred
|
||||
block size
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Commit 63d2dd2eb2 ("vddk: Export block size information for this
|
||||
plugin") tried to calculate the preferred block size from the logical
|
||||
and physical sector size reported by VDDK. Unfortunately VDDK < 7’s
|
||||
VixDiskLib_GetInfo API returns a struct which does not contain
|
||||
these fields at all. We knew about this already because the
|
||||
debug code does not print them, but the block size code uses
|
||||
them regardless of the VDDK version.
|
||||
|
||||
The practical result of this error was that sometimes (depending on
|
||||
existing contents of memory) you would see the error:
|
||||
|
||||
nbdkit: vddk[1]: error: plugin must set preferred block size to a power of 2
|
||||
|
||||
Fix this by only using the fields when VDDK >= 7, and in earlier
|
||||
versions assuming VDDK’s normal sector size.
|
||||
|
||||
Reported-by: Xiaodai Wang
|
||||
Fixes: commit 63d2dd2eb2c9980a07841fe84ec16844085a59c3
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2066655
|
||||
(cherry picked from commit 31bc5322b179545bef827022e1ae3b7859387b1b)
|
||||
---
|
||||
plugins/vddk/vddk.c | 17 +++++++++++++++--
|
||||
1 file changed, 15 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c
|
||||
index 5d31b073..51ef8f33 100644
|
||||
--- a/plugins/vddk/vddk.c
|
||||
+++ b/plugins/vddk/vddk.c
|
||||
@@ -855,6 +855,7 @@ vddk_block_size (void *handle,
|
||||
{
|
||||
struct vddk_handle *h = handle;
|
||||
VixDiskLibInfo *info;
|
||||
+ uint32_t logicalSectorSize, physicalSectorSize;
|
||||
struct command info_cmd = { .type = INFO, .ptr = &info };
|
||||
|
||||
if (send_command_and_wait (h, &info_cmd) == -1)
|
||||
@@ -862,8 +863,20 @@ vddk_block_size (void *handle,
|
||||
|
||||
/* VDDK can only serve whole 512 byte sectors. */
|
||||
*minimum = VIXDISKLIB_SECTOR_SIZE;
|
||||
- *preferred = MAX (MAX (info->logicalSectorSize, info->physicalSectorSize),
|
||||
- 4096);
|
||||
+
|
||||
+ /* The logicalSectorSize and physicalSectorSize fields are only
|
||||
+ * present in VDDK >= 7. In earlier versions they will not be
|
||||
+ * initialized and contain random values (beyond the end of the
|
||||
+ * returned structure). So compute sector sizes with this in mind.
|
||||
+ */
|
||||
+ logicalSectorSize = physicalSectorSize = VIXDISKLIB_SECTOR_SIZE;
|
||||
+ if (library_version >= 7) {
|
||||
+ logicalSectorSize = info->logicalSectorSize;
|
||||
+ physicalSectorSize = info->physicalSectorSize;
|
||||
+ }
|
||||
+
|
||||
+ *preferred = MAX (MAX (logicalSectorSize, physicalSectorSize), 4096);
|
||||
+
|
||||
*maximum = 0xffffffff;
|
||||
|
||||
VDDK_CALL_START (VixDiskLib_FreeInfo, "info")
|
||||
--
|
||||
2.31.1
|
||||
|
@ -53,7 +53,7 @@ ExclusiveArch: x86_64
|
||||
|
||||
Name: nbdkit
|
||||
Version: 1.30.1
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: NBD server
|
||||
|
||||
License: BSD
|
||||
@ -78,6 +78,7 @@ Source3: copy-patches.sh
|
||||
# https://gitlab.com/nbdkit/nbdkit/-/commits/rhel-9.1/
|
||||
|
||||
# Patches.
|
||||
Patch0001: 0001-vddk-Don-t-use-uninitialized-values-when-computing-p.patch
|
||||
|
||||
# For automatic RPM Provides generation.
|
||||
# See: https://rpm-software-management.github.io/rpm/manual/dependency_generators.html
|
||||
@ -1177,13 +1178,15 @@ export LIBGUESTFS_TRACE=1
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Mar 15 2022 Richard W.M. Jones <rjones@redhat.com> - 1.30.1-1
|
||||
* Tue Mar 22 2022 Richard W.M. Jones <rjones@redhat.com> - 1.30.1-2
|
||||
- Rebase to new stable branch version 1.30.1
|
||||
resolves: rhbz#2059289
|
||||
- Add automatic provides generator and subpackage nbdkit-srpm-macros
|
||||
resolves: rhbz#2059291
|
||||
- New filters: blocksize-policy, protect, retry-request
|
||||
- Fix license of bash-completion subpackage
|
||||
- vddk: Fix use of uninitialized memory when computing block size
|
||||
resolves: rhbz#2066655
|
||||
|
||||
* Mon Jan 24 2022 Richard W.M. Jones <rjones@redhat.com> - 1.28.5-1
|
||||
- Rebase to new stable branch version 1.28.5
|
||||
|
Loading…
Reference in New Issue
Block a user