package/libsndfile: add upstream post-1.2.2 security fixes
PATCH 1/1 package/libsndfile: add upstream post-1.2.2 security fixes
Fixes the following security vulnerabilities:
CVE-2022-33065: Multiple signed integers overflow in function au_read_header in src/au.c and in functions mat4_open and mat4_read_header in src/mat4.c in Libsndfile, allows an attacker to cause Denial of Service or other unspecified impacts.
CVE-2024-50612: libsndfile through 1.2.2 has an ogg_vorbis.c vorbis_analysis_wrote out-of-bounds read.
--- ...-int-overflow-in-dataend-calculation.patch | 45 ++ ...-overflow-while-calculating-data_end.patch | 58 +++ ...-fix-int-overflow-in-avr_read_header.patch | 34 ++ ...rflow-warning-in-sample-calculations.patch | 61 +++ ...erflow-when-counting-header-elements.patch | 39 ++ ...ix-int-overflow-in-ircam_read_header.patch | 82 ++++ ...t-overflow-when-calculating-blockwid.patch | 48 ++ ...-int-overflow-in-psf_binheader_readf.patch | 181 ++++++++ ...-fix-int-overflow-in-signal-estimate.patch | 233 ++++++++++ ...m-fix-int-overflow-in-sf.frames-calc.patch | 39 ++ ...011-pcm-fix-int-overflow-in-pcm_init.patch | 35 ++ ...fix-int-overflow-in-rf64_read_header.patch | 40 ++ ...-fix-int-overflow-in-ima_reader_init.patch | 55 +++ ...rror-checking-for-vorbis.-Fixes-1035.patch | 411 ++++++++++++++++++ package/libsndfile/libsndfile.mk | 18 + 15 files changed, 1379 insertions(+) create mode 100644 package/libsndfile/0001-mat4-mat5-fix-int-overflow-in-dataend-calculation.patch create mode 100644 package/libsndfile/0002-au-avoid-int-overflow-while-calculating-data_end.patch create mode 100644 package/libsndfile/0003-avr-fix-int-overflow-in-avr_read_header.patch create mode 100644 package/libsndfile/0004-sds-fix-int-overflow-warning-in-sample-calculations.patch create mode 100644 package/libsndfile/0005-aiff-fix-int-overflow-when-counting-header-elements.patch create mode 100644 package/libsndfile/0006-ircam-fix-int-overflow-in-ircam_read_header.patch create mode 100644 package/libsndfile/0007-mat4-mat5-fix-int-overflow-when-calculating-blockwid.patch create mode 100644 package/libsndfile/0008-common-fix-int-overflow-in-psf_binheader_readf.patch create mode 100644 package/libsndfile/0009-nms_adpcm-fix-int-overflow-in-signal-estimate.patch create mode 100644 package/libsndfile/0010-nms_adpcm-fix-int-overflow-in-sf.frames-calc.patch create mode 100644 package/libsndfile/0011-pcm-fix-int-overflow-in-pcm_init.patch create mode 100644 package/libsndfile/0012-rf64-fix-int-overflow-in-rf64_read_header.patch create mode 100644 package/libsndfile/0013-ima_adpcm-fix-int-overflow-in-ima_reader_init.patch create mode 100644 package/libsndfile/0014-src-ogg-better-error-checking-for-vorbis.-Fixes-1035.patch
package/libsndfile/0001-mat4-mat5-fix-int-overflow-in-dataend-calculation.patch new file +45 -0
@@ -0,0 +1,45 @@ +From 0754562e13d2e63a248a1c82f90b30bc0ffe307c Mon Sep 17 00:00:00 2001 +From: Alex Stewart <[email protected]> +Date: Tue, 10 Oct 2023 16:10:34 -0400 +Subject: [PATCH] mat4/mat5: fix int overflow in dataend calculation + +The clang sanitizer warns of a possible signed integer overflow when +calculating the `dataend` value in `mat4_read_header()`. + +``` +src/mat4.c:323:41: runtime error: signed integer overflow: 205 * -100663296 cannot be represented in type 'int' +SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/mat4.c:323:41 in +src/mat4.c:323:48: runtime error: signed integer overflow: 838860800 * 4 cannot be represented in type 'int' +SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/mat4.c:323:48 in +``` + +Cast the offending `rows` and `cols` ints to `sf_count_t` (the type of +`dataend` before performing the calculation, to avoid the issue. + +CVE: CVE-2022-33065 +Fixes: https://github.com/libsndfile/libsndfile/issues/789 +Fixes: https://github.com/libsndfile/libsndfile/issues/833 + +Signed-off-by: Alex Stewart <[email protected]> +Upstream: https://github.com/libsndfile/libsndfile/commit/0754562e13d2e63a248a1c82f90b30bc0ffe307c +Signed-off-by: Peter Korsgaard <[email protected]> +--- + src/mat4.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/mat4.c b/src/mat4.c +index 0b1b414b..575683ba 100644 +--- a/src/mat4.c ++++ b/src/mat4.c +@@ -320,7 +320,7 @@ mat4_read_header (SF_PRIVATE *psf) + psf->filelength - psf->dataoffset, psf->sf.channels * psf->sf.frames * psf->bytewidth) ; + } + else if ((psf->filelength - psf->dataoffset) > psf->sf.channels * psf->sf.frames * psf->bytewidth) +- psf->dataend = psf->dataoffset + rows * cols * psf->bytewidth ; ++ psf->dataend = psf->dataoffset + (sf_count_t) rows * (sf_count_t) cols * psf->bytewidth ; + + psf->datalength = psf->filelength - psf->dataoffset - psf->dataend ; + +-- +2.39.5 +
package/libsndfile/0002-au-avoid-int-overflow-while-calculating-data_end.patch new file +58 -0
58 lines not on this page · raw message
package/libsndfile/0003-avr-fix-int-overflow-in-avr_read_header.patch new file +34 -0
@@ -0,0 +1,34 @@ +From 2f8eece78cc8b4dce6c95b3045867f0936714db8 Mon Sep 17 00:00:00 2001 +From: Alex Stewart <[email protected]> +Date: Wed, 11 Oct 2023 16:46:29 -0400 +Subject: [PATCH] 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: https://github.com/libsndfile/libsndfile/commit/2f8eece78cc8b4dce6c95b3045867f0936714db8 +Signed-off-by: Peter Korsgaard <[email protected]> +--- + src/avr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/avr.c b/src/avr.c +index 6c78ff69..1bc1ffc9 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 ; +-- +2.39.5 +
package/libsndfile/0004-sds-fix-int-overflow-warning-in-sample-calculations.patch new file +61 -0
61 lines not on this page · raw message
package/libsndfile/0005-aiff-fix-int-overflow-when-counting-header-elements.patch new file +39 -0
@@ -0,0 +1,39 @@ +From 187451dbd3c044f9a76b6c1d950d458de0103180 Mon Sep 17 00:00:00 2001 +From: Alex Stewart <[email protected]> +Date: Wed, 11 Oct 2023 17:26:51 -0400 +Subject: [PATCH] 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: https://github.com/libsndfile/libsndfile/commit/187451dbd3c044f9a76b6c1d950d458de0103180 +Signed-off-by: Peter Korsgaard <[email protected]> +--- + src/aiff.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/aiff.c b/src/aiff.c +index ac3655e9..6d8f1bc8 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) ; +-- +2.39.5 +
package/libsndfile/0006-ircam-fix-int-overflow-in-ircam_read_header.patch new file +82 -0
82 lines not on this page · raw message
package/libsndfile/0007-mat4-mat5-fix-int-overflow-when-calculating-blockwid.patch new file +48 -0
48 lines not on this page · raw message
package/libsndfile/0008-common-fix-int-overflow-in-psf_binheader_readf.patch new file +181 -0
181 lines not on this page · raw message
package/libsndfile/0009-nms_adpcm-fix-int-overflow-in-signal-estimate.patch new file +233 -0
233 lines not on this page · raw message
package/libsndfile/0010-nms_adpcm-fix-int-overflow-in-sf.frames-calc.patch new file +39 -0
@@ -0,0 +1,39 @@ +From 3fb27a2c93a11dd3321b0b13140d89ebb39060cb Mon Sep 17 00:00:00 2001 +From: Alex Stewart <[email protected]> +Date: Tue, 17 Oct 2023 11:50:53 -0400 +Subject: [PATCH] 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: https://github.com/libsndfile/libsndfile/commit/3fb27a2c93a11dd3321b0b13140d89ebb39060cb +Signed-off-by: Peter Korsgaard <[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 dca85f0b..61d171c7 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 ; + +-- +2.39.5 +
package/libsndfile/0011-pcm-fix-int-overflow-in-pcm_init.patch new file +35 -0
@@ -0,0 +1,35 @@ +From 09f8f8d5544d98a5a2d28504c02314a2a816ac37 Mon Sep 17 00:00:00 2001 +From: Alex Stewart <[email protected]> +Date: Tue, 17 Oct 2023 11:57:23 -0400 +Subject: [PATCH] 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: https://github.com/libsndfile/libsndfile/commit/09f8f8d5544d98a5a2d28504c02314a2a816ac37 +Signed-off-by: Peter Korsgaard <[email protected]> +--- + src/pcm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/pcm.c b/src/pcm.c +index bdf46183..a42e4868 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 ; +-- +2.39.5 +
package/libsndfile/0012-rf64-fix-int-overflow-in-rf64_read_header.patch new file +40 -0
@@ -0,0 +1,40 @@ +From 49704025956f03751d3436a0bb42287cd7f434b6 Mon Sep 17 00:00:00 2001 +From: Alex Stewart <[email protected]> +Date: Tue, 17 Oct 2023 12:01:00 -0400 +Subject: [PATCH] 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: https://github.com/libsndfile/libsndfile/commit/49704025956f03751d3436a0bb42287cd7f434b6 +Signed-off-by: Peter Korsgaard <[email protected]> +--- + src/rf64.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/rf64.c b/src/rf64.c +index 123db445..c60399fb 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) ; +-- +2.39.5 +
package/libsndfile/0013-ima_adpcm-fix-int-overflow-in-ima_reader_init.patch new file +55 -0
55 lines not on this page · raw message
package/libsndfile/0014-src-ogg-better-error-checking-for-vorbis.-Fixes-1035.patch new file +411 -0
411 lines not on this page · raw message
package/libsndfile/libsndfile.mk +18 -0
@@ -13,6 +13,24 @@ LIBSNDFILE_LICENSE_FILES = COPYING LIBSNDFILE_CPE_ID_VALID = YES LIBSNDFILE_DEPENDENCIES = host-pkgconf +# 0001-mat4-mat5-fix-int-overflow-in-dataend-calculation.patch +# 0002-au-avoid-int-overflow-while-calculating-data_end.patch +# 0003-avr-fix-int-overflow-in-avr_read_header.patch +# 0004-sds-fix-int-overflow-warning-in-sample-calculations.patch +# 0005-aiff-fix-int-overflow-when-counting-header-elements.patch +# 0006-ircam-fix-int-overflow-in-ircam_read_header.patch +# 0007-mat4-mat5-fix-int-overflow-when-calculating-blockwid.patch +# 0008-common-fix-int-overflow-in-psf_binheader_readf.patch +# 0009-nms_adpcm-fix-int-overflow-in-signal-estimate.patch +# 0010-nms_adpcm-fix-int-overflow-in-sf.frames-calc.patch +# 0011-pcm-fix-int-overflow-in-pcm_init.patch +# 0012-rf64-fix-int-overflow-in-rf64_read_header.patch +# 0013-ima_adpcm-fix-int-overflow-in-ima_reader_init.patch +LIBSNDFILE_IGNORE_CVES += CVE-2022-33065 + +# 0014-src-ogg-better-error-checking-for-vorbis.-Fixes-1035.patch +LIBSNDFILE_IGNORE_CVES += CVE-2024-50612 + LIBSNDFILE_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99' LIBSNDFILE_CONF_OPTS = \ --disable-sqlite \
Signature · 6 lines
2.39.5 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 11 lines · Peter Korsgaard
Fixes the following security vulnerabilities:
CVE-2022-33065: Multiple signed integers overflow in function
au_read_headerinsrc/au.cand in functionsmat4_openandmat4_read_headerinsrc/mat4.cin Libsndfile, allows an attacker to cause Denial of Service or other unspecified impacts.CVE-2024-50612: libsndfile through 1.2.2 has an
ogg_vorbis.cvorbis_analysis_wroteout-of-bounds read.Signed-off-by Peter Korsgaard <[email protected]>
Applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Julien" == Julien Olivain <[email protected]> writes:
Quoted 10 lines · Peter Korsgaard
Fixes the following security vulnerabilities:
CVE-2022-33065: Multiple signed integers overflow in functionau_read_header
insrc/au.cand in functionsmat4_openandmat4_read_headerinsrc/mat4.cin
Libsndfile, allows an attacker to cause Denial of Service or other unspecified impacts.
CVE-2024-50612: libsndfile through 1.2.2 has anogg_vorbis.cvorbis_analysis_wroteout-of-bounds read.Signed-off-by Peter Korsgaard <[email protected]>
Quoted 1 line
Applied to master, thanks.
Committed to 2024.02.x and 2024.11.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot