summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGyorgy Sarvari <skandigraun@gmail.com>2025-12-28 14:39:27 +0100
committerGyorgy Sarvari <skandigraun@gmail.com>2026-01-08 22:03:02 +0100
commit4a97186719ef0367b5841d7b92e4672b83d91db8 (patch)
tree9a355e0e4dc1ac99524f2af6cb6e36913c2d04d1
parentd618b8dc840899bd3275bc1e26952d226206278d (diff)
downloadmeta-openembedded-4a97186719ef0367b5841d7b92e4672b83d91db8.tar.gz
nbdkit: patch CVE-2025-47711
Details: https://nvd.nist.gov/vuln/detail/CVE-2025-47711 Pick the patch from the repository which explicitly mentions this CVE ID. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
-rw-r--r--meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47711.patch168
-rw-r--r--meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb3
2 files changed, 170 insertions, 1 deletions
diff --git a/meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47711.patch b/meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47711.patch
new file mode 100644
index 0000000000..edc1b7243c
--- /dev/null
+++ b/meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47711.patch
@@ -0,0 +1,168 @@
1From 53b7e408f2a5fc449183ff4c82e1cad8387ca331 Mon Sep 17 00:00:00 2001
2From: Eric Blake <eblake@redhat.com>
3Date: Tue, 22 Apr 2025 17:01:12 -0500
4Subject: [PATCH] server: Fix off-by-one for maximum block_status length
5 [CVE-2025-47711]
6
7There has been an off-by-one bug in the code for .extents since the
8introduction of that callback. Remember, internally the code allows
9plugins to report on extents with 64-bit lengths, but the protocol
10only supports 32-bit block status calls (nbdkit will need to create
11plugin version 3 before it can support NBD's newer 64-bit block
12status). As such, the server loop intentionally truncates a plugin's
13large extent to 2**32-1 bytes. But in the process of checking whether
14the loop should exit early, or if any additional extents should be
15reported to the client, the server used 'pos > offset+count' instead
16of >=, which is one byte too far. If the client has requested exactly
172**32-1 bytes, and the plugin's first extent has that same length, the
18code erroneously proceeds on to the plugin's second extent. Worse, if
19the plugin's first extent has 2**32 bytes or more, it was truncated to
202**31-1 bytes, but not completely handled, and the failure to exit the
21loop early means that the server then fails the assertion:
22
23nbdkit: ../../server/protocol.c:505: extents_to_block_descriptors:
24Assertion `e.length <= length' failed.
25
26The single-byte fix addresses both symptoms, while the added test
27demonstrates both when run on older nbdkit (the protocol violation
28when the plugin returns 2**32-1 bytes in the first extent, and the
29assertion failure when the plugin returns 2**32 or more bytes in the
30first extent).
31
32The problem can only be triggered by a client request for 2**32-1
33bytes; anything smaller is immune. The problem also does not occur
34for plugins that do not return extents information beyond the client's
35request, or if the first extent is smaller than the client's request.
36
37The ability to cause the server to die from an assertion failure can
38be used as a denial of service attack against other clients.
39Mitigations: if you require the use of TLS, then you can ensure that
40you only have trusted clients that won't trigger a block status call
41of length 2**32-1 bytes. Also, you can use "--filter=blocksize-policy
42blocksize-minimum=512" to reject block status attempts from clients
43that are not sector-aligned.
44
45Fixes: 26455d45 ('server: protocol: Implement Block Status "base:allocation".', v1.11.10)
46Reported-by: Nikolay Ivanets <stenavin@gmail.com>
47Signed-off-by: Eric Blake <eblake@redhat.com>
48Message-ID: <20250423211953.GR1450@redhat.com>
49Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
50
51CVE: CVE-2025-47711
52Upstream-Status: Backport [https://gitlab.com/nbdkit/nbdkit/-/commit/e6f96bd1b77c0cc927ce6aeff650b52238304f39]
53Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
54---
55 server/protocol.c | 2 +-
56 tests/Makefile.am | 2 ++
57 tests/test-eval-extents.sh | 71 ++++++++++++++++++++++++++++++++++++++
58 3 files changed, 74 insertions(+), 1 deletion(-)
59 create mode 100755 tests/test-eval-extents.sh
60
61diff --git a/server/protocol.c b/server/protocol.c
62index 2ac77055..015235ce 100644
63--- a/server/protocol.c
64+++ b/server/protocol.c
65@@ -495,7 +495,7 @@ extents_to_block_descriptors (struct nbdkit_extents *extents,
66 (*nr_blocks)++;
67
68 pos += length;
69- if (pos > offset + count) /* this must be the last block */
70+ if (pos >= offset + count) /* this must be the last block */
71 break;
72
73 /* If we reach here then we must have consumed this whole
74diff --git a/tests/Makefile.am b/tests/Makefile.am
75index 9b995e53..8ddf73d1 100644
76--- a/tests/Makefile.am
77+++ b/tests/Makefile.am
78@@ -705,11 +705,13 @@ TESTS += \
79 test-eval.sh \
80 test-eval-file.sh \
81 test-eval-exports.sh \
82+ test-eval-extents.sh \
83 $(NULL)
84 EXTRA_DIST += \
85 test-eval.sh \
86 test-eval-file.sh \
87 test-eval-exports.sh \
88+ test-eval-extents.sh \
89 $(NULL)
90
91 # file plugin test.
92diff --git a/tests/test-eval-extents.sh b/tests/test-eval-extents.sh
93new file mode 100755
94index 00000000..92b503e6
95--- /dev/null
96+++ b/tests/test-eval-extents.sh
97@@ -0,0 +1,71 @@
98+#!/usr/bin/env bash
99+# nbdkit
100+# Copyright Red Hat
101+#
102+# Redistribution and use in source and binary forms, with or without
103+# modification, are permitted provided that the following conditions are
104+# met:
105+#
106+# * Redistributions of source code must retain the above copyright
107+# notice, this list of conditions and the following disclaimer.
108+#
109+# * Redistributions in binary form must reproduce the above copyright
110+# notice, this list of conditions and the following disclaimer in the
111+# documentation and/or other materials provided with the distribution.
112+#
113+# * Neither the name of Red Hat nor the names of its contributors may be
114+# used to endorse or promote products derived from this software without
115+# specific prior written permission.
116+#
117+# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
118+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
119+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
120+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
121+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
122+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
123+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
124+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
125+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
126+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
127+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
128+# SUCH DAMAGE.
129+
130+source ./functions.sh
131+set -e
132+set -x
133+
134+requires_run
135+requires_plugin eval
136+requires_nbdsh_uri
137+requires nbdsh --base-allocation --version
138+
139+files="eval-extents.out"
140+rm -f $files
141+cleanup_fn rm -f $files
142+
143+# Trigger an off-by-one bug introduced in v1.11.10 and fixed in v1.43.7
144+export script='
145+def f(context, offset, extents, status):
146+ print(extents)
147+
148+# First, probe where the server should return 2 extents.
149+h.block_status(2**32-1, 2, f)
150+
151+# Next, probe where the server has exactly 2**32-1 bytes in its first extent.
152+h.block_status(2**32-1, 1, f)
153+
154+# Now, probe where the first extent has to be truncated.
155+h.block_status(2**32-1, 0, f)
156+'
157+nbdkit eval \
158+ get_size='echo 5G' \
159+ pread='dd if=/dev/zero count=$3 iflag=count_bytes' \
160+ extents='echo 0 4G 1; echo 4G 1G 2' \
161+ --run 'nbdsh --base-allocation --uri "$uri" -c "$script"' \
162+ > eval-extents.out
163+cat eval-extents.out
164+diff -u - eval-extents.out <<EOF
165+[4294967294, 1, 1073741824, 2]
166+[4294967295, 1]
167+[4294967295, 1]
168+EOF
diff --git a/meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb b/meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb
index da24b1efd6..d5b51f0e8d 100644
--- a/meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb
+++ b/meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb
@@ -10,7 +10,8 @@ LICENSE = "BSD-3-Clause"
10LIC_FILES_CHKSUM = "file://LICENSE;md5=f9dcc2d8acdde215fa4bd6ac12bb14f0" 10LIC_FILES_CHKSUM = "file://LICENSE;md5=f9dcc2d8acdde215fa4bd6ac12bb14f0"
11 11
12SRC_URI = "git://github.com/libguestfs/nbdkit.git;protocol=https;branch=master \ 12SRC_URI = "git://github.com/libguestfs/nbdkit.git;protocol=https;branch=master \
13" 13 file://CVE-2025-47711.patch \
14 "
14 15
15SRCREV = "b59380e061fdf0f114c13c226ea2a508f2c067d0" 16SRCREV = "b59380e061fdf0f114c13c226ea2a508f2c067d0"
16 17