server: Fix .zero fallback path

resolves: RHEL-101635
This commit is contained in:
Richard W.M. Jones 2025-07-05 08:47:50 +01:00
parent 58b3d4e63e
commit 4450b8fbd9
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,39 @@
From e947a2a55cb018711b7f4ede5b5cec291ed5cf24 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 2 Jul 2025 16:18:19 +0100
Subject: [PATCH] server: Fix .zero fallback path
When no efficient zero method is supported, we fall back to writing a
buffer of actual zeroes. However because of an omitted update to
'offset' we would only zero out (up to) the first 64M of each range.
nbdcopy defaults to working on blocks of 128M, leaving the second 64M
unzeroed.
This affects only backing filesystems which do not support fallocate
FALLOC_FL_PUNCH_HOLE or FALLOC_FL_ZERO_RANGE, which turns out to be
rare, but it does include some NFS-mounted filesystems which is where
I saw this problem.
Fixes: commit 19184d3eb6356ae3b14da0fbaa9c9bdc7743a448
Thanks: Alex Kalenyuk
(cherry picked from commit 20b23fc9838faeddfd42664a7f497a9b29dc5921)
(cherry picked from commit 3c8d0812e7a7b6a1f9e5cceab7bee6e25b9cd7cd)
---
server/plugins.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/plugins.c b/server/plugins.c
index 3c7df0d2..db36ce42 100644
--- a/server/plugins.c
+++ b/server/plugins.c
@@ -807,6 +807,7 @@ plugin_zero (struct context *c,
if (r == -1)
break;
count -= limit;
+ offset += limit;
}
done:
--
2.47.1

View File

@ -56,7 +56,7 @@
Name: nbdkit
Version: 1.38.5
Release: 11%{?dist}
Release: 12%{?dist}
Summary: NBD server
License: BSD-3-Clause
@ -124,6 +124,7 @@ Patch0040: 0040-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch
Patch0041: 0041-server-Fix-off-by-one-for-maximum-block_status-lengt.patch
Patch0042: 0042-blocksize-Fix-32-bit-overflow-in-.extents-CVE-2025-4.patch
Patch0043: 0043-vddk-Add-support-for-VDDK-9.0.0.0.patch
Patch0044: 0044-server-Fix-.zero-fallback-path.patch
# For automatic RPM Provides generation.
# See: https://rpm-software-management.github.io/rpm/manual/dependency_generators.html
@ -1542,6 +1543,10 @@ fi
%changelog
* Sat Jul 05 2025 Richard W.M. Jones <rjones@redhat.com> - 1.38.5-12
- server: Fix .zero fallback path
resolves: RHEL-101635
* Mon Jun 23 2025 Richard W.M. Jones <rjones@redhat.com> - 1.38.5-11
- Add support for VDDK 9.0.0.0
resolves: RHEL-99466