summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2022-01-06 17:35:13 +0100
committerMark Wielaard <mark@klomp.org>2022-01-06 17:36:52 +0100
commit90b1b14a9a7e659cf5665855ae07da424e5cbd96 (patch)
tree7be2b0e3cf1a693e0afaf8b221441643533ef15a /libdwfl
parentlibdwfl: Fix overflow check in link_map.c read_addrs (diff)
downloadelfutils-90b1b14a9a7e659cf5665855ae07da424e5cbd96.tar.gz
elfutils-90b1b14a9a7e659cf5665855ae07da424e5cbd96.tar.bz2
elfutils-90b1b14a9a7e659cf5665855ae07da424e5cbd96.tar.xz
libdwfl: Handle unaligned Dyns in dwfl_segment_report_module
The xlate functions only handle correctly aligned buffers. But they do handle src == dest. So if the source buffer isn't aligned correctly just copy it first into the destination (which is already correctly aligned). https://sourceware.org/bugzilla/show_bug.cgi?id=28720 Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/dwfl_segment_report_module.c12
2 files changed, 17 insertions, 0 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index f8319f44..aace969f 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,10 @@
12022-01-03 Mark Wielaard <mark@klomp.org> 12022-01-03 Mark Wielaard <mark@klomp.org>
2 2
3 * dwfl_segment_report_module.c (dwfl_segment_report_module): Copy
4 dyn_data and set xlatefrom.d_buf to dyns when dyns is not aligned.
5
62022-01-03 Mark Wielaard <mark@klomp.org>
7
3 * link_map.c (read_addrs): Fix buffer_available nb overflow. 8 * link_map.c (read_addrs): Fix buffer_available nb overflow.
4 9
52021-12-23 Mark Wielaard <mark@klomp.org> 102021-12-23 Mark Wielaard <mark@klomp.org>
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c
index 5bef249e..1461ae26 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -844,7 +844,19 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
844 xlateto.d_buf = dyns; 844 xlateto.d_buf = dyns;
845 xlateto.d_size = dyn_filesz; 845 xlateto.d_size = dyn_filesz;
846 846
847 /* dyn_data may be unaligned, in which case xlatetom would not work.
848 xlatetom does work when the in and out d_buf are equal (but not
849 for any other overlap). */
847 bool is32 = (ei_class == ELFCLASS32); 850 bool is32 = (ei_class == ELFCLASS32);
851 size_t dyn_align = (is32
852 ? __alignof__ (Elf32_Dyn)
853 : __alignof__ (Elf64_Dyn));
854 if (((uintptr_t) dyn_data & (dyn_align - 1)) != 0)
855 {
856 memcpy (dyns, dyn_data, dyn_filesz);
857 xlatefrom.d_buf = dyns;
858 }
859
848 if ((is32 && elf32_xlatetom (&xlateto, &xlatefrom, ei_data) != NULL) 860 if ((is32 && elf32_xlatetom (&xlateto, &xlatefrom, ei_data) != NULL)
849 || (!is32 && elf64_xlatetom (&xlateto, &xlatefrom, ei_data) != NULL)) 861 || (!is32 && elf64_xlatetom (&xlateto, &xlatefrom, ei_data) != NULL))
850 { 862 {