libraw: patch CVE-2025-43961 CVE-2025-43962
PATCH 1/3 libraw: patch CVE-2025-43961 CVE-2025-43962
Details
- https://nvd.nist.gov/vuln/detail/CVE-2025-43961
- https://nvd.nist.gov/vuln/detail/CVE-2025-43962
Signed-off-by Ankur Tyagi <[email protected]>
--- .../0001-CVE-2025-43961-CVE-2025-43962.patch | 108 ++++++++++++++++++ .../recipes-support/libraw/libraw_0.21.2.bb | 5 +- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-support/libraw/libraw/0001-CVE-2025-43961-CVE-2025-43962.patch
meta-oe/recipes-support/libraw/libraw/0001-CVE-2025-43961-CVE-2025-43962.patch new file +108 -0
@@ -0,0 +1,108 @@ +From 880829f7ed206c21ce05d5772f0928629c7dd577 Mon Sep 17 00:00:00 2001 +From: Alex Tutubalin <[email protected]> +Date: Sat, 1 Feb 2025 15:32:39 +0300 +Subject: [PATCH] CVE-2025-43961 CVE-2025-43962 + +Prevent out-of-bounds read in fuji 0xf00c tag parser + +prevent OOB reads in phase_one_correct + +CVE: CVE-2025-43961 CVE-2025-43962 +Upstream-Status: Backport [https://github.com/LibRaw/LibRaw/commit/66fe663e02a4dd610b4e832f5d9af326709336c2] + +(cherry picked from commit 66fe663e02a4dd610b4e832f5d9af326709336c2) +Signed-off-by: Ankur Tyagi <[email protected]> +--- + src/decoders/load_mfbacks.cpp | 18 ++++++++++++++---- + src/metadata/tiff.cpp | 28 +++++++++++++++++----------- + 2 files changed, 31 insertions(+), 15 deletions(-) + +diff --git a/src/decoders/load_mfbacks.cpp b/src/decoders/load_mfbacks.cpp +index cddc33eb..1a1bdfb3 100644 +--- a/src/decoders/load_mfbacks.cpp ++++ b/src/decoders/load_mfbacks.cpp +@@ -490,6 +490,9 @@ int LibRaw::phase_one_correct() + fseek(ifp, off_412, SEEK_SET); + for (i = 0; i < 9; i++) + head[i] = get4() & 0x7fff; ++ unsigned w0 = head[1] * head[3], w1 = head[2] * head[4]; ++ if (w0 > 10240000 || w1 > 10240000) ++ throw LIBRAW_EXCEPTION_ALLOC; + yval[0] = (float *)calloc(head[1] * head[3] + head[2] * head[4], 6); + yval[1] = (float *)(yval[0] + head[1] * head[3]); + xval[0] = (ushort *)(yval[1] + head[2] * head[4]); +@@ -514,10 +517,17 @@ int LibRaw::phase_one_correct() + for (k = j = 0; j < head[1]; j++) + if (num < xval[0][k = head[1] * i + j]) + break; +- frac = (j == 0 || j == head[1]) +- ? 0 +- : (xval[0][k] - num) / (xval[0][k] - xval[0][k - 1]); +- mult[i - cip] = yval[0][k - 1] * frac + yval[0][k] * (1 - frac); ++ if (j == 0 || j == head[1] || k < 1 || k >= w0+w1) ++ frac = 0; ++ else ++ { ++ int xdiv = (xval[0][k] - xval[0][k - 1]); ++ frac = xdiv ? (xval[0][k] - num) / (xval[0][k] - xval[0][k - 1]) : 0; ++ } ++ if (k < w0 + w1) ++ mult[i - cip] = yval[0][k > 0 ? k - 1 : 0] * frac + yval[0][k] * (1 - frac); ++ else ++ mult[i - cip] = 0; + } + i = ((mult[0] * (1 - cfrac) + mult[1] * cfrac) * row + num) * 2; + RAW(row, col) = LIM(i, 0, 65535); +diff --git a/src/metadata/tiff.cpp b/src/metadata/tiff.cpp +index c34b8647..af664937 100644 +--- a/src/metadata/tiff.cpp ++++ b/src/metadata/tiff.cpp +@@ -1032,31 +1032,37 @@ int LibRaw::parse_tiff_ifd(int base) + if ((fwb[0] == rafdata[fi]) && (fwb[1] == rafdata[fi + 1]) && + (fwb[2] == rafdata[fi + 2])) // found Tungsten WB + { +- if (rafdata[fi - 15] != ++ if (fi > 14 && rafdata[fi - 15] != + fwb[0]) // 15 is offset of Tungsten WB from the first + // preset, Fine Weather WB + continue; +- for (int wb_ind = 0, ofst = fi - 15; wb_ind < (int)Fuji_wb_list1.size(); +- wb_ind++, ofst += 3) +- { +- icWBC[Fuji_wb_list1[wb_ind]][1] = +- icWBC[Fuji_wb_list1[wb_ind]][3] = rafdata[ofst]; +- icWBC[Fuji_wb_list1[wb_ind]][0] = rafdata[ofst + 1]; +- icWBC[Fuji_wb_list1[wb_ind]][2] = rafdata[ofst + 2]; +- } ++ if (fi >= 15) ++ { ++ for (int wb_ind = 0, ofst = fi - 15; wb_ind < (int)Fuji_wb_list1.size(); ++ wb_ind++, ofst += 3) ++ { ++ icWBC[Fuji_wb_list1[wb_ind]][1] = ++ icWBC[Fuji_wb_list1[wb_ind]][3] = rafdata[ofst]; ++ icWBC[Fuji_wb_list1[wb_ind]][0] = rafdata[ofst + 1]; ++ icWBC[Fuji_wb_list1[wb_ind]][2] = rafdata[ofst + 2]; ++ } ++ } + + if (is34) + fi += 24; + fi += 96; + for (fj = fi; fj < (fi + 15); fj += 3) // looking for the end of the WB table + { ++ if (fj > libraw_internal_data.unpacker_data.lenRAFData - 3) ++ break; + if (rafdata[fj] != rafdata[fi]) + { + fj -= 93; + if (is34) + fj -= 9; +-// printf ("wb start in DNG: 0x%04x\n", fj*2-0x4e); +- for (int iCCT = 0, ofst = fj; iCCT < 31; ++//printf ("wb start in DNG: 0x%04x\n", fj*2-0x4e); ++ for (int iCCT = 0, ofst = fj; iCCT < 31 ++ && ofst < libraw_internal_data.unpacker_data.lenRAFData - 3; + iCCT++, ofst += 3) + { + icWBCCTC[iCCT][0] = FujiCCT_K[iCCT];
meta-oe/recipes-support/libraw/libraw_0.21.2.bb +4 -1
@@ -2,7 +2,10 @@ SUMMARY = "raw image decoder" LICENSE = "LGPL-2.1-only | CDDL-1.0" LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=1501ae0aa3c8544e63f08d6f7bf88a6f" -SRC_URI = "git://github.com/LibRaw/LibRaw.git;branch=0.21-stable;protocol=https" +SRC_URI = " \ + git://github.com/LibRaw/LibRaw.git;branch=0.21-stable;protocol=https \ + file://0001-CVE-2025-43961-CVE-2025-43962.patch \ +" SRCREV = "1ef70158d7fde1ced6aaddb0b9443c32a7121d3d" S = "${WORKDIR}/git"
PATCH 2/3 libraw: patch CVE-2025-43963
Details https://nvd.nist.gov/vuln/detail/CVE-2025-43963
Signed-off-by Ankur Tyagi <[email protected]>
--- .../libraw/libraw/0002-CVE-2025-43963.patch | 40 +++++++++++++++++++ .../recipes-support/libraw/libraw_0.21.2.bb | 1 + 2 files changed, 41 insertions(+) create mode 100644 meta-oe/recipes-support/libraw/libraw/0002-CVE-2025-43963.patch
meta-oe/recipes-support/libraw/libraw/0002-CVE-2025-43963.patch new file +40 -0
@@ -0,0 +1,40 @@ +From 975393c804bc321fd4bc709c3c221733dac2d80a Mon Sep 17 00:00:00 2001 +From: Alex Tutubalin <[email protected]> +Date: Thu, 6 Feb 2025 21:01:58 +0300 +Subject: [PATCH] CVE-2025-43963 + +check split_col/split_row values in phase_one_correct + +CVE: CVE-2025-43963 +Upstream-Status: Backport [https://github.com/LibRaw/LibRaw/commit/be26e7639ecf8beb55f124ce780e99842de2e964] + +(cherry picked from commit be26e7639ecf8beb55f124ce780e99842de2e964) +Signed-off-by: Ankur Tyagi <[email protected]> +--- + src/decoders/load_mfbacks.cpp | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/decoders/load_mfbacks.cpp b/src/decoders/load_mfbacks.cpp +index 1a1bdfb3..f89aecce 100644 +--- a/src/decoders/load_mfbacks.cpp ++++ b/src/decoders/load_mfbacks.cpp +@@ -348,7 +348,8 @@ int LibRaw::phase_one_correct() + off_412 = ftell(ifp) - 38; + } + } +- else if (tag == 0x041f && !qlin_applied) ++ else if (tag == 0x041f && !qlin_applied && ph1.split_col > 0 && ph1.split_col < raw_width ++ && ph1.split_row > 0 && ph1.split_row < raw_height) + { /* Quadrant linearization */ + ushort lc[2][2][16], ref[16]; + int qr, qc; +@@ -432,7 +433,8 @@ int LibRaw::phase_one_correct() + } + qmult_applied = 1; + } +- else if (tag == 0x0431 && !qmult_applied) ++ else if (tag == 0x0431 && !qmult_applied && ph1.split_col > 0 && ph1.split_col < raw_width ++ && ph1.split_row > 0 && ph1.split_row < raw_height) + { /* Quadrant combined - four tile gain calibration */ + ushort lc[2][2][7], ref[7]; + int qr, qc;
meta-oe/recipes-support/libraw/libraw_0.21.2.bb +1 -0
@@ -5,6 +5,7 @@ LIC_FILES_CHKSUM = "file://COPYRIGHT;md5=1501ae0aa3c8544e63f08d6f7bf88a6f" SRC_URI = " \ git://github.com/LibRaw/LibRaw.git;branch=0.21-stable;protocol=https \ file://0001-CVE-2025-43961-CVE-2025-43962.patch \ + file://0002-CVE-2025-43963.patch \ " SRCREV = "1ef70158d7fde1ced6aaddb0b9443c32a7121d3d" S = "${WORKDIR}/git"
PATCH 3/3 libraw: patch CVE-2025-43964
In reply to Ankur TyagiDetails https://nvd.nist.gov/vuln/detail/CVE-2025-43964
Signed-off-by Ankur Tyagi <[email protected]>
--- .../libraw/libraw/0003-CVE-2025-43964.patch | 29 +++++++++++++++++++ .../recipes-support/libraw/libraw_0.21.2.bb | 1 + 2 files changed, 30 insertions(+) create mode 100644 meta-oe/recipes-support/libraw/libraw/0003-CVE-2025-43964.patch
meta-oe/recipes-support/libraw/libraw/0003-CVE-2025-43964.patch new file +29 -0
@@ -0,0 +1,29 @@ +From 0ecd9906f70114a974809bb35b4ec9fe7fed9011 Mon Sep 17 00:00:00 2001 +From: Alex Tutubalin <[email protected]> +Date: Sun, 2 Mar 2025 11:35:43 +0300 +Subject: [PATCH] CVE-2025-43964 + +additional checks in PhaseOne correction tag 0x412 processing + +CVE: CVE-2025-43964 +Upstream-Status: Backport [https://github.com/LibRaw/LibRaw/commit/a50dc3f1127d2e37a9b39f57ad9bb2ebb60f18c0] + +(cherry picked from commit a50dc3f1127d2e37a9b39f57ad9bb2ebb60f18c0) +Signed-off-by: Ankur Tyagi <[email protected]> +--- + src/decoders/load_mfbacks.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/decoders/load_mfbacks.cpp b/src/decoders/load_mfbacks.cpp +index f89aecce..95015d27 100644 +--- a/src/decoders/load_mfbacks.cpp ++++ b/src/decoders/load_mfbacks.cpp +@@ -495,6 +495,8 @@ int LibRaw::phase_one_correct() + unsigned w0 = head[1] * head[3], w1 = head[2] * head[4]; + if (w0 > 10240000 || w1 > 10240000) + throw LIBRAW_EXCEPTION_ALLOC; ++ if (w0 < 1 || w1 < 1) ++ throw LIBRAW_EXCEPTION_IO_CORRUPT; + yval[0] = (float *)calloc(head[1] * head[3] + head[2] * head[4], 6); + yval[1] = (float *)(yval[0] + head[1] * head[3]); + xval[0] = (ushort *)(yval[1] + head[2] * head[4]);
meta-oe/recipes-support/libraw/libraw_0.21.2.bb +1 -0
@@ -6,6 +6,7 @@ SRC_URI = " \ git://github.com/LibRaw/LibRaw.git;branch=0.21-stable;protocol=https \ file://0001-CVE-2025-43961-CVE-2025-43962.patch \ file://0002-CVE-2025-43963.patch \ + file://0003-CVE-2025-43964.patch \ " SRCREV = "1ef70158d7fde1ced6aaddb0b9443c32a7121d3d" S = "${WORKDIR}/git"