summaryrefslogtreecommitdiffstats
path: root/meta-oe
diff options
context:
space:
mode:
authorHitendra Prajapati <hprajapati@mvista.com>2025-10-28 13:23:36 +0530
committerAnuj Mittal <anuj.mittal@intel.com>2025-10-30 15:11:00 +0800
commitd18271891f5f8a226585df9d7a71ad03952a469f (patch)
treee5163c0e7488fcd2976b0a23726e440fa83b8626 /meta-oe
parent5657774a702e14c8681634c182b90c8403ad0843 (diff)
downloadmeta-openembedded-d18271891f5f8a226585df9d7a71ad03952a469f.tar.gz
libjxl: fix CVE-2024-11403 & CVE-2024-11498
* CVE-2024-11403 - Upstream-Status: Backport from https://github.com/libjxl/libjxl/commit/9cc451b91b74ba470fd72bd48c121e9f33d24c99 * CVE-2024-11498 - Upstream-Status: Backport from https://github.com/libjxl/libjxl/commit/bf4781a2eed2eef664790170977d1d3d8347efb9 Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'meta-oe')
-rw-r--r--meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11403.patch70
-rw-r--r--meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11498.patch113
-rw-r--r--meta-oe/recipes-multimedia/libjxl/libjxl_0.10.2.bb6
3 files changed, 187 insertions, 2 deletions
diff --git a/meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11403.patch b/meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11403.patch
new file mode 100644
index 0000000000..625218c2d3
--- /dev/null
+++ b/meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11403.patch
@@ -0,0 +1,70 @@
1From 9cc451b91b74ba470fd72bd48c121e9f33d24c99 Mon Sep 17 00:00:00 2001
2From: szabadka <9074039+szabadka@users.noreply.github.com>
3Date: Thu, 3 Oct 2024 18:07:38 +0200
4Subject: [PATCH] Port the Huffman lookup table size fix from brunsli. (#3871)
5
6CVE: CVE-2024-11403
7Upstream-Status: Backport [https://github.com/libjxl/libjxl/commit/9cc451b91b74ba470fd72bd48c121e9f33d24c99]
8Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
9---
10 lib/jpegli/huffman.h | 16 ++++++++++++----
11 lib/jxl/jpeg/enc_jpeg_huffman_decode.h | 16 ++++++++++++----
12 2 files changed, 24 insertions(+), 8 deletions(-)
13
14diff --git a/lib/jpegli/huffman.h b/lib/jpegli/huffman.h
15index f0e5e1de..99549668 100644
16--- a/lib/jpegli/huffman.h
17+++ b/lib/jpegli/huffman.h
18@@ -15,10 +15,18 @@ namespace jpegli {
19
20 constexpr int kJpegHuffmanRootTableBits = 8;
21 // Maximum huffman lookup table size.
22-// According to zlib/examples/enough.c, 758 entries are always enough for
23-// an alphabet of 257 symbols (256 + 1 special symbol for the all 1s code) and
24-// max bit length 16 if the root table has 8 bits.
25-constexpr int kJpegHuffmanLutSize = 758;
26+// Requirements: alphabet of 257 symbols (256 + 1 special symbol for the all 1s
27+// code) and max bit length 16, the root table has 8 bits.
28+// zlib/examples/enough.c works with an assumption that Huffman code is
29+// "complete". Input JPEGs might have this assumption broken, hence the
30+// following sum is used as estimate:
31+// + number of 1-st level cells
32+// + number of symbols
33+// + asymptotic amount of repeated 2nd level cells
34+// The third number is 1 + 3 + ... + 255 i.e. it is assumed that sub-table of
35+// each "size" might be almost completely be filled with repetitions.
36+// Total sum is slightly less than 1024,...
37+constexpr int kJpegHuffmanLutSize = 1024;
38
39 struct HuffmanTableEntry {
40 uint8_t bits; // number of bits used for this symbol
41diff --git a/lib/jxl/jpeg/enc_jpeg_huffman_decode.h b/lib/jxl/jpeg/enc_jpeg_huffman_decode.h
42index b8a60e41..fc9bd17b 100644
43--- a/lib/jxl/jpeg/enc_jpeg_huffman_decode.h
44+++ b/lib/jxl/jpeg/enc_jpeg_huffman_decode.h
45@@ -15,10 +15,18 @@ namespace jpeg {
46
47 constexpr int kJpegHuffmanRootTableBits = 8;
48 // Maximum huffman lookup table size.
49-// According to zlib/examples/enough.c, 758 entries are always enough for
50-// an alphabet of 257 symbols (256 + 1 special symbol for the all 1s code) and
51-// max bit length 16 if the root table has 8 bits.
52-constexpr int kJpegHuffmanLutSize = 758;
53+// Requirements: alphabet of 257 symbols (256 + 1 special symbol for the all 1s
54+// code) and max bit length 16, the root table has 8 bits.
55+// zlib/examples/enough.c works with an assumption that Huffman code is
56+// "complete". Input JPEGs might have this assumption broken, hence the
57+// following sum is used as estimate:
58+// + number of 1-st level cells
59+// + number of symbols
60+// + asymptotic amount of repeated 2nd level cells
61+// The third number is 1 + 3 + ... + 255 i.e. it is assumed that sub-table of
62+// each "size" might be almost completely be filled with repetitions.
63+// Total sum is slightly less than 1024,...
64+constexpr int kJpegHuffmanLutSize = 1024;
65
66 struct HuffmanTableEntry {
67 // Initialize the value to an invalid symbol so that we can recognize it
68--
692.50.1
70
diff --git a/meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11498.patch b/meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11498.patch
new file mode 100644
index 0000000000..25f85e1527
--- /dev/null
+++ b/meta-oe/recipes-multimedia/libjxl/libjxl/CVE-2024-11498.patch
@@ -0,0 +1,113 @@
1From bf4781a2eed2eef664790170977d1d3d8347efb9 Mon Sep 17 00:00:00 2001
2From: Luca Versari <veluca@google.com>
3Date: Thu, 21 Nov 2024 16:33:08 +0100
4Subject: [PATCH] Check height limit in modular trees. (#3943)
5
6Also rewrite the implementation to use iterative checking instead of
7recursive checking of tree property values, to ensure stack usage is
8low.
9
10Before, it was possible for appropriately-crafted files to use a
11significant amount of stack (in the order of hundreds of MB).
12
13CVE: CVE-2024-11498
14Upstream-Status: Backport [https://github.com/libjxl/libjxl/commit/bf4781a2eed2eef664790170977d1d3d8347efb9]
15Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
16---
17 lib/jxl/modular/encoding/dec_ma.cc | 66 ++++++++++++++++++++----------
18 1 file changed, 45 insertions(+), 21 deletions(-)
19
20diff --git a/lib/jxl/modular/encoding/dec_ma.cc b/lib/jxl/modular/encoding/dec_ma.cc
21index b53b9a91..df2948d8 100644
22--- a/lib/jxl/modular/encoding/dec_ma.cc
23+++ b/lib/jxl/modular/encoding/dec_ma.cc
24@@ -6,6 +6,7 @@
25 #include "lib/jxl/modular/encoding/dec_ma.h"
26
27 #include <limits>
28+#include <vector>
29
30 #include "lib/jxl/base/printf_macros.h"
31 #include "lib/jxl/dec_ans.h"
32@@ -17,23 +18,49 @@ namespace jxl {
33
34 namespace {
35
36-Status ValidateTree(
37- const Tree &tree,
38- const std::vector<std::pair<pixel_type, pixel_type>> &prop_bounds,
39- size_t root) {
40- if (tree[root].property == -1) return true;
41- size_t p = tree[root].property;
42- int val = tree[root].splitval;
43- if (prop_bounds[p].first > val) return JXL_FAILURE("Invalid tree");
44- // Splitting at max value makes no sense: left range will be exactly same
45- // as parent, right range will be invalid (min > max).
46- if (prop_bounds[p].second <= val) return JXL_FAILURE("Invalid tree");
47- auto new_bounds = prop_bounds;
48- new_bounds[p].first = val + 1;
49- JXL_RETURN_IF_ERROR(ValidateTree(tree, new_bounds, tree[root].lchild));
50- new_bounds[p] = prop_bounds[p];
51- new_bounds[p].second = val;
52- return ValidateTree(tree, new_bounds, tree[root].rchild);
53+Status ValidateTree(const Tree &tree) {
54+ int num_properties = 0;
55+ for (auto node : tree) {
56+ if (node.property >= num_properties) {
57+ num_properties = node.property + 1;
58+ }
59+ }
60+ std::vector<int> height(tree.size());
61+ std::vector<std::pair<pixel_type, pixel_type>> property_ranges(
62+ num_properties * tree.size());
63+ for (int i = 0; i < num_properties; i++) {
64+ property_ranges[i].first = std::numeric_limits<pixel_type>::min();
65+ property_ranges[i].second = std::numeric_limits<pixel_type>::max();
66+ }
67+ const int kHeightLimit = 2048;
68+ for (size_t i = 0; i < tree.size(); i++) {
69+ if (height[i] > kHeightLimit) {
70+ return JXL_FAILURE("Tree too tall: %d", height[i]);
71+ }
72+ if (tree[i].property == -1) continue;
73+ height[tree[i].lchild] = height[i] + 1;
74+ height[tree[i].rchild] = height[i] + 1;
75+ for (size_t p = 0; p < static_cast<size_t>(num_properties); p++) {
76+ if (p == static_cast<size_t>(tree[i].property)) {
77+ pixel_type l = property_ranges[i * num_properties + p].first;
78+ pixel_type u = property_ranges[i * num_properties + p].second;
79+ pixel_type val = tree[i].splitval;
80+ if (l > val || u <= val) {
81+ return JXL_FAILURE("Invalid tree");
82+ }
83+ property_ranges[tree[i].lchild * num_properties + p] =
84+ std::make_pair(val + 1, u);
85+ property_ranges[tree[i].rchild * num_properties + p] =
86+ std::make_pair(l, val);
87+ } else {
88+ property_ranges[tree[i].lchild * num_properties + p] =
89+ property_ranges[i * num_properties + p];
90+ property_ranges[tree[i].rchild * num_properties + p] =
91+ property_ranges[i * num_properties + p];
92+ }
93+ }
94+ }
95+ return true;
96 }
97
98 Status DecodeTree(BitReader *br, ANSSymbolReader *reader,
99@@ -82,10 +109,7 @@ Status DecodeTree(BitReader *br, ANSSymbolReader *reader,
100 tree->size() + to_decode + 2, Predictor::Zero, 0, 1);
101 to_decode += 2;
102 }
103- std::vector<std::pair<pixel_type, pixel_type>> prop_bounds;
104- prop_bounds.resize(256, {std::numeric_limits<pixel_type>::min(),
105- std::numeric_limits<pixel_type>::max()});
106- return ValidateTree(*tree, prop_bounds, 0);
107+ return ValidateTree(*tree);
108 }
109 } // namespace
110
111--
1122.50.1
113
diff --git a/meta-oe/recipes-multimedia/libjxl/libjxl_0.10.2.bb b/meta-oe/recipes-multimedia/libjxl/libjxl_0.10.2.bb
index eced6c7726..2bf0f126b0 100644
--- a/meta-oe/recipes-multimedia/libjxl/libjxl_0.10.2.bb
+++ b/meta-oe/recipes-multimedia/libjxl/libjxl_0.10.2.bb
@@ -8,8 +8,10 @@ inherit cmake pkgconfig mime
8 8
9DEPENDS = "highway brotli" 9DEPENDS = "highway brotli"
10 10
11SRC_URI = "gitsm://github.com/libjxl/libjxl.git;protocol=https;nobranch=1" 11SRC_URI = "gitsm://github.com/libjxl/libjxl.git;protocol=https;nobranch=1 \
12 12 file://CVE-2024-11403.patch \
13 file://CVE-2024-11498.patch \
14 "
13SRCREV = "e1489592a770b989303b0edc5cc1dc447bbe0515" 15SRCREV = "e1489592a770b989303b0edc5cc1dc447bbe0515"
14S = "${WORKDIR}/git" 16S = "${WORKDIR}/git"
15 17