diff mbox series

[4/6] libexif: backport fixes for CVE-2026-40385/CVE-2026-40386/CVE-2026-32775

Message ID 20260414155652.1214302-4-ross.burton@arm.com
State New
Headers show
Series [1/6] graphene: ignore CVE-2024-1984 | expand

Commit Message

Ross Burton April 14, 2026, 3:56 p.m. UTC
Backport the fixes for these three CVEs from upstream.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../0001-check-maxlen-to-be-at-least-1.patch  | 74 +++++++++++++++++++
 ...-fixed-2-unsigned-integer-underflows.patch | 46 ++++++++++++
 ...n-32bit-system-when-reading-Nikon-Ma.patch | 36 +++++++++
 .../recipes-support/libexif/libexif_0.6.25.bb |  3 +
 4 files changed, 159 insertions(+)
 create mode 100644 meta/recipes-support/libexif/libexif/0001-check-maxlen-to-be-at-least-1.patch
 create mode 100644 meta/recipes-support/libexif/libexif/0002-fixed-2-unsigned-integer-underflows.patch
 create mode 100644 meta/recipes-support/libexif/libexif/0003-Avoid-overflow-on-32bit-system-when-reading-Nikon-Ma.patch
diff mbox series

Patch

diff --git a/meta/recipes-support/libexif/libexif/0001-check-maxlen-to-be-at-least-1.patch b/meta/recipes-support/libexif/libexif/0001-check-maxlen-to-be-at-least-1.patch
new file mode 100644
index 00000000000..e5b7eb14b5b
--- /dev/null
+++ b/meta/recipes-support/libexif/libexif/0001-check-maxlen-to-be-at-least-1.patch
@@ -0,0 +1,74 @@ 
+From 2d12cc141c4d799cea2b42639645db5142940ff7 Mon Sep 17 00:00:00 2001
+From: Marcus Meissner <marcus@jet.franken.de>
+Date: Mon, 9 Mar 2026 10:02:53 +0100
+Subject: [PATCH 1/3] check maxlen to be at least 1
+
+maxlen-- on 0 will become a high value.
+
+(likely found by AI)
+
+Fixes https://github.com/libexif/libexif/issues/247
+
+CVE: CVE-2026-32775
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ libexif/canon/mnote-canon-entry.c     | 2 ++
+ libexif/fuji/mnote-fuji-entry.c       | 1 +
+ libexif/olympus/mnote-olympus-entry.c | 2 ++
+ libexif/pentax/mnote-pentax-entry.c   | 1 +
+ 5 files changed, 8 insertions(+)
+
+diff --git a/libexif/canon/mnote-canon-entry.c b/libexif/canon/mnote-canon-entry.c
+index de0fac4..2849d5b 100644
+--- a/libexif/canon/mnote-canon-entry.c
++++ b/libexif/canon/mnote-canon-entry.c
+@@ -561,6 +561,8 @@ mnote_canon_entry_get_value (const MnoteCanonEntry *entry, unsigned int t, char
+ 
+ 	if (!entry) 
+ 		return NULL;
++	if (maxlen < 1)
++		return NULL;
+ 
+ 	data = entry->data;
+ 	size = entry->size;
+diff --git a/libexif/fuji/mnote-fuji-entry.c b/libexif/fuji/mnote-fuji-entry.c
+index 47e01ed..5d9f16f 100644
+--- a/libexif/fuji/mnote-fuji-entry.c
++++ b/libexif/fuji/mnote-fuji-entry.c
+@@ -201,6 +201,7 @@ mnote_fuji_entry_get_value (MnoteFujiEntry *entry,
+ 	int i, j;
+ 
+ 	if (!entry) return (NULL);
++	if (maxlen < 1) return NULL;
+ 
+ 	memset (val, 0, maxlen);
+ 	maxlen--;
+diff --git a/libexif/olympus/mnote-olympus-entry.c b/libexif/olympus/mnote-olympus-entry.c
+index e5200be..f938d40 100644
+--- a/libexif/olympus/mnote-olympus-entry.c
++++ b/libexif/olympus/mnote-olympus-entry.c
+@@ -286,6 +286,8 @@ mnote_olympus_entry_get_value (MnoteOlympusEntry *entry, char *v, unsigned int m
+ 
+ 	if (!entry)
+ 		return (NULL);
++	if (maxlen < 1)
++		return NULL;
+ 
+ 	memset (v, 0, maxlen);
+ 	maxlen--;
+diff --git a/libexif/pentax/mnote-pentax-entry.c b/libexif/pentax/mnote-pentax-entry.c
+index 46900c3..0a6f87a 100644
+--- a/libexif/pentax/mnote-pentax-entry.c
++++ b/libexif/pentax/mnote-pentax-entry.c
+@@ -317,6 +317,7 @@ mnote_pentax_entry_get_value (MnotePentaxEntry *entry,
+ 	int i = 0, j = 0;
+ 
+ 	if (!entry) return (NULL);
++	if (maxlen < 1) return (NULL);
+ 
+ 	memset (val, 0, maxlen);
+ 	maxlen--;
+-- 
+2.43.0
+
diff --git a/meta/recipes-support/libexif/libexif/0002-fixed-2-unsigned-integer-underflows.patch b/meta/recipes-support/libexif/libexif/0002-fixed-2-unsigned-integer-underflows.patch
new file mode 100644
index 00000000000..2879d488f61
--- /dev/null
+++ b/meta/recipes-support/libexif/libexif/0002-fixed-2-unsigned-integer-underflows.patch
@@ -0,0 +1,46 @@ 
+From ef8d6041d567bcf2b7f466b1bad470689fb4d159 Mon Sep 17 00:00:00 2001
+From: Marcus Meissner <meissner@suse.de>
+Date: Thu, 2 Apr 2026 13:26:31 +0200
+Subject: [PATCH 2/3] fixed 2 unsigned integer underflows
+
+this could cause crashes or data leaks.
+
+Reported-by: Kerwin <kerwinxia66001@gmail.com>
+
+CVE: CVE-2026-40386
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ libexif/fuji/exif-mnote-data-fuji.c       | 2 +-
+ libexif/olympus/exif-mnote-data-olympus.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libexif/fuji/exif-mnote-data-fuji.c b/libexif/fuji/exif-mnote-data-fuji.c
+index c28c541..2dcb877 100644
+--- a/libexif/fuji/exif-mnote-data-fuji.c
++++ b/libexif/fuji/exif-mnote-data-fuji.c
+@@ -70,7 +70,7 @@ exif_mnote_data_fuji_get_value (ExifMnoteData *d, unsigned int i, char *val, uns
+ 	ExifMnoteDataFuji *n = (ExifMnoteDataFuji *) d;
+ 
+ 	if (!d || !val) return NULL;
+-	if (i > n->count -1) return NULL;
++	if (i >= n->count) return NULL;
+ /*
+ 	exif_log (d->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataFuji",
+ 		  "Querying value for tag '%s'...",
+diff --git a/libexif/olympus/exif-mnote-data-olympus.c b/libexif/olympus/exif-mnote-data-olympus.c
+index a57af17..428f365 100644
+--- a/libexif/olympus/exif-mnote-data-olympus.c
++++ b/libexif/olympus/exif-mnote-data-olympus.c
+@@ -78,7 +78,7 @@ exif_mnote_data_olympus_get_value (ExifMnoteData *d, unsigned int i, char *val,
+ 	ExifMnoteDataOlympus *n = (ExifMnoteDataOlympus *) d;
+ 
+ 	if (!d || !val) return NULL;
+-	if (i > n->count -1) return NULL;
++	if (i >= n->count) return NULL;
+ /*
+ 	exif_log (d->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus",
+ 		  "Querying value for tag '%s'...",
+-- 
+2.43.0
+
diff --git a/meta/recipes-support/libexif/libexif/0003-Avoid-overflow-on-32bit-system-when-reading-Nikon-Ma.patch b/meta/recipes-support/libexif/libexif/0003-Avoid-overflow-on-32bit-system-when-reading-Nikon-Ma.patch
new file mode 100644
index 00000000000..e1f9d12a7cc
--- /dev/null
+++ b/meta/recipes-support/libexif/libexif/0003-Avoid-overflow-on-32bit-system-when-reading-Nikon-Ma.patch
@@ -0,0 +1,36 @@ 
+From 62f657ab2b01ede7ab85adbdec333c81176518e9 Mon Sep 17 00:00:00 2001
+From: Marcus Meissner <meissner@suse.de>
+Date: Fri, 3 Apr 2026 11:18:47 +0200
+Subject: [PATCH 3/3] Avoid overflow on 32bit system when reading Nikon
+ MakerNotes
+
+The addition o2 = datao + exif_get_long(buf + o2, n->order)
+could have overflowed on systems with 32bit unsigned int size_t.
+
+This could have caused out of bound reads of data, leading to
+misparsing of exif / crashes.
+
+Reported-By: Kerwin <kerwinxia66001@gmail.com>
+
+CVE: CVE-2026-40385
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ libexif/olympus/exif-mnote-data-olympus.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libexif/olympus/exif-mnote-data-olympus.c b/libexif/olympus/exif-mnote-data-olympus.c
+index 428f365..37f08ff 100644
+--- a/libexif/olympus/exif-mnote-data-olympus.c
++++ b/libexif/olympus/exif-mnote-data-olympus.c
+@@ -386,6 +386,7 @@ exif_mnote_data_olympus_load (ExifMnoteData *en,
+ 		o2 += 2;
+ 
+ 		/* Go to where the number of entries is. */
++		if (CHECKOVERFLOW(o2,buf_size,exif_get_long (buf + o2, n->order))) return;
+ 		o2 = datao + exif_get_long (buf + o2, n->order);
+ 		break;
+ 
+-- 
+2.43.0
+
diff --git a/meta/recipes-support/libexif/libexif_0.6.25.bb b/meta/recipes-support/libexif/libexif_0.6.25.bb
index c57855303f4..d869f8c6c3b 100644
--- a/meta/recipes-support/libexif/libexif_0.6.25.bb
+++ b/meta/recipes-support/libexif/libexif_0.6.25.bb
@@ -9,6 +9,9 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=243b725d71bb5df4a1e5920b344b86ad"
 
 SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/libexif-${PV}.tar.bz2 \
            file://0001-Add-serial-tests-config-needed-by-ptest.patch \
+           file://0001-check-maxlen-to-be-at-least-1.patch \
+           file://0002-fixed-2-unsigned-integer-underflows.patch \
+           file://0003-Avoid-overflow-on-32bit-system-when-reading-Nikon-Ma.patch \
            file://run-ptest \
            "