|
| 1 | +From 1b6211c6fe3e85b4415ae22d7e97467182a5bdc4 Mon Sep 17 00:00:00 2001 |
| 2 | +From: dj_palli <v-dpalli@microsoft.com> |
| 3 | +Date: Wed, 28 May 2025 11:13:05 +0000 |
| 4 | +Subject: [PATCH] Address CVE-2025-1352 |
| 5 | + |
| 6 | +Upstream patch URL: https://sourceware.org/cgit/elfutils/commit/?id=2636426a091bd6c6f7f02e49ab20d4cdc6bfc753 |
| 7 | + |
| 8 | +--- |
| 9 | + libdw/dwarf_getabbrev.c | 12 ++++-------- |
| 10 | + libdw/dwarf_offabbrev.c | 10 +++++++--- |
| 11 | + libdw/dwarf_tag.c | 3 +-- |
| 12 | + libdw/libdw.h | 4 +++- |
| 13 | + libdw/libdwP.h | 3 +-- |
| 14 | + 5 files changed, 16 insertions(+), 16 deletions(-) |
| 15 | + |
| 16 | +diff --git a/libdw/dwarf_getabbrev.c b/libdw/dwarf_getabbrev.c |
| 17 | +index 5b02333..d9a6c02 100644 |
| 18 | +--- a/libdw/dwarf_getabbrev.c |
| 19 | ++++ b/libdw/dwarf_getabbrev.c |
| 20 | +@@ -1,5 +1,6 @@ |
| 21 | + /* Get abbreviation at given offset. |
| 22 | + Copyright (C) 2003, 2004, 2005, 2006, 2014, 2017 Red Hat, Inc. |
| 23 | ++ Copyright (C) 2025 Mark J. Wielaard <mark@klomp.org> |
| 24 | + This file is part of elfutils. |
| 25 | + Written by Ulrich Drepper <drepper@redhat.com>, 2003. |
| 26 | + |
| 27 | +@@ -38,7 +39,7 @@ |
| 28 | + Dwarf_Abbrev * |
| 29 | + internal_function |
| 30 | + __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset, |
| 31 | +- size_t *lengthp, Dwarf_Abbrev *result) |
| 32 | ++ size_t *lengthp) |
| 33 | + { |
| 34 | + /* Don't fail if there is not .debug_abbrev section. */ |
| 35 | + if (dbg->sectiondata[IDX_debug_abbrev] == NULL) |
| 36 | +@@ -85,12 +86,7 @@ __libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, Dwarf_Off offset, |
| 37 | + Dwarf_Abbrev *abb = NULL; |
| 38 | + if (cu == NULL |
| 39 | + || (abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code)) == NULL) |
| 40 | +- { |
| 41 | +- if (result == NULL) |
| 42 | +- abb = libdw_typed_alloc (dbg, Dwarf_Abbrev); |
| 43 | +- else |
| 44 | +- abb = result; |
| 45 | +- } |
| 46 | ++ abb = libdw_typed_alloc (dbg, Dwarf_Abbrev); |
| 47 | + else |
| 48 | + { |
| 49 | + foundit = true; |
| 50 | +@@ -183,5 +179,5 @@ dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset, size_t *lengthp) |
| 51 | + return NULL; |
| 52 | + } |
| 53 | + |
| 54 | +- return __libdw_getabbrev (dbg, cu, abbrev_offset + offset, lengthp, NULL); |
| 55 | ++ return __libdw_getabbrev (dbg, cu, abbrev_offset + offset, lengthp); |
| 56 | + } |
| 57 | +diff --git a/libdw/dwarf_offabbrev.c b/libdw/dwarf_offabbrev.c |
| 58 | +index 27cdad6..41df69b 100644 |
| 59 | +--- a/libdw/dwarf_offabbrev.c |
| 60 | ++++ b/libdw/dwarf_offabbrev.c |
| 61 | +@@ -41,11 +41,15 @@ dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp, |
| 62 | + if (dbg == NULL) |
| 63 | + return -1; |
| 64 | + |
| 65 | +- Dwarf_Abbrev *abbrev = __libdw_getabbrev (dbg, NULL, offset, lengthp, |
| 66 | +- abbrevp); |
| 67 | ++ Dwarf_Abbrev *abbrev = __libdw_getabbrev (dbg, NULL, offset, lengthp); |
| 68 | + |
| 69 | + if (abbrev == NULL) |
| 70 | + return -1; |
| 71 | + |
| 72 | +- return abbrev == DWARF_END_ABBREV ? 1 : 0; |
| 73 | ++ if (abbrev == DWARF_END_ABBREV) |
| 74 | ++ return 1; |
| 75 | ++ |
| 76 | ++ *abbrevp = *abbrev; |
| 77 | ++ |
| 78 | ++ return 0; |
| 79 | + } |
| 80 | +diff --git a/libdw/dwarf_tag.c b/libdw/dwarf_tag.c |
| 81 | +index d784970..218382a 100644 |
| 82 | +--- a/libdw/dwarf_tag.c |
| 83 | ++++ b/libdw/dwarf_tag.c |
| 84 | +@@ -53,8 +53,7 @@ __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code) |
| 85 | + |
| 86 | + /* Find the next entry. It gets automatically added to the |
| 87 | + hash table. */ |
| 88 | +- abb = __libdw_getabbrev (cu->dbg, cu, cu->last_abbrev_offset, &length, |
| 89 | +- NULL); |
| 90 | ++ abb = __libdw_getabbrev (cu->dbg, cu, cu->last_abbrev_offset, &length); |
| 91 | + if (abb == NULL || abb == DWARF_END_ABBREV) |
| 92 | + { |
| 93 | + /* Make sure we do not try to search for it again. */ |
| 94 | +diff --git a/libdw/libdw.h b/libdw/libdw.h |
| 95 | +index 64d1689..829cc21 100644 |
| 96 | +--- a/libdw/libdw.h |
| 97 | ++++ b/libdw/libdw.h |
| 98 | +@@ -587,7 +587,9 @@ extern int dwarf_srclang (Dwarf_Die *die); |
| 99 | + extern Dwarf_Abbrev *dwarf_getabbrev (Dwarf_Die *die, Dwarf_Off offset, |
| 100 | + size_t *lengthp); |
| 101 | + |
| 102 | +-/* Get abbreviation at given offset in .debug_abbrev section. */ |
| 103 | ++/* Get abbreviation at given offset in .debug_abbrev section. On |
| 104 | ++ success return zero and fills in ABBREVP. When there is no (more) |
| 105 | ++ abbrev at offset returns one. On error returns a negative value. */ |
| 106 | + extern int dwarf_offabbrev (Dwarf *dbg, Dwarf_Off offset, size_t *lengthp, |
| 107 | + Dwarf_Abbrev *abbrevp) |
| 108 | + __nonnull_attribute__ (4); |
| 109 | +diff --git a/libdw/libdwP.h b/libdw/libdwP.h |
| 110 | +index 5cbdc27..6ea34bd 100644 |
| 111 | +--- a/libdw/libdwP.h |
| 112 | ++++ b/libdw/libdwP.h |
| 113 | +@@ -682,8 +682,7 @@ extern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu, |
| 114 | + |
| 115 | + /* Get abbreviation at given offset. */ |
| 116 | + extern Dwarf_Abbrev *__libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu, |
| 117 | +- Dwarf_Off offset, size_t *lengthp, |
| 118 | +- Dwarf_Abbrev *result) |
| 119 | ++ Dwarf_Off offset, size_t *lengthp) |
| 120 | + __nonnull_attribute__ (1) internal_function; |
| 121 | + |
| 122 | + /* Get abbreviation of given DIE, and optionally set *READP to the DIE memory |
| 123 | +-- |
| 124 | +2.45.2 |
| 125 | + |
0 commit comments