Skip to contentSkip to conversation

package/xz: add patch trailer

PATCH Applied Thomas Perale via buildroot 1 participant 4 messages Apr 17 – Apr 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/xz: add patch trailer

Commit [1] introduced a set of patches to fix CVE-2025-31115. Since [2] the security patches neeed to reference the vulnerability with the CVE: trailer in the patch header.

This set of patch is no longer present on master branch with xz bump [3] but hasn't been cherry picked to 2025.02.x branch.

[1] 06c6c49fe8 package/xz: add security patches fixing CVE-2025-31115
[2] 1167d0ff3d docs/manual: mention CVE trailer
[3] aaa50b0e61 package/xz: bump to version 5.8.1

---
 package/xz/0001-liblzma-mt-dec-Fix-a-comment.patch               | 1 +
 ...02-liblzma-mt-dec-Simplify-by-removing-the-THR_STOP-sta.patch | 1 +
 ...03-liblzma-mt-dec-Don-t-free-the-input-buffer-too-early.patch | 1 +
 ...04-liblzma-mt-dec-Don-t-modify-thr-in_size-in-the-worke.patch | 1 +
 4 files changed, 4 insertions(+)
package/xz/0001-liblzma-mt-dec-Fix-a-comment.patch +1 -0
index 2424fb0d13..41870a8282 100644
@@ -5,6 +5,7 @@ Subject: [PATCH] liblzma: mt dec: Fix a comment
 
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/831b55b971cf579ee16a854f177c36b20d3c6999
 Signed-off-by: Julien Olivain <[email protected]>
 ---
package/xz/0002-liblzma-mt-dec-Simplify-by-removing-the-THR_STOP-sta.patch +1 -0
index 7845380a8c..14985ebc8f 100644
@@ -12,6 +12,7 @@ called (reinitializing the decoder always calls threads_end()).
 
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/c0c835964dfaeb2513a3c0bdb642105152fe9f34
 Signed-off-by: Julien Olivain <[email protected]>
 ---
package/xz/0003-liblzma-mt-dec-Don-t-free-the-input-buffer-too-early.patch +1 -0
index 9915e6b275..d370d8b613 100644
@@ -26,6 +26,7 @@ Fixes: 4cce3e27f529 ("liblzma: Add threaded .xz decompressor.")
 Reported-by: Harri K. Koskinen <[email protected]>
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/d5a2ffe41bb77b918a8c96084885d4dbe4bf6480
 Signed-off-by: Julien Olivain <[email protected]>
 ---
package/xz/0004-liblzma-mt-dec-Don-t-modify-thr-in_size-in-the-worke.patch +1 -0
index 1a914e08db..b3fd11b29d 100644
@@ -21,6 +21,7 @@ Block before the worker thread is activated.
 Fixes: 4cce3e27f529 ("liblzma: Add threaded .xz decompressor.")
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/8188048854e8d11071b8a50d093c74f4c030acc9
 Signed-off-by: Julien Olivain <[email protected]>
 ---
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 package/xz: patch CVE-2026-34743

- CVE-2026-34743:
XZ Utils provide a general-purpose data-compression library plus command-line tools. Prior to version 5.8.3, if lzma_index_decoder() was used to decode an Index that contained no Records, the resulting lzma_index was left in a state where where a subsequent lzma_index_append() would allocate too little memory, and a buffer overflow would occur. This issue has been patched in version 5.8.3.

For more information, see:
- https://www.cve.org/CVERecord?id=CVE-2026-34743
- https://security-tracker.debian.org/tracker/CVE-2026-34743
- https://github.com/tukaani-project/xz/commit/c8c22869e780ff57c96b46939c3d79ff99395f87

(cherry picked from commit 724635227314010518372c5bad4d37d7c58950c1)
---
 ...buffer-overflow-in-lzma-index-append.patch | 62 +++++++++++++++++++
 package/xz/xz.mk                              |  5 +-
 2 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 package/xz/0005-liblzma-Fix-a-buffer-overflow-in-lzma-index-append.patch
package/xz/0005-liblzma-Fix-a-buffer-overflow-in-lzma-index-append.patch new file +62 -0
new file mode 100644
index 0000000000..034122d4f7
@@ -0,0 +1,62 @@
+From c8c22869e780ff57c96b46939c3d79ff99395f87 Mon Sep 17 00:00:00 2001
+From: Lasse Collin <[email protected]>
+Date: Sun, 29 Mar 2026 19:11:21 +0300
+Subject: [PATCH] liblzma: Fix a buffer overflow in lzma_index_append()
+
+If lzma_index_decoder() was used to decode an Index that contained no
+Records, the resulting lzma_index had an invalid internal "prealloc"
+value. If lzma_index_append() was called on this lzma_index, too
+little memory would be allocated and a buffer overflow would occur.
+
+While this combination of the API functions is meant to work, in the
+real-world apps this call sequence is rare or might not exist at all.
+
+This bug is older than xz 5.0.0, so all stable releases are affected.
+
+Reported-by: GitHub user christos-spearbit
+CVE: CVE-2026-34743
+Upstream: https://github.com/tukaani-project/xz/commit/c8c22869e780ff57c96b46939c3d79ff99395f87
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/liblzma/common/index.c | 21 +++++++++++++++++++++
+ 1 file changed, 21 insertions(+)
+
+diff --git a/src/liblzma/common/index.c b/src/liblzma/common/index.c
+index 6add6a683..c4aadb9b0 100644
+--- a/src/liblzma/common/index.c
++++ b/src/liblzma/common/index.c
+@@ -433,6 +433,26 @@ lzma_index_prealloc(lzma_index *i, lzma_vli records)
+ 	if (records > PREALLOC_MAX)
+ 		records = PREALLOC_MAX;
+ 
++	// If index_decoder.c calls us with records == 0, it's decoding
++	// an Index that has no Records. In that case the decoder won't call
++	// lzma_index_append() at all, and i->prealloc isn't used during
++	// the Index decoding either.
++	//
++	// Normally the first lzma_index_append() call from the Index decoder
++	// would reset i->prealloc to INDEX_GROUP_SIZE. With no Records,
++	// lzma_index_append() isn't called and the resetting of prealloc
++	// won't occur either. Thus, if records == 0, use the default value
++	// INDEX_GROUP_SIZE instead.
++	//
++	// NOTE: lzma_index_append() assumes i->prealloc > 0. liblzma <= 5.8.2
++	// didn't have this check and could set i->prealloc = 0, which would
++	// result in a buffer overflow if the application called
++	// lzma_index_append() after decoding an empty Index. Appending
++	// Records after decoding an Index is a rare thing to do, but
++	// it is supposed to work.
++	if (records == 0)
++		records = INDEX_GROUP_SIZE;
++
+ 	i->prealloc = (size_t)(records);
+ 	return;
+ }
+@@ -685,6 +705,7 @@ lzma_index_append(lzma_index *i, const lzma_allocator *allocator,
+ 		++g->last;
+ 	} else {
+ 		// We need to allocate a new group.
++		assert(i->prealloc > 0);
+ 		g = lzma_alloc(sizeof(index_group)
+ 				+ i->prealloc * sizeof(index_record),
+ 				allocator);
package/xz/xz.mk +4 -1
index 60c2df70ee..205ab928a7 100644
@@ -22,7 +22,10 @@ HOST_XZ_ADD_CCACHE_DEPENDENCY = NO
 # 0002-liblzma-mt-dec-Simplify-by-removing-the-THR_STOP-sta.patch
 # 0003-liblzma-mt-dec-Don-t-free-the-input-buffer-too-early.patch
 # 0004-liblzma-mt-dec-Don-t-modify-thr-in_size-in-the-worke.patch
-XZ_IGNORE_CVES = CVE-2025-31115
+XZ_IGNORE_CVES += CVE-2025-31115
+
+# 0005-liblzma-Fix-a-buffer-overflow-in-lzma-index-append.patch
+XZ_IGNORE_CVES += CVE-2026-34743
 
 XZ_CONF_OPTS = \
 	--enable-encoders=lzma1,lzma2,delta,x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv \
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 2/2 2025.02.x] package/xz: patch CVE-2026-34743

In reply of:

Quoted 8 lines

- CVE-2026-34743:
XZ Utils provide a general-purpose data-compression library plus command-line tools. Prior to version 5.8.3, if lzma_index_decoder() was used to decode an Index that contained no Records, the resulting lzma_index was left in a state where where a subsequent lzma_index_append() would allocate too little memory, and a buffer overflow would occur. This issue has been patched in version 5.8.3.

Quoted 7 lines

For more information, see:
- https://www.cve.org/CVERecord?id=CVE-2026-34743
- https://security-tracker.debian.org/tracker/CVE-2026-34743
- https://github.com/tukaani-project/xz/commit/c8c22869e780ff57c96b46939c3d79ff99395f87

(cherry picked from commit 724635227314010518372c5bad4d37d7c58950c1)

Applied to 2025.02.x. Thanks

Quoted 97 lines
---
 ...buffer-overflow-in-lzma-index-append.patch | 62 +++++++++++++++++++
 package/xz/xz.mk                              |  5 +-
 2 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 package/xz/0005-liblzma-Fix-a-buffer-overflow-in-lzma-index-append.patch
package/xz/0005-liblzma-Fix-a-buffer-overflow-in-lzma-index-append.patch new file +62 -0
new file mode 100644
index 0000000000..034122d4f7
@@ -0,0 +1,62 @@
+From c8c22869e780ff57c96b46939c3d79ff99395f87 Mon Sep 17 00:00:00 2001
+From: Lasse Collin <[email protected]>
+Date: Sun, 29 Mar 2026 19:11:21 +0300
+Subject: [PATCH] liblzma: Fix a buffer overflow in lzma_index_append()
+
+If lzma_index_decoder() was used to decode an Index that contained no
+Records, the resulting lzma_index had an invalid internal "prealloc"
+value. If lzma_index_append() was called on this lzma_index, too
+little memory would be allocated and a buffer overflow would occur.
+
+While this combination of the API functions is meant to work, in the
+real-world apps this call sequence is rare or might not exist at all.
+
+This bug is older than xz 5.0.0, so all stable releases are affected.
+
+Reported-by: GitHub user christos-spearbit
+CVE: CVE-2026-34743
+Upstream: https://github.com/tukaani-project/xz/commit/c8c22869e780ff57c96b46939c3d79ff99395f87
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/liblzma/common/index.c | 21 +++++++++++++++++++++
+ 1 file changed, 21 insertions(+)
+
+diff --git a/src/liblzma/common/index.c b/src/liblzma/common/index.c
+index 6add6a683..c4aadb9b0 100644
+--- a/src/liblzma/common/index.c
++++ b/src/liblzma/common/index.c
+@@ -433,6 +433,26 @@ lzma_index_prealloc(lzma_index *i, lzma_vli records)
+ 	if (records > PREALLOC_MAX)
+ 		records = PREALLOC_MAX;
+ 
++	// If index_decoder.c calls us with records == 0, it's decoding
++	// an Index that has no Records. In that case the decoder won't call
++	// lzma_index_append() at all, and i->prealloc isn't used during
++	// the Index decoding either.
++	//
++	// Normally the first lzma_index_append() call from the Index decoder
++	// would reset i->prealloc to INDEX_GROUP_SIZE. With no Records,
++	// lzma_index_append() isn't called and the resetting of prealloc
++	// won't occur either. Thus, if records == 0, use the default value
++	// INDEX_GROUP_SIZE instead.
++	//
++	// NOTE: lzma_index_append() assumes i->prealloc > 0. liblzma <= 5.8.2
++	// didn't have this check and could set i->prealloc = 0, which would
++	// result in a buffer overflow if the application called
++	// lzma_index_append() after decoding an empty Index. Appending
++	// Records after decoding an Index is a rare thing to do, but
++	// it is supposed to work.
++	if (records == 0)
++		records = INDEX_GROUP_SIZE;
++
+ 	i->prealloc = (size_t)(records);
+ 	return;
+ }
+@@ -685,6 +705,7 @@ lzma_index_append(lzma_index *i, const lzma_allocator *allocator,
+ 		++g->last;
+ 	} else {
+ 		// We need to allocate a new group.
++		assert(i->prealloc > 0);
+ 		g = lzma_alloc(sizeof(index_group)
+ 				+ i->prealloc * sizeof(index_record),
+ 				allocator);
package/xz/xz.mk +4 -1
index 60c2df70ee..205ab928a7 100644
@@ -22,7 +22,10 @@ HOST_XZ_ADD_CCACHE_DEPENDENCY = NO
 # 0002-liblzma-mt-dec-Simplify-by-removing-the-THR_STOP-sta.patch
 # 0003-liblzma-mt-dec-Don-t-free-the-input-buffer-too-early.patch
 # 0004-liblzma-mt-dec-Don-t-modify-thr-in_size-in-the-worke.patch
-XZ_IGNORE_CVES = CVE-2025-31115
+XZ_IGNORE_CVES += CVE-2025-31115
+
+# 0005-liblzma-Fix-a-buffer-overflow-in-lzma-index-append.patch
+XZ_IGNORE_CVES += CVE-2026-34743
 
 XZ_CONF_OPTS = \
 	--enable-encoders=lzma1,lzma2,delta,x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv \
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Thomas Perale via buildroot

In reply of:

Quoted 4 lines

Commit [1] introduced a set of patches to fix CVE-2025-31115. Since [2] the security patches neeed to reference the vulnerability with the CVE: trailer in the patch header.

Quoted 8 lines

This set of patch is no longer present on master branch with xz bump [3] but hasn't been cherry picked to 2025.02.x branch.

[1] 06c6c49fe8 package/xz: add security patches fixing CVE-2025-31115
[2] 1167d0ff3d docs/manual: mention CVE trailer
[3] aaa50b0e61 package/xz: bump to version 5.8.1

Applied to 2025.02.x. Thanks

Quoted 62 lines
---
 package/xz/0001-liblzma-mt-dec-Fix-a-comment.patch               | 1 +
 ...02-liblzma-mt-dec-Simplify-by-removing-the-THR_STOP-sta.patch | 1 +
 ...03-liblzma-mt-dec-Don-t-free-the-input-buffer-too-early.patch | 1 +
 ...04-liblzma-mt-dec-Don-t-modify-thr-in_size-in-the-worke.patch | 1 +
 4 files changed, 4 insertions(+)
package/xz/0001-liblzma-mt-dec-Fix-a-comment.patch +1 -0
index 2424fb0d13..41870a8282 100644
@@ -5,6 +5,7 @@ Subject: [PATCH] liblzma: mt dec: Fix a comment
 
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/831b55b971cf579ee16a854f177c36b20d3c6999
 Signed-off-by: Julien Olivain <[email protected]>
 ---
package/xz/0002-liblzma-mt-dec-Simplify-by-removing-the-THR_STOP-sta.patch +1 -0
index 7845380a8c..14985ebc8f 100644
@@ -12,6 +12,7 @@ called (reinitializing the decoder always calls threads_end()).
 
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/c0c835964dfaeb2513a3c0bdb642105152fe9f34
 Signed-off-by: Julien Olivain <[email protected]>
 ---
package/xz/0003-liblzma-mt-dec-Don-t-free-the-input-buffer-too-early.patch +1 -0
index 9915e6b275..d370d8b613 100644
@@ -26,6 +26,7 @@ Fixes: 4cce3e27f529 ("liblzma: Add threaded .xz decompressor.")
 Reported-by: Harri K. Koskinen <[email protected]>
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/d5a2ffe41bb77b918a8c96084885d4dbe4bf6480
 Signed-off-by: Julien Olivain <[email protected]>
 ---
package/xz/0004-liblzma-mt-dec-Don-t-modify-thr-in_size-in-the-worke.patch +1 -0
index 1a914e08db..b3fd11b29d 100644
@@ -21,6 +21,7 @@ Block before the worker thread is activated.
 Fixes: 4cce3e27f529 ("liblzma: Add threaded .xz decompressor.")
 Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
 Thanks-to: Sam James <[email protected]>
+CVE: CVE-2025-31115
 Upstream: https://github.com/tukaani-project/xz/commit/8188048854e8d11071b8a50d093c74f4c030acc9
 Signed-off-by: Julien Olivain <[email protected]>
 ---
Signature · 6 lines
2.53.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot