summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorMatthias Maennich <maennich@google.com>2021-11-18 19:44:50 +0000
committerMark Wielaard <mark@klomp.org>2021-11-20 01:05:11 +0100
commit2e3bc18672f0cede0332ae3194eb2e33d4cc5fd7 (patch)
tree5fc3768eedb8ffa01d33c5250bc44d9c860fa5e4 /libdwfl
parenttests: Don't set DEBUGINFOD_TIMEOUT (diff)
downloadelfutils-2e3bc18672f0cede0332ae3194eb2e33d4cc5fd7.tar.gz
elfutils-2e3bc18672f0cede0332ae3194eb2e33d4cc5fd7.tar.bz2
elfutils-2e3bc18672f0cede0332ae3194eb2e33d4cc5fd7.tar.xz
dwfl: fix potential overflow when reporting on kernel modules
dwfl_linux_kernel_report_modules_ has an outstanding ancient bug when reading kernel module information from a modules list file. The target buffer for the module name was sized too small to hold potential values. Fix that by increasing the value to account for the null termination. In practice, this unlikely ever happened, but it now got diagnosed by LLVM as part of a stricter -Wfortify-source implementation [1]: libdwfl/linux-kernel-modules.c:1019:7: error: 'sscanf' may overflow; destination buffer in argument 3 has size 128, but the corresponding specifier may require size 129 [-Werror,-Wfortify-source] modname, &modsz, &modaddr) == 3) [1] https://github.com/llvm/llvm-project/commit/2db66f8d48beeea835cb9a6940e25bc04ab5d941 Suggested-by: Paul Pluzhnikov <ppluzhnikov@google.com> Signed-off-by: Matthias Maennich <maennich@google.com>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/linux-kernel-modules.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index f7e24a21..57b2c494 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
12021-11-18 Matthias Maennich <maennich@google.com>
2
3 * linux-kernel-modules.c (dwfl_linux_kernel_report_modules):
4 Add one to modname array size.
5
12021-02-14 Alexander Miller <alex.miller@gmx.de> 62021-02-14 Alexander Miller <alex.miller@gmx.de>
2 7
3 * core-file.c (dwfl_core_file_report): Move NEW_VERSION before 8 * core-file.c (dwfl_core_file_report): Move NEW_VERSION before
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index c0f8dfa4..58c0c417 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -1008,7 +1008,7 @@ dwfl_linux_kernel_report_modules (Dwfl *dwfl)
1008 int result = 0; 1008 int result = 0;
1009 Dwarf_Addr modaddr; 1009 Dwarf_Addr modaddr;
1010 unsigned long int modsz; 1010 unsigned long int modsz;
1011 char modname[128]; 1011 char modname[128+1];
1012 char *line = NULL; 1012 char *line = NULL;
1013 size_t linesz = 0; 1013 size_t linesz = 0;
1014 /* We can't just use fscanf here because it's not easy to distinguish \n 1014 /* We can't just use fscanf here because it's not easy to distinguish \n