Skip to contentSkip to conversation

libsndfile1: Backport fix for CVE-2022-33065

PATCH New [email protected] 1 participant 1 message Dec 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsndfile1: Backport fix for CVE-2022-33065

From: Vijay Anusuri <[email protected]>

Added missing commits for complete CVE fix

Ref: https://github.com/libsndfile/libsndfile/issues/833

     https://ubuntu.com/security/CVE-2022-33065
---
 ...022-33065.patch => CVE-2022-33065-1.patch} |   0
 .../libsndfile1/CVE-2022-33065-10.patch       |  39 +++
 .../libsndfile1/CVE-2022-33065-11.patch       |  35 +++
 .../libsndfile1/CVE-2022-33065-12.patch       |  40 +++
 .../libsndfile1/CVE-2022-33065-13.patch       |  58 +++++
 .../libsndfile1/CVE-2022-33065-2.patch        |  58 +++++
 .../libsndfile1/CVE-2022-33065-3.patch        |  34 +++
 .../libsndfile1/CVE-2022-33065-4.patch        |  60 +++++
 .../libsndfile1/CVE-2022-33065-5.patch        |  39 +++
 .../libsndfile1/CVE-2022-33065-6.patch        |  82 +++++++
 .../libsndfile1/CVE-2022-33065-7.patch        |  48 ++++
 .../libsndfile1/CVE-2022-33065-8.patch        | 179 ++++++++++++++
 .../libsndfile1/CVE-2022-33065-9.patch        | 231 ++++++++++++++++++
 .../libsndfile/libsndfile1_1.0.31.bb          |  14 +-
 14 files changed, 916 insertions(+), 1 deletion(-)
 rename meta/recipes-multimedia/libsndfile/libsndfile1/{CVE-2022-33065.patch => CVE-2022-33065-1.patch} (100%)
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-10.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-11.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-12.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-13.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-2.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-3.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-4.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-5.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-6.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-7.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-8.patch
 create mode 100644 meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-9.patch
meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-1.patch renamed from meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065.patch +0 -0
similarity index 100%
rename from meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065.patch
rename to meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-1.patch
meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-10.patch new file +39 -0
new file mode 100644
index 0000000000..17867fc308
@@ -0,0 +1,39 @@
+From cd44bfaf3708e778c8670cb7f707a597c3334376 Mon Sep 17 00:00:00 2001
+From: Alex Stewart <[email protected]>
+Date: Tue, 17 Oct 2023 11:50:53 -0400
+Subject: [PATCH 14/17] nms_adpcm: fix int overflow in sf.frames calc
+
+When calculating sf.frames from the blocks_total PNMS variable, it is
+theoretically possible to overflow the blocks_total int boundaries,
+leading to undefined behavior.
+
+Cast blocks_total to a long-sized sf_count_t before the calculation, to
+provide it with enough numeric space and because that is the final
+typing regardless.
+
+CVE: CVE-2022-33065
+Fixes: https://github.com/libsndfile/libsndfile/issues/833
+
+Signed-off-by: Alex Stewart <[email protected]>
+
+Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libsndfile/tree/debian/patches/CVE-2022-33065/CVE-2022-33065-10.patch?h=ubuntu/jammy-security
+Upstream commit https://github.com/libsndfile/libsndfile/commit/cd44bfaf3708e778c8670cb7f707a597c3334376]
+CVE: CVE-2022-33065
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ src/nms_adpcm.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/nms_adpcm.c b/src/nms_adpcm.c
+index dca85f0b0..61d171c73 100644
+--- a/src/nms_adpcm.c
++++ b/src/nms_adpcm.c
+@@ -1090,7 +1090,7 @@ nms_adpcm_init (SF_PRIVATE *psf)
+ 	else
+ 		pnms->blocks_total = psf->datalength / (pnms->shortsperblock * sizeof (short)) ;
+ 
+-	psf->sf.frames		= pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ;
++	psf->sf.frames		= (sf_count_t) pnms->blocks_total * NMS_SAMPLES_PER_BLOCK ;
+ 	psf->codec_close	= nms_adpcm_close ;
+ 	psf->seek			= nms_adpcm_seek ;
+ 
meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-11.patch new file +35 -0
new file mode 100644
index 0000000000..a147a0d593
@@ -0,0 +1,35 @@
+From 915e154e2deb327612ca413c838365b7c9bfbf16 Mon Sep 17 00:00:00 2001
+From: Alex Stewart <[email protected]>
+Date: Tue, 17 Oct 2023 11:57:23 -0400
+Subject: [PATCH 15/17] pcm: fix int overflow in pcm_init()
+
+Cast the int-sized bytewidth variable to a long-sized sf_count_t type
+prior to calculating the blockwidth, to provide the calculation with
+enough numeric space and sf_count_t is the final typing regardless.
+
+CVE: CVE-2022-33065
+Fixes: https://github.com/libsndfile/libsndfile/issues/833
+
+Signed-off-by: Alex Stewart <[email protected]>
+
+Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libsndfile/tree/debian/patches/CVE-2022-33065/CVE-2022-33065-11.patch?h=ubuntu/jammy-security
+Upstream commit https://github.com/libsndfile/libsndfile/commit/915e154e2deb327612ca413c838365b7c9bfbf16]
+CVE: CVE-2022-33065
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ src/pcm.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/pcm.c b/src/pcm.c
+index bdf461839..a42e48681 100644
+--- a/src/pcm.c
++++ b/src/pcm.c
+@@ -127,7 +127,7 @@ pcm_init (SF_PRIVATE *psf)
+ 		return SFE_INTERNAL ;
+ 		} ;
+ 
+-	psf->blockwidth = psf->bytewidth * psf->sf.channels ;
++	psf->blockwidth = (sf_count_t) psf->bytewidth * psf->sf.channels ;
+ 
+ 	if ((SF_CODEC (psf->sf.format)) == SF_FORMAT_PCM_S8)
+ 		chars = SF_CHARS_SIGNED ;
meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-12.patch new file +40 -0
new file mode 100644
index 0000000000..659a6a4c22
@@ -0,0 +1,40 @@
+From ec149a79d457916479489d71b55e4d63015a08ea Mon Sep 17 00:00:00 2001
+From: Alex Stewart <[email protected]>
+Date: Tue, 17 Oct 2023 12:01:00 -0400
+Subject: [PATCH 16/17] rf64: fix int overflow in rf64_read_header()
+
+When checking for mismatches between the filelength and riff_size, it is
+possible to overflow the temporary riff_size value used in the
+comparison by adding a static offset; which is probably fine, but it is
+offensive to overflow fuzzers.
+
+Since filelength is always a positive value, simply move the offset to
+the other side of the comparison operator as a negative value, avoid the
+possibility of an overflow.
+
+CVE: CVE-2022-33065
+Fixes: https://github.com/libsndfile/libsndfile/issues/833
+
+Signed-off-by: Alex Stewart <[email protected]>
+
+Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libsndfile/tree/debian/patches/CVE-2022-33065/CVE-2022-33065-12.patch?h=ubuntu/jammy-security
+Upstream commit https://github.com/libsndfile/libsndfile/commit/ec149a79d457916479489d71b55e4d63015a08ea]
+CVE: CVE-2022-33065
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ src/rf64.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/rf64.c b/src/rf64.c
+index 123db445a..c60399fb3 100644
+--- a/src/rf64.c
++++ b/src/rf64.c
+@@ -242,7 +242,7 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
+ 							} ;
+ 						} ;
+ 
+-					if (psf->filelength != riff_size + 8)
++					if (psf->filelength - 8 != riff_size)
+ 						psf_log_printf (psf, "  Riff size : %D (should be %D)\n", riff_size, psf->filelength - 8) ;
+ 					else
+ 						psf_log_printf (psf, "  Riff size : %D\n", riff_size) ;
meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-13.patch new file +58 -0

58 lines not on this page · raw message

meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-2.patch new file +58 -0

58 lines not on this page · raw message

meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-3.patch new file +34 -0
new file mode 100644
index 0000000000..80af387081
@@ -0,0 +1,34 @@
+From 839fa9131820d689b2038c81531b618b2932fbe3 Mon Sep 17 00:00:00 2001
+From: Alex Stewart <[email protected]>
+Date: Wed, 11 Oct 2023 16:46:29 -0400
+Subject: [PATCH 07/17] avr: fix int overflow in avr_read_header()
+
+Pre-cast hdr.frames to sf_count_t, to provide the calculation with
+enough numeric space to avoid an int-overflow.
+
+CVE: CVE-2022-33065
+Fixes: https://github.com/libsndfile/libsndfile/issues/833
+
+Signed-off-by: Alex Stewart <[email protected]>
+
+Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libsndfile/tree/debian/patches/CVE-2022-33065/CVE-2022-33065-3.patch?h=ubuntu/jammy-security
+Upstream commit https://github.com/libsndfile/libsndfile/commit/839fa9131820d689b2038c81531b618b2932fbe3]
+CVE: CVE-2022-33065
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ src/avr.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/avr.c b/src/avr.c
+index 6c78ff69b..1bc1ffc90 100644
+--- a/src/avr.c
++++ b/src/avr.c
+@@ -162,7 +162,7 @@ avr_read_header (SF_PRIVATE *psf)
+ 	psf->endian = SF_ENDIAN_BIG ;
+ 
+  	psf->dataoffset = AVR_HDR_SIZE ;
+-	psf->datalength = hdr.frames * (hdr.rez / 8) ;
++	psf->datalength = (sf_count_t) hdr.frames * (hdr.rez / 8) ;
+ 
+ 	if (psf->fileoffset > 0)
+ 		psf->filelength = AVR_HDR_SIZE + psf->datalength ;
meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-4.patch new file +60 -0

60 lines not on this page · raw message

meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-5.patch new file +39 -0
new file mode 100644
index 0000000000..a96e5fefa4
@@ -0,0 +1,39 @@
+From 23188c9b1c34f06ca7f17243425d59403e9eb0db Mon Sep 17 00:00:00 2001
+From: Alex Stewart <[email protected]>
+Date: Wed, 11 Oct 2023 17:26:51 -0400
+Subject: [PATCH 09/17] aiff: fix int overflow when counting header elements
+
+aiff_read_basc_chunk() tries to count the AIFF header size by keeping
+track of the bytes returned by psf_binheader_readf(). Though improbable,
+it is technically possible for these added bytes to exceed the int-sized
+`count` accumulator.
+
+Use a 64-bit sf_count_t type for `count`, to ensure that it always has
+enough numeric space.
+
+CVE: CVE-2022-33065
+Fixes: https://github.com/libsndfile/libsndfile/issues/833
+
+Signed-off-by: Alex Stewart <[email protected]>
+
+Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/libsndfile/tree/debian/patches/CVE-2022-33065/CVE-2022-33065-5.patch?h=ubuntu/jammy-security
+Upstream commit https://github.com/libsndfile/libsndfile/commit/23188c9b1c34f06ca7f17243425d59403e9eb0db]
+CVE: CVE-2022-33065
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ src/aiff.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/aiff.c b/src/aiff.c
+index ac3655e9d..6d8f1bc83 100644
+--- a/src/aiff.c
++++ b/src/aiff.c
+@@ -1702,7 +1702,7 @@ static int
+ aiff_read_basc_chunk (SF_PRIVATE * psf, int datasize)
+ {	const char * type_str ;
+ 	basc_CHUNK bc ;
+-	int count ;
++	sf_count_t count ;
+ 
+ 	count = psf_binheader_readf (psf, "E442", &bc.version, &bc.numBeats, &bc.rootNote) ;
+ 	count += psf_binheader_readf (psf, "E222", &bc.scaleType, &bc.sigNumerator, &bc.sigDenominator) ;
meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-6.patch new file +82 -0

82 lines not on this page · raw message

meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-7.patch new file +48 -0

48 lines not on this page · raw message

meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-8.patch new file +179 -0

179 lines not on this page · raw message

meta/recipes-multimedia/libsndfile/libsndfile1/CVE-2022-33065-9.patch new file +231 -0

231 lines not on this page · raw message

meta/recipes-multimedia/libsndfile/libsndfile1_1.0.31.bb +13 -1
index 20240635f7..6a6ccf7567 100644
@@ -11,7 +11,19 @@ LICENSE = "LGPL-2.1-only"
 SRC_URI = "https://github.com/libsndfile/libsndfile/releases/download/${PV}/libsndfile-${PV}.tar.bz2 \
            file://noopus.patch \
            file://0001-flac-Fix-improper-buffer-reusing-732.patch \
-           file://CVE-2022-33065.patch \
+           file://CVE-2022-33065-1.patch \
+           file://CVE-2022-33065-2.patch \
+           file://CVE-2022-33065-3.patch \
+           file://CVE-2022-33065-4.patch \
+           file://CVE-2022-33065-5.patch \
+           file://CVE-2022-33065-6.patch \
+           file://CVE-2022-33065-7.patch \
+           file://CVE-2022-33065-8.patch \
+           file://CVE-2022-33065-9.patch \
+           file://CVE-2022-33065-10.patch \
+           file://CVE-2022-33065-11.patch \
+           file://CVE-2022-33065-12.patch \
+           file://CVE-2022-33065-13.patch \
            file://CVE-2024-50612.patch \
           "
 UPSTREAM_CHECK_URI = "https://github.com/libsndfile/libsndfile/releases/"
Signature · 1 line
2.25.1