Skip to contentSkip to conversation

libsdl: CVE fixes

PATCH In review Anuj Mittal 3 participants 3 messages Jul 23, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsdl: CVE fixes

Fixes CVE-2019-7572, CVE-2019-7574, CVE-2019-7575, CVE-2019-7576, CVE-2019-7577, CVE-2019-7578, CVE-2019-7635, CVE-2019-7637, CVE-2019-7638.

---
 .../libsdl/libsdl-1.2.15/CVE-2019-7572.patch  | 114 +++++++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7574.patch  |  68 +++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7575.patch  |  81 ++++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7576.patch  |  80 ++++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7577.patch  | 123 +++++++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7578.patch  |  64 ++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7635.patch  |  63 ++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7637.patch  | 192 ++++++++++++++++++
 .../libsdl/libsdl-1.2.15/CVE-2019-7638.patch  |  38 ++++
 meta/recipes-graphics/libsdl/libsdl_1.2.15.bb |   9 +
 10 files changed, 832 insertions(+)
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7572.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7574.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7575.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7576.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7577.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7578.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7635.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7637.patch
 create mode 100644 meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7638.patch
meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7572.patch new file +114 -0
new file mode 100644
index 0000000000..c41c2de0f3
@@ -0,0 +1,114 @@
+# HG changeset patch
+# User Petr Písař <[email protected]>
+# Date 1560182231 25200
+#      Mon Jun 10 08:57:11 2019 -0700
+# Branch SDL-1.2
+# Node ID a8afedbcaea0e84921dc770195c4699bda3ccdc5
+# Parent  faf9abbcfb5fe0d0ca23c4bf0394aa226ceccf02
+CVE-2019-7572: Fix a buffer overwrite in IMA_ADPCM_decode
+If data chunk was longer than expected based on a WAV format
+definition, IMA_ADPCM_decode() tried to write past the output
+buffer. This patch fixes it.
+
+Based on patch from
+<https://bugzilla.libsdl.org/show_bug.cgi?id=4496>.
+
+CVE-2019-7572
+https://bugzilla.libsdl.org/show_bug.cgi?id=4495
+
+Signed-off-by: Petr Písař <[email protected]>
+
+# HG changeset patch
+# User Petr Písař <[email protected]>
+# Date 1560041863 25200
+#      Sat Jun 08 17:57:43 2019 -0700
+# Branch SDL-1.2
+# Node ID e52413f5258600878f9a10d2f92605a729aa8976
+# Parent  4e73be7b47877ae11d2279bd916910d469d18f8e
+CVE-2019-7572: Fix a buffer overread in IMA_ADPCM_nibble
+If an IMA ADPCM block contained an initial index out of step table
+range (loaded in IMA_ADPCM_decode()), IMA_ADPCM_nibble() blindly used
+this bogus value and that lead to a buffer overread.
+
+This patch fixes it by moving clamping the index value at the
+beginning of IMA_ADPCM_nibble() function instead of the end after
+an update.
+
+CVE-2019-7572
+https://bugzilla.libsdl.org/show_bug.cgi?id=4495
+
+Signed-off-by: Petr Písař <[email protected]>
+
+CVE: CVE-2019-7572
+Upstream-Status: Backport
+Signed-off-by: Anuj Mittal <[email protected]>
+
+diff -r faf9abbcfb5f -r a8afedbcaea0 src/audio/SDL_wave.c
+--- a/src/audio/SDL_wave.c	Mon Jun 10 08:54:29 2019 -0700
++++ b/src/audio/SDL_wave.c	Mon Jun 10 08:57:11 2019 -0700
+@@ -346,7 +346,7 @@
+ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
+ {
+ 	struct IMA_ADPCM_decodestate *state;
+-	Uint8 *freeable, *encoded, *encoded_end, *decoded;
++	Uint8 *freeable, *encoded, *encoded_end, *decoded, *decoded_end;
+ 	Sint32 encoded_len, samplesleft;
+ 	unsigned int c, channels;
+ 
+@@ -373,6 +373,7 @@
+ 		return(-1);
+ 	}
+ 	decoded = *audio_buf;
++	decoded_end = decoded + *audio_len;
+ 
+ 	/* Get ready... Go! */
+ 	while ( encoded_len >= IMA_ADPCM_state.wavefmt.blockalign ) {
+@@ -392,6 +393,7 @@
+ 			}
+ 
+ 			/* Store the initial sample we start with */
++			if (decoded + 2 > decoded_end) goto invalid_size;
+ 			decoded[0] = (Uint8)(state[c].sample&0xFF);
+ 			decoded[1] = (Uint8)(state[c].sample>>8);
+ 			decoded += 2;
+@@ -402,6 +404,8 @@
+ 		while ( samplesleft > 0 ) {
+ 			for ( c=0; c<channels; ++c ) {
+ 				if (encoded + 4 > encoded_end) goto invalid_size;
++				if (decoded + 4 * 4 * channels > decoded_end)
++					goto invalid_size;
+ 				Fill_IMA_ADPCM_block(decoded, encoded,
+ 						c, channels, &state[c]);
+ 				encoded += 4;
+
+diff -r 4e73be7b4787 -r e52413f52586 src/audio/SDL_wave.c
+--- a/src/audio/SDL_wave.c	Sat Jun 01 18:27:46 2019 +0100
++++ b/src/audio/SDL_wave.c	Sat Jun 08 17:57:43 2019 -0700
+@@ -264,6 +264,14 @@
+ 	};
+ 	Sint32 delta, step;
+ 
++	/* Clamp index value. The inital value can be invalid. */
++	if ( state->index > 88 ) {
++		state->index = 88;
++	} else
++	if ( state->index < 0 ) {
++		state->index = 0;
++	}
++
+ 	/* Compute difference and new sample value */
+ 	step = step_table[state->index];
+ 	delta = step >> 3;
+@@ -275,12 +283,6 @@
+ 
+ 	/* Update index value */
+ 	state->index += index_table[nybble];
+-	if ( state->index > 88 ) {
+-		state->index = 88;
+-	} else
+-	if ( state->index < 0 ) {
+-		state->index = 0;
+-	}
+ 
+ 	/* Clamp output sample */
+ 	if ( state->sample > max_audioval ) {
meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7574.patch new file +68 -0

68 lines not on this page · raw message

meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7575.patch new file +81 -0

81 lines not on this page · raw message

meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7576.patch new file +80 -0

80 lines not on this page · raw message

meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7577.patch new file +123 -0

123 lines not on this page · raw message

meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7578.patch new file +64 -0

64 lines not on this page · raw message

meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7635.patch new file +63 -0

63 lines not on this page · raw message

meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7637.patch new file +192 -0

192 lines not on this page · raw message

meta/recipes-graphics/libsdl/libsdl-1.2.15/CVE-2019-7638.patch new file +38 -0
new file mode 100644
index 0000000000..dab9aaeb2b
@@ -0,0 +1,38 @@
+# HG changeset patch
+# User Sam Lantinga <[email protected]>
+# Date 1550504903 28800
+#      Mon Feb 18 07:48:23 2019 -0800
+# Branch SDL-1.2
+# Node ID 19d8c3b9c25143f71a34ff40ce1df91b4b3e3b78
+# Parent  8586f153eedec4c4e07066d6248ebdf67f10a229
+Fixed bug 4500 - Heap-Buffer Overflow in Map1toN pertaining to SDL_pixels.c
+
+Petr Pisar
+
+The reproducer has these data in BITMAPINFOHEADER:
+
+biSize = 40
+biBitCount = 8
+biClrUsed = 131075
+
+SDL_LoadBMP_RW() function passes biBitCount as a color depth to SDL_CreateRGBSurface(), thus 256-color pallete is allocated. But then biClrUsed colors are read from a file and stored into the palette. SDL_LoadBMP_RW should report an error if biClrUsed is greater than 2^biBitCount.
+
+CVE: CVE-2019-7638
+CVE: CVE-2019-7636
+Upstream-Status: Backport
+Signed-off-by: Anuj Mittal <[email protected]>
+
+diff -r 8586f153eede -r 19d8c3b9c251 src/video/SDL_bmp.c
+--- a/src/video/SDL_bmp.c	Sun Jan 13 15:27:50 2019 +0100
++++ b/src/video/SDL_bmp.c	Mon Feb 18 07:48:23 2019 -0800
+@@ -233,6 +233,10 @@
+ 	if ( palette ) {
+ 		if ( biClrUsed == 0 ) {
+ 			biClrUsed = 1 << biBitCount;
++		} else if ( biClrUsed > (1 << biBitCount) ) {
++			SDL_SetError("BMP file has an invalid number of colors");
++			was_error = SDL_TRUE;
++			goto done;
+ 		}
+ 		if ( biSize == 12 ) {
+ 			for ( i = 0; i < (int)biClrUsed; ++i ) {
meta/recipes-graphics/libsdl/libsdl_1.2.15.bb +9 -0
index 7718d11919..7a01908322 100644
@@ -18,6 +18,15 @@ SRC_URI = "http://www.libsdl.org/release/SDL-${PV}.tar.gz \
            file://libsdl-1.2.15-xdata32.patch \
            file://pkgconfig.patch \
            file://0001-build-Pass-tag-CC-explictly-when-using-libtool.patch \
+           file://CVE-2019-7577.patch \
+           file://CVE-2019-7574.patch \
+           file://CVE-2019-7572.patch \
+           file://CVE-2019-7578.patch \
+           file://CVE-2019-7575.patch \
+           file://CVE-2019-7635.patch \
+           file://CVE-2019-7637.patch \
+           file://CVE-2019-7638.patch \
+           file://CVE-2019-7576.patch \
           "
 
 UPSTREAM_CHECK_REGEX = "SDL-(?P<pver>\d+(\.\d+)+)\.tar"
Signature · 1 line
2.20.1
#1 lore raw
Quoted 3 lines · Anuj Mittal

Fixes CVE-2019-7572, CVE-2019-7574, CVE-2019-7575, CVE-2019-7576, CVE-2019-7577, CVE-2019-7578, CVE-2019-7635, CVE-2019-7637, CVE-2019-7638.

Wow, that a load of CVE fixes. Thanks Anuj!

Can you remind tell me why we need to keep libsdl_1.2.15? It was deprecated 7 years ago:
https://en.wikipedia.org/wiki/Simple_DirectMedia_Layer

$ cd .../oe-core.git
$ rgrep sdl * | grep -v sdl2 | \
   grep -v recipes-graphics/libsdl/libsdl[-_]1.2.15

...nothing that looks like a dependency on this version...

There are some dependencies in other layers so maybe we should move this to meta-oe if those dependencies can't be changed to libsdl2.

Signature · 2 lines
# Randy MacLeod
# Wind River Linux
#2 lore raw
Quoted 9 lines · Randy MacLeod

Can you remind tell me why we need to keep libsdl_1.2.15? It was deprecated 7 years ago:
https://en.wikipedia.org/wiki/Simple_DirectMedia_Layer

$ cd .../oe-core.git
$ rgrep sdl * | grep -v sdl2 | \
    grep -v recipes-graphics/libsdl/libsdl[-_]1.2.15
Quoted 5 lines

...nothing that looks like a dependency on this version...

There are some dependencies in other layers so maybe we should move this to meta-oe if those dependencies can't be changed to libsdl2.

I think mpg123/321 was the last user, and I changed that a while ago. So, yes!

Anuj, can you send the recipe with the CVE fixes to meta-oe?

Ross