faad2: patch CVE-221-32272
PATCH 1/4 faad2: patch CVE-221-32272
Details: https://nvd.nist.gov/vuln/detail/CVE-2021-32272
Pick the patch that is mentioned in the ncv report.
--- ...ix-heap-buffer-overflow-in-mp4read.c.patch | 37 +++++++++++++++++++ .../recipes-multimedia/faad2/faad2_2.8.8.bb | 4 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-multimedia/faad2/faad2/0001-fix-heap-buffer-overflow-in-mp4read.c.patch
meta-oe/recipes-multimedia/faad2/faad2/0001-fix-heap-buffer-overflow-in-mp4read.c.patch new file +37 -0
@@ -0,0 +1,37 @@ +From 57850acf9d40fc2898ded492b9ce942110d0c426 Mon Sep 17 00:00:00 2001 +From: Fabian Greffrath <[email protected]> +Date: Mon, 31 Aug 2020 10:00:37 +0200 +Subject: [PATCH] fix heap-buffer-overflow in mp4read.c + +This originated from an integer overflow: If mp4config.frame.ents +would be read-in with a value of (uint32t)(-1), it would overflow to 0 +in the size calculation for the allocation in the next line. The +malloc() function would then successfully return a pointer to a memory +region of size 0, which will cause a segfault when written to. + +Fixes #57. + +CVE: CVE-2021-32272 +Upstream-Status: Backport [https://github.com/knik0/faad2/commit/1b71a6ba963d131375f5e489b3b25e36f19f3f24] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + frontend/mp4read.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/frontend/mp4read.c b/frontend/mp4read.c +index 9767383..5dc36b7 100644 +--- a/frontend/mp4read.c ++++ b/frontend/mp4read.c +@@ -340,7 +340,10 @@ static int stszin(int size) + // Number of entries + mp4config.frame.ents = u32in(); + // fixme error checking +- // fixme: check atom size ++ ++ if (!(mp4config.frame.ents + 1)) ++ return ERR_FAIL; ++ + mp4config.frame.data = malloc(sizeof(*mp4config.frame.data) + * (mp4config.frame.ents + 1)); + ofs = 0;
meta-oe/recipes-multimedia/faad2/faad2_2.8.8.bb +3 -1
@@ -7,7 +7,9 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=381c8cbe277a7bc1ee2ae6083a04c958" LICENSE_FLAGS = "commercial" -SRC_URI = "${SOURCEFORGE_MIRROR}/faac/faad2-src/faad2-2.8.0/${BP}.tar.gz" +SRC_URI = "${SOURCEFORGE_MIRROR}/faac/faad2-src/faad2-2.8.0/${BP}.tar.gz \ + file://0001-fix-heap-buffer-overflow-in-mp4read.c.patch \ + " SRC_URI[md5sum] = "28f6116efdbe9378269f8a6221767d1f" SRC_URI[sha256sum] = "985c3fadb9789d2815e50f4ff714511c79c2710ac27a4aaaf5c0c2662141426d"
PATCH 2/4 faad2: patch CVE-2021-32273
Details: https://nvd.nist.gov/vuln/detail/CVE-2021-32273
Pick the patch that resolved the issue linked in the nvd report.
--- ...ack-buffer-overflow-in-stringin-ftyp.patch | 28 +++++++++++++++++++ .../recipes-multimedia/faad2/faad2_2.8.8.bb | 1 + 2 files changed, 29 insertions(+) create mode 100644 meta-oe/recipes-multimedia/faad2/faad2/0001-mp4read.c-fix-stack-buffer-overflow-in-stringin-ftyp.patch
meta-oe/recipes-multimedia/faad2/faad2/0001-mp4read.c-fix-stack-buffer-overflow-in-stringin-ftyp.patch new file +28 -0
@@ -0,0 +1,28 @@ +From a58cf881b820bfb4544995192fe5992ae010f1d7 Mon Sep 17 00:00:00 2001 +From: Fabian Greffrath <[email protected]> +Date: Mon, 17 Aug 2020 07:37:09 +0200 +Subject: [PATCH] mp4read.c: fix stack-buffer-overflow in stringin()/ftypin() + +Terminate the string read into the stack buffer, +fixes #56. + +CVE: CVE-2021-32273 +Upstream-Status: Backport [https://github.com/knik0/faad2/commit/1073aeef823cafd844704389e9a497c257768e2f] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + frontend/mp4read.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/frontend/mp4read.c b/frontend/mp4read.c +index 5dc36b7..a978e62 100644 +--- a/frontend/mp4read.c ++++ b/frontend/mp4read.c +@@ -91,6 +91,7 @@ static int stringin(char *txt, int sizemax) + if (!txt[size]) + break; + } ++ txt[sizemax-1] = '\0'; + + return size; + }
meta-oe/recipes-multimedia/faad2/faad2_2.8.8.bb +1 -0
@@ -9,6 +9,7 @@ LICENSE_FLAGS = "commercial" SRC_URI = "${SOURCEFORGE_MIRROR}/faac/faad2-src/faad2-2.8.0/${BP}.tar.gz \ file://0001-fix-heap-buffer-overflow-in-mp4read.c.patch \ + file://0001-mp4read.c-fix-stack-buffer-overflow-in-stringin-ftyp.patch \ " SRC_URI[md5sum] = "28f6116efdbe9378269f8a6221767d1f" SRC_URI[sha256sum] = "985c3fadb9789d2815e50f4ff714511c79c2710ac27a4aaaf5c0c2662141426d"
PATCH 3/4 faad2: patch CVE-2021-32274 and CVE-2021-32277
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2021-32274
https://nvd.nist.gov/vuln/detail/CVE-2021-32277
Pick the patch that resolved the issues linked in the nvd reports (same patch fixes both vulnerabilities).
merge to CVE-2021-32274
--- ...frame-length-to-960-and-1024-samples.patch | 87 +++++++++++++++++++ .../recipes-multimedia/faad2/faad2_2.8.8.bb | 1 + 2 files changed, 88 insertions(+) create mode 100644 meta-oe/recipes-multimedia/faad2/faad2/0001-Restrict-SBR-frame-length-to-960-and-1024-samples.patch
meta-oe/recipes-multimedia/faad2/faad2/0001-Restrict-SBR-frame-length-to-960-and-1024-samples.patch new file +87 -0
@@ -0,0 +1,87 @@ +From 9f7515c9571d5c72f6ec2dd6199650093628730b Mon Sep 17 00:00:00 2001 +From: Andrew Wesie <[email protected]> +Date: Mon, 5 Oct 2020 05:47:59 -0500 +Subject: [PATCH] Restrict SBR frame length to 960 and 1024 samples. + +Fixes #59 and #60. + +CVE: CVE-2021-32274 CVE-2021-32277 +Upstream-Status: Backport [https://github.com/knik0/faad2/commit/c78251b2b5d41ea840fd61ab9502b3d3036bd747] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + libfaad/sbr_dec.c | 9 ++++++++- + libfaad/specrec.c | 4 ++++ + libfaad/syntax.c | 7 +++++++ + 3 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/libfaad/sbr_dec.c b/libfaad/sbr_dec.c +index 0705ddd..1a541ef 100644 +--- a/libfaad/sbr_dec.c ++++ b/libfaad/sbr_dec.c +@@ -97,10 +97,17 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, + { + sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960; + sbr->numTimeSlots = NO_TIME_SLOTS_960; +- } else { ++ } ++ else if (framelength == 1024) ++ { + sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS; + sbr->numTimeSlots = NO_TIME_SLOTS; + } ++ else ++ { ++ faad_free(sbr); ++ return NULL; ++ } + + sbr->GQ_ringbuf_index[0] = 0; + sbr->GQ_ringbuf_index[1] = 0; +diff --git a/libfaad/specrec.c b/libfaad/specrec.c +index 9797d6e..d539bbe 100644 +--- a/libfaad/specrec.c ++++ b/libfaad/specrec.c +@@ -1053,6 +1053,8 @@ uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics, + #endif + ); + } ++ if (!hDecoder->sbr[ele]) ++ return 19; + + if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) + hDecoder->sbr[ele]->maxAACLine = 8*min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)], sce->ics1.swb_offset_max); +@@ -1305,6 +1307,8 @@ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_s + #endif + ); + } ++ if (!hDecoder->sbr[ele]) ++ return 19; + + if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) + hDecoder->sbr[ele]->maxAACLine = 8*min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)], cpe->ics1.swb_offset_max); +diff --git a/libfaad/syntax.c b/libfaad/syntax.c +index f8e808c..462ba9e 100644 +--- a/libfaad/syntax.c ++++ b/libfaad/syntax.c +@@ -1079,6 +1079,8 @@ static uint8_t fill_element(NeAACDecStruct *hDecoder, bitfile *ld, drc_info *drc + #endif + ); + } ++ if (!hDecoder->sbr[sbr_ele]) ++ return 19; + + hDecoder->sbr_present_flag = 1; + +@@ -1348,6 +1350,11 @@ void DRM_aac_scalable_main_element(NeAACDecStruct *hDecoder, NeAACDecFrameInfo * + hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0], + 2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1); + } ++ if (!hDecoder->sbr[0]) ++ { ++ hInfo->error = 19; ++ return; ++ } + + /* Reverse bit reading of SBR data in DRM audio frame */ + revbuffer = (uint8_t*)faad_malloc(buffer_size*sizeof(uint8_t));
meta-oe/recipes-multimedia/faad2/faad2_2.8.8.bb +1 -0
@@ -10,6 +10,7 @@ LICENSE_FLAGS = "commercial" SRC_URI = "${SOURCEFORGE_MIRROR}/faac/faad2-src/faad2-2.8.0/${BP}.tar.gz \ file://0001-fix-heap-buffer-overflow-in-mp4read.c.patch \ file://0001-mp4read.c-fix-stack-buffer-overflow-in-stringin-ftyp.patch \ + file://0001-Restrict-SBR-frame-length-to-960-and-1024-samples.patch \ " SRC_URI[md5sum] = "28f6116efdbe9378269f8a6221767d1f" SRC_URI[sha256sum] = "985c3fadb9789d2815e50f4ff714511c79c2710ac27a4aaaf5c0c2662141426d"
PATCH 4/4 faad2: patch CVE-2021-32278
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2021-32278
Pick the patch that is marked to revolve the issue linked in the nvd report.
--- .../0001-Check-return-value-of-ltp_data.patch | 31 +++++++++++++++++++ .../recipes-multimedia/faad2/faad2_2.8.8.bb | 1 + 2 files changed, 32 insertions(+) create mode 100644 meta-oe/recipes-multimedia/faad2/faad2/0001-Check-return-value-of-ltp_data.patch
meta-oe/recipes-multimedia/faad2/faad2/0001-Check-return-value-of-ltp_data.patch new file +31 -0
@@ -0,0 +1,31 @@ +From 4f8a793807d57d6a28aac3ab73ba0992efd5d828 Mon Sep 17 00:00:00 2001 +From: Andrew Wesie <[email protected]> +Date: Mon, 5 Oct 2020 00:33:44 -0500 +Subject: [PATCH] Check return value of ltp_data. + +Fixes #62. + +CVE: CVE-2021-32278 +Upstream-Status: Backport [https://github.com/knik0/faad2/commit/e19a5e491354e0e4664d02b796dacee28fb2521e] + +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + libfaad/syntax.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/libfaad/syntax.c b/libfaad/syntax.c +index 462ba9e..4e57efd 100644 +--- a/libfaad/syntax.c ++++ b/libfaad/syntax.c +@@ -872,7 +872,10 @@ static uint8_t ics_info(NeAACDecStruct *hDecoder, ic_stream *ics, bitfile *ld, + if ((ics->ltp.data_present = faad_get1bit(ld + DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1) + { +- ltp_data(hDecoder, ics, &(ics->ltp), ld); ++ if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0) ++ { ++ return retval; ++ } + } + } + #endif
meta-oe/recipes-multimedia/faad2/faad2_2.8.8.bb +1 -0
@@ -11,6 +11,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/faac/faad2-src/faad2-2.8.0/${BP}.tar.gz \ file://0001-fix-heap-buffer-overflow-in-mp4read.c.patch \ file://0001-mp4read.c-fix-stack-buffer-overflow-in-stringin-ftyp.patch \ file://0001-Restrict-SBR-frame-length-to-960-and-1024-samples.patch \ + file://0001-Check-return-value-of-ltp_data.patch \ " SRC_URI[md5sum] = "28f6116efdbe9378269f8a6221767d1f" SRC_URI[sha256sum] = "985c3fadb9789d2815e50f4ff714511c79c2710ac27a4aaaf5c0c2662141426d"