Issue 47421 in oss-fuzz: elfutils:fuzz-libelf: Timeout in fuzz-libelf

2022-07-31 Thread ClusterFuzz-External via monorail via Elfutils-devel
Updates:
Labels: ClusterFuzz-Verified
Status: Verified

Comment #1 on issue 47421 by ClusterFuzz-External: elfutils:fuzz-libelf: 
Timeout in fuzz-libelf
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47421#c1

ClusterFuzz testcase 5573250354118656 is verified as fixed in 
https://oss-fuzz.com/revisions?job=libfuzzer_asan_i386_elfutils&range=202207310603:202207311200

If this is incorrect, please file a bug on 
https://github.com/google/oss-fuzz/issues/new

-- 
You received this message because:
  1. You were specifically CC'd on the issue

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

Reply to this email to add a comment.


[Bug debuginfod/28325] create new debuginfod.service.8 man page

2022-07-31 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28325

Mark Wielaard  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED
 CC||mark at klomp dot org

--- Comment #1 from Mark Wielaard  ---
commit 88c355011a78b5030fefedd10630bc99cecaceb6
Author: Noah Sanci 
Date:   Thu Jun 2 14:26:46 2022 -0400

Added debuginfod.service.8 manual page.

Signed-off-by: Noah Sanci 

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: [PATCH] readelf: Support --dynamic with --use-dynamic

2022-07-31 Thread Mark Wielaard
Hi,

On Tue, May 24, 2022 at 11:53:11PM +0800, Di Chen via Elfutils-devel wrote:
> All the request changes are fixed, ready for review again.
> 
> 1. help message updated: "Use the dynamic segment when possible for
> displaying info"
> 2. move enum dyn_idx to a proper place
> 3. add strtab_data's NULL check in function: handle_dynamic()
> 4. add phdr's NULL check in function: print_dynamic()
> 5. add comments for function: find_offsets()
> 6. remove redundant return-statement in function: get_dynscn_addrs()
> 7. add run-readelf-Dd.sh to EXTRA_DISTS
> 8. check strsz in (dyn->d_un.d_ptr < strtab_data->d_size) in function:
> handle_dynamic()

Sorry the re-review took so long. This looks great. I did add a NEWS
entry and wrote a Changelog entry while re-reviewing. And a few small
whitespace fixups.

The only code change I made was:

-  char *lib_name = NULL;
-
-  if (!use_dynamic_segment)
-lib_name = elf_strptr (ebl->elf, shdr->sh_link, dyn->d_un.d_val);
-  else if (use_dynamic_segment)
-lib_name = ((char *)strtab_data->d_buf) + dyn->d_un.d_ptr;
-  else
-break;
+  char *name = NULL;
+  if (dyn->d_tag == DT_NEEDED
+ || dyn->d_tag == DT_SONAME
+ || dyn->d_tag == DT_RPATH
+ || dyn->d_tag == DT_RUNPATH)
+   {
+ if (! use_dynamic_segment)
+   name = elf_strptr (ebl->elf, shdr->sh_link, dyn->d_un.d_val);
+ else if (dyn->d_un.d_ptr < strtab_data->d_size
+  && memrchr (strtab_data->d_buf + strtab_data->d_size - 1, 
'\0',
+  strtab_data->d_size - 1 - dyn->d_un.d_ptr) != 
NULL)
+   name = ((char *) strtab_data->d_buf) + dyn->d_un.d_ptr;
+   }

That does the check whether dyn->d_un.d_ptr is valid early, so it
doesn't need to be checked in each case statement. Also it adds an
extra memrchr check to make sure the string is zero terminated.

Pushed with those changes.

Thanks,

Mark

>From 369c021c6eedae3665c1dbbaa4fc43afbbb698f4 Mon Sep 17 00:00:00 2001
From: Di Chen 
Date: Thu, 28 Apr 2022 19:55:33 +0800
Subject: [PATCH] readelf: Support --dynamic with --use-dynamic

Currently, eu-readelf is using section headers to dump the dynamic
segment information (print_dynamic -> handle_dynamic).

This patch adds new options to eu-readelf (-D, --use-dynamic)
for (-d, --dynamic).

https://sourceware.org/bugzilla/show_bug.cgi?id=28873

Signed-off-by: Di Chen 
---
 ChangeLog   |   4 +
 NEWS|   2 +
 src/ChangeLog   |  13 +++
 src/readelf.c   | 212 +++-
 tests/ChangeLog |   6 ++
 tests/Makefile.am   |   4 +-
 tests/run-readelf-Dd.sh |  66 +
 7 files changed, 280 insertions(+), 27 deletions(-)
 create mode 100755 tests/run-readelf-Dd.sh

diff --git a/ChangeLog b/ChangeLog
index 0ececcc9..5421f5b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-04-28  Di Chen  
+
+	* NEWS: Add readefl -D, --use-dynamic.
+
 2022-07-28  Di Chen  
 
 	* NEWS: Add dwfl_frame_reg.
diff --git a/NEWS b/NEWS
index 82c86cb6..156f78df 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 Version 0.188 some time after 0.187
 
+readelf: Add -D, --use-dynamic option.
+
 debuginfod: Add --disable-source-scan option.
 
 libdwfl: Add new function dwfl_get_debuginfod_client.
diff --git a/src/ChangeLog b/src/ChangeLog
index 8c9f5ddd..db20a6ef 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
+2022-04-28  Di Chen  
+
+	* readelf.c (options): Add use-dynamic 'D'.
+	(use_dynamic_segment): New static bool.
+	(enum dyn_idx): New.
+	(get_dynscn_strtab): New function.
+	(get_dynscn_addrs): Likewise.
+	(find_offsets): Likewise.
+	(parse_opt): Handle 'D'.
+	(handle_dynamic): New argument phdr. Get data either through the shdr
+	or phdr.  Print segment info when use_dynamic_segment. Use
+	get_dynscn_strtab. Get library name and paths through strtab_data.
+
 2022-05-09  Mark Wielaard  
 
 	* strip.c (remove_debug_relocations): Check gelf_getshdr, gelf_getrela,
diff --git a/src/readelf.c b/src/readelf.c
index 4b6aab2b..f4d973da 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -137,6 +137,8 @@ static const struct argp_option options[] =
   { "string-dump", 'p', NULL, OPTION_ALIAS | OPTION_HIDDEN, NULL, 0 },
   { "archive-index", 'c', NULL, 0,
 N_("Display the symbol index of an archive"), 0 },
+  { "use-dynamic", 'D', NULL, 0,
+N_("Use the dynamic segment when possible for displaying info"), 0 },
 
   { NULL, 0, NULL, 0, N_("Output control:"), 0 },
   { "numeric-addresses", 'N', NULL, 0,
@@ -195,6 +197,9 @@ static bool print_symbol_table;
 /* True if (only) the dynsym table should be printed.  */
 static bool print_dynsym_table;
 
+/* True if reconstruct dynamic symbol table from the PT_DYNAMIC segment.  */
+static bool use_dynamic_segment;
+
 /* A specific section name, or NULL to print all symbol tables.  */
 static char *symbol_table_section;
 
@@ -318,6 +323,24 @@ static void dump_strings (Ebl *ebl);
 stati

☠ Buildbot (GNU Toolchain): elfutils - failed test (failure) (master)

2022-07-31 Thread builder--- via Elfutils-devel
A new failure has been detected on builder elfutils-fedora-s390x while building 
elfutils.

Full details are available at:
https://builder.sourceware.org/buildbot/#builders/43/builds/47

Build state: failed test (failure)
Revision: 369c021c6eedae3665c1dbbaa4fc43afbbb698f4
Worker: fedora-s390x
Build Reason: (unknown)
Blamelist: Di Chen 

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/2/logs/stdio

- 3: autoreconf ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/3/logs/stdio

- 4: configure ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/4/logs/stdio

- 5: get version ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/5/logs/stdio
- property changes: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/5/logs/property_changes

- 6: make ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/6/logs/stdio
- warnings (3): 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/6/logs/warnings__3_

- 7: make check ( failure )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/7/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/7/logs/test-suite_log

- 8: prep ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/8/logs/stdio

- 9: build bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/9/logs/stdio

- 10: fetch bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/10/logs/stdio

- 11: unpack bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/11/logs/stdio

- 12: pass .bunsen.source.gitname ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/12/logs/stdio

- 13: pass .bunsen.source.gitbranch ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/13/logs/stdio

- 14: pass .bunsen.source.gitrepo ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/14/logs/stdio

- 15: upload to bunsen ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/15/logs/stdio

- 16: clean up ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/16/logs/stdio

- 17: make clean ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/17/logs/stdio



Re: ☠ Buildbot (GNU Toolchain): elfutils - failed test (failure) (master)

2022-07-31 Thread Mark Wielaard
On Sun, Jul 31, 2022 at 11:54:33PM +, builder--- via Elfutils-devel wrote:
> A new failure has been detected on builder elfutils-fedora-s390x while 
> building elfutils.
> 
> Full details are available at:
> https://builder.sourceware.org/buildbot/#builders/43/builds/47
> 
> Build state: failed test (failure)
> Revision: 369c021c6eedae3665c1dbbaa4fc43afbbb698f4
> Worker: fedora-s390x
> Build Reason: (unknown)
> Blamelist: Di Chen 
> [...]
> - 7: make check ( failure )
> Logs:
> - stdio: 
> https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/7/logs/stdio
> - test-suite.log: 
> https://builder.sourceware.org/buildbot/#builders/43/builds/47/steps/7/logs/test-suite_log

So that is in the one little addition I made:

-==3856043== Invalid read of size 1
-==3856043==at 0x484EBE8: memrchr (vg_replace_strmem.c:1012)
-==3856043==by 0x100FEDF: handle_dynamic (readelf.c:1909)
-==3856043==by 0x102061D: print_dynamic (readelf.c:2013)
-==3856043==by 0x102061D: process_elf_file (readelf.c:1034)
-==3856043==by 0x1021FDB: process_dwflmod (readelf.c:818)
-==3856043==by 0x4962BCF: dwfl_getmodules (dwfl_getmodules.c:86)
-==3856043==by 0x100E175: process_file (readelf.c:926)
-==3856043==by 0x1006A75: main (readelf.c:395)
-==3856043==  Address 0x56df358 is 24 bytes before a block of size 264 alloc'd
-==3856043==at 0x484C002: calloc (vg_replace_malloc.c:1328)
-==3856043==by 0x4A4EED9: elf_getdata_rawchunk (elf_getdata_rawchunk.c:173)
-==3856043==by 0x1010621: get_dynscn_strtab (readelf.c:4958)
-==3856043==by 0x1010621: handle_dynamic (readelf.c:1884)
-==3856043==by 0x102061D: print_dynamic (readelf.c:2013)
-==3856043==by 0x102061D: process_elf_file (readelf.c:1034)
-==3856043==by 0x1021FDB: process_dwflmod (readelf.c:818)
-==3856043==by 0x4962BCF: dwfl_getmodules (dwfl_getmodules.c:86)
-==3856043==by 0x100E175: process_file (readelf.c:926)
-==3856043==by 0x1006A75: main (readelf.c:395)

I am staring at the code, but don't immediately see which mistake I
made.  Maybe I should use d_val instead of d_ptr (but those are both
uint64_t so that shouldn't really matter).

Cheers,

Mark