summaryrefslogtreecommitdiffstats
path: root/meta-networking
diff options
context:
space:
mode:
authorGyorgy Sarvari <skandigraun@gmail.com>2025-12-28 14:39:28 +0100
committerGyorgy Sarvari <skandigraun@gmail.com>2026-01-08 22:03:02 +0100
commit2ab2b6060992367a4a2b603a6068078f9d32e443 (patch)
tree53dcc9f58c6b598d21da71e37c775c00afa9965d /meta-networking
parent4a97186719ef0367b5841d7b92e4672b83d91db8 (diff)
downloadmeta-openembedded-2ab2b6060992367a4a2b603a6068078f9d32e443.tar.gz
nbdkit: patch CVE-2025-47712
Details: https://nvd.nist.gov/vuln/detail/CVE-2025-47712 Pick the patch from the project's repository which explicitly mentions this vulnerability ID. Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Diffstat (limited to 'meta-networking')
-rw-r--r--meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47712.patch162
-rw-r--r--meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb1
2 files changed, 163 insertions, 0 deletions
diff --git a/meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47712.patch b/meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47712.patch
new file mode 100644
index 0000000000..84b0ad89f2
--- /dev/null
+++ b/meta-networking/recipes-support/nbdkit/nbdkit/CVE-2025-47712.patch
@@ -0,0 +1,162 @@
1From 4290f04d6fd9321fffcf09c0507a4f394e19f087 Mon Sep 17 00:00:00 2001
2From: Eric Blake <eblake@redhat.com>
3Date: Tue, 22 Apr 2025 19:53:39 -0500
4Subject: [PATCH] blocksize: Fix 32-bit overflow in .extents [CVE-2025-47712]
5
6If the original request is larger than 2**32 - minblock, then we were
7calling nbdkit_extents_aligned() with a count that rounded up then
8overflowed to 0 instead of the intended 4G because of overflowing a
932-bit type, which in turn causes an assertion failure:
10
11nbdkit: ../../server/backend.c:814: backend_extents: Assertion `backend_valid_range (c, offset, count)' failed.
12
13The fix is to force the rounding to be in a 64-bit type from the
14get-go.
15
16The ability for a well-behaved client to cause the server to die from
17an assertion failure can be used as a denial of service attack against
18other clients. Mitigations: if you requrire the use of TLS, then you
19can ensure that you only have trusted clients that won't trigger a
20block status call that large. Also, the problem only occurs when
21using the blocksize filter, although setting the filter's maxlen
22parameter to a smaller value than its default of 2**32-1 does not
23help.
24
25Fixes: 2680be00 ('blocksize: Fix .extents when plugin changes type within minblock', v1.21.16)
26Signed-off-by: Eric Blake <eblake@redhat.com>
27Message-ID: <20250423210917.1784789-3-eblake@redhat.com>
28Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
29
30CVE: CVE-2025-47712
31Upstream-Status: Backport [https://gitlab.com/nbdkit/nbdkit/-/commit/a486f88d1eea653ea88b0bf8804c4825dab25ec7]
32Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
33---
34 filters/blocksize/blocksize.c | 5 +-
35 tests/Makefile.am | 2 +
36 tests/test-blocksize-extents-overflow.sh | 83 ++++++++++++++++++++++++
37 3 files changed, 88 insertions(+), 2 deletions(-)
38 create mode 100755 tests/test-blocksize-extents-overflow.sh
39
40diff --git a/filters/blocksize/blocksize.c b/filters/blocksize/blocksize.c
41index 03da4971..b06f78b3 100644
42--- a/filters/blocksize/blocksize.c
43+++ b/filters/blocksize/blocksize.c
44@@ -474,8 +474,9 @@ blocksize_extents (nbdkit_next *next,
45 return -1;
46 }
47
48- if (nbdkit_extents_aligned (next, MIN (ROUND_UP (count, h->minblock),
49- h->maxlen),
50+ if (nbdkit_extents_aligned (next,
51+ MIN (ROUND_UP ((uint64_t) count, h->minblock),
52+ h->maxlen),
53 ROUND_DOWN (offset, h->minblock), flags,
54 h->minblock, extents2, err) == -1)
55 return -1;
56diff --git a/tests/Makefile.am b/tests/Makefile.am
57index 8ddf73d1..a38a37bc 100644
58--- a/tests/Makefile.am
59+++ b/tests/Makefile.am
60@@ -1415,11 +1415,13 @@ test_layers_filter3_la_LIBADD = $(IMPORT_LIBRARY_ON_WINDOWS)
61 TESTS += \
62 test-blocksize.sh \
63 test-blocksize-extents.sh \
64+ test-blocksize-extents-overflow.sh \
65 test-blocksize-default.sh \
66 $(NULL)
67 EXTRA_DIST += \
68 test-blocksize.sh \
69 test-blocksize-extents.sh \
70+ test-blocksize-extents-overflow.sh \
71 test-blocksize-default.sh \
72 $(NULL)
73
74diff --git a/tests/test-blocksize-extents-overflow.sh b/tests/test-blocksize-extents-overflow.sh
75new file mode 100755
76index 00000000..844c3999
77--- /dev/null
78+++ b/tests/test-blocksize-extents-overflow.sh
79@@ -0,0 +1,83 @@
80+#!/usr/bin/env bash
81+# nbdkit
82+# Copyright Red Hat
83+#
84+# Redistribution and use in source and binary forms, with or without
85+# modification, are permitted provided that the following conditions are
86+# met:
87+#
88+# * Redistributions of source code must retain the above copyright
89+# notice, this list of conditions and the following disclaimer.
90+#
91+# * Redistributions in binary form must reproduce the above copyright
92+# notice, this list of conditions and the following disclaimer in the
93+# documentation and/or other materials provided with the distribution.
94+#
95+# * Neither the name of Red Hat nor the names of its contributors may be
96+# used to endorse or promote products derived from this software without
97+# specific prior written permission.
98+#
99+# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
100+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
101+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
102+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
103+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
104+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
105+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
106+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
107+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
108+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
109+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
110+# SUCH DAMAGE.
111+
112+# Demonstrate a fix for a bug where blocksize overflowed 32 bits
113+
114+source ./functions.sh
115+set -e
116+set -x
117+
118+requires_run
119+requires_plugin eval
120+requires_nbdsh_uri
121+requires nbdsh --base-allocation --version
122+
123+# Script a sparse server that requires 512-byte aligned requests.
124+exts='
125+if test $(( ($3|$4) & 511 )) != 0; then
126+ echo "EINVAL request unaligned" 2>&1
127+ exit 1
128+fi
129+echo 0 5G 0
130+'
131+
132+# We also need an nbdsh script to parse all extents, coalescing adjacent
133+# types for simplicity.
134+# FIXME: Once nbdkit plugin version 3 allows 64-bit block extents, run
135+# this test twice, once for each bit size (32-bit needs 2 extents, 64-bit
136+# will get the same result with only 1 extent).
137+export script='
138+size = h.get_size()
139+offs = 0
140+entries = []
141+def f(metacontext, offset, e, err):
142+ global entries
143+ global offs
144+ assert offs == offset
145+ for length, flags in zip(*[iter(e)] * 2):
146+ if entries and flags == entries[-1][1]:
147+ entries[-1] = (entries[-1][0] + length, flags)
148+ else:
149+ entries.append((length, flags))
150+ offs = offs + length
151+
152+# Test a loop over the entire device
153+while offs < size:
154+ len = min(size - offs, 2**32-1)
155+ h.block_status(len, offs, f)
156+assert entries == [(5 * 2**30, 0)]
157+'
158+
159+# Now run everything
160+nbdkit --filter=blocksize eval minblock=512 \
161+ get_size='echo 5G' pread='exit 1' extents="$exts" \
162+ --run 'nbdsh --base-allocation -u "$uri" -c "$script"'
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 d5b51f0e8d..7996c43752 100644
--- a/meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb
+++ b/meta-networking/recipes-support/nbdkit/nbdkit_1.30.2.bb
@@ -11,6 +11,7 @@ LIC_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 file://CVE-2025-47711.patch \ 13 file://CVE-2025-47711.patch \
14 file://CVE-2025-47712.patch \
14 " 15 "
15 16
16SRCREV = "b59380e061fdf0f114c13c226ea2a508f2c067d0" 17SRCREV = "b59380e061fdf0f114c13c226ea2a508f2c067d0"