Re: [PATCH] tests: Check addsections test binary is 64bit for run-large-elf-file.sh

2022-03-24 Thread Mark Wielaard
On Mon, Mar 21, 2022 at 12:17:14AM +0100, Mark Wielaard wrote:
> The test binary should be 64bit to be able to create 4GB, or larger,
> ELF files.

Pushed.

Mark


[Bug general/28975] run-large-elf-file.sh fails in 32-bit cross-compile on 64-bit machine

2022-03-24 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=28975

Mark Wielaard  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from Mark Wielaard  ---
commit d85945f1056641180e03fb48ab770b893125786e
Author: Mark Wielaard 
Date:   Mon Mar 21 00:34:24 2022 +0100

configure: Don't check whether -m64 works for 32bit host biarch check

Running a 32bit backtrace test against a 64bit binary doesn't work.
Only a 64bit binary can backtrace a 32bit binary. So disable the
biarch check that inserts -m64 for a 32bit host.

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

Signed-off-by: Mark Wielaard 

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

Re: [PATCH] configure: Don't check whether -m64 works for 32bit host biarch check

2022-03-24 Thread Mark Wielaard
On Mon, Mar 21, 2022 at 12:47:51AM +0100, Mark Wielaard wrote:
> Running a 32bit backtrace test against a 64bit binary doesn't work.
> Only a 64bit binary can backtrace a 32bit binary. So disable the
> biarch check that inserts -m64 for a 32bit host.

Pushed.

Mark



[Bug libdw/24158] run-backtrace-native-biarch.sh test fails on CC='gcc -m32' CXX='g++ -m32' x86_64 host.

2022-03-24 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=24158

--- Comment #3 from Mark Wielaard  ---
This disables the "biarch" tests in the case of a 32bit build.

commit d85945f1056641180e03fb48ab770b893125786e
Author: Mark Wielaard 
Date:   Mon Mar 21 00:34:24 2022 +0100

configure: Don't check whether -m64 works for 32bit host biarch check

Running a 32bit backtrace test against a 64bit binary doesn't work.
Only a 64bit binary can backtrace a 32bit binary. So disable the
biarch check that inserts -m64 for a 32bit host.

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

Signed-off-by: Mark Wielaard 

But lets keep this bug open. It would in theory be good if this worked.

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

Get r_debug from a core file

2022-03-24 Thread Pablo Galindo Salgado via Elfutils-devel
Hi,

I'm trying to obtain the r_debug structure from a core file. It seems that
elfutils
is able to obtain the structure using the "dwfl_link_map_report" function,
but unfortunately
this is internal.

Is there a known way to obtain the structure using functions from the
public API?

If not, would you be willing to expose one or make dwfl_link_map_report
public?

Thanks for your consideration,

Pablo Galindo


Issue 45630 in oss-fuzz: elfutils:fuzz-libelf: Use-of-uninitialized-value in validate_str

2022-03-24 Thread ClusterFuzz-External via monorail via Elfutils-devel
Updates:
Labels: -Reproducible Unreproducible

Comment #5 on issue 45630 by ClusterFuzz-External: elfutils:fuzz-libelf: 
Use-of-uninitialized-value in validate_str
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45630#c5

ClusterFuzz testcase 5658767587409920 appears to be flaky, updating 
reproducibility label.

-- 
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.


Issue 45631 in oss-fuzz: elfutils:fuzz-libdwfl: Use-of-uninitialized-value in __libdw_gunzip

2022-03-24 Thread ClusterFuzz-External via monorail via Elfutils-devel
Updates:
Labels: ClusterFuzz-Verified
Status: Verified

Comment #4 on issue 45631 by ClusterFuzz-External: elfutils:fuzz-libdwfl: 
Use-of-uninitialized-value in __libdw_gunzip
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45631#c4

ClusterFuzz testcase 5742116662280192 is verified as fixed in 
https://oss-fuzz.com/revisions?job=libfuzzer_msan_elfutils&range=202203240610:202203241200

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.


Issue 45633 in oss-fuzz: elfutils:fuzz-libdwfl: Use-of-uninitialized-value in __libelf_read_mmaped_file

2022-03-24 Thread ClusterFuzz-External via monorail via Elfutils-devel
Updates:
Labels: ClusterFuzz-Verified
Status: Verified

Comment #1 on issue 45633 by ClusterFuzz-External: elfutils:fuzz-libdwfl: 
Use-of-uninitialized-value in __libelf_read_mmaped_file
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45633#c1

ClusterFuzz testcase 6298551989174272 is verified as fixed in 
https://oss-fuzz.com/revisions?job=libfuzzer_msan_elfutils&range=202203240610:202203241200

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.


Re: [PATCH v2] libebl: recognize FDO Packaging Metadata ELF note

2022-03-24 Thread Mark Wielaard
> I haven't forgotten about this. The glibc elf.h change has been
> integrated now. But when I wanted to resync with the elfutils
> libelf/elf.h version I noticed something that look like ABI
> breakage:
> https://sourceware.org/pipermail/libc-alpha/2021-December/133589.html
>
> I am trying to get a response to that before syncing and integrating
> your patch.

Sorry, I didn't like the answer I got. Basically this is ABI breakage,
it is just that the old constants were never really used, so some have
simply been renamed or given different constant values. Sigh.

That of course is not a good reason to then forget about your
patch. Apologies.

I took the elf.h update separately. Tweaked your patch a little and
added a patch of my own to make elflint recognize the new note type.

  [PATCH 1/3] libelf: Sync elf.h from glibc.
  [PATCH 2/3] libebl: recognize FDO Packaging Metadata ELF note
  [PATCH 3/3] elflint: Recognize NT_FDO_PACKAGING_METADATA

I saw Fedora 36 now has these new package notes. Sadly they omit the
debugInfoUrl field. Which makes them less useful imho. Do you happen
to know why that wasn't included?

Cheers,

Mark


[PATCH 1/3] libelf: Sync elf.h from glibc.

2022-03-24 Thread Mark Wielaard
Adds EM_INTELGT, NT_ARM_TAGGED_ADDR_CTRL, NT_ARM_PAC_ENABLED_KEYS,
ELF_NOTE_FDO, NT_FDO_PACKAGING_METADATA and OpenRISC 1000 specific
relocs.

It also adds and renames some GNU_PROPERTY constants. But none of the
constants the elfutils code uses was renamed or given a different
constant value.

dwelf_elf_e_machine_string was updated to handle EM_INTELGT.

Signed-off-by: Mark Wielaard 
---
 libdwelf/ChangeLog|   5 ++
 libdwelf/dwelf_elf_e_machine_string.c |   2 +
 libelf/ChangeLog  |   4 +
 libelf/elf.h  | 107 --
 4 files changed, 94 insertions(+), 24 deletions(-)

diff --git a/libdwelf/ChangeLog b/libdwelf/ChangeLog
index 5f7fb4ed..c9010af8 100644
--- a/libdwelf/ChangeLog
+++ b/libdwelf/ChangeLog
@@ -1,3 +1,8 @@
+2022-03-24  Mark Wielaard  
+
+   * dwelf_elf_e_machine_string.c (dwelf_elf_e_machine_string): Add
+   EM_INTELGT Intel Graphics Technology.
+
 2021-02-14  Alexander Miller  
 
* dwelf_elf_begin.c (dwelf_elf_begin): Move NEW_VERSION before
diff --git a/libdwelf/dwelf_elf_e_machine_string.c 
b/libdwelf/dwelf_elf_e_machine_string.c
index 387648e2..051c70b5 100644
--- a/libdwelf/dwelf_elf_e_machine_string.c
+++ b/libdwelf/dwelf_elf_e_machine_string.c
@@ -360,6 +360,8 @@ dwelf_elf_e_machine_string (int machine)
   return "XMOS xCORE";
 case EM_MCHP_PIC:
   return "Microchip 8-bit PIC";
+case EM_INTELGT:
+  return "Intel Graphics Technology";
 case EM_KM32:
   return "KM211 KM32";
 case EM_KMX32:
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 5ea1e41e..7fd6202b 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2022-03-24  Mark Wielaard  
+
+   * elf.h: Update from glibc.
+
 2022-03-22  Mark Wielaard  
 
* elf_getdata.c (__libelf_type_aligns): ELF_T_GNUHASH has different
diff --git a/libelf/elf.h b/libelf/elf.h
index 8e3e618f..0735f6b5 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -1,5 +1,5 @@
 /* This file defines standard ELF types, structures, and macros.
-   Copyright (C) 1995-2020 Free Software Foundation, Inc.
+   Copyright (C) 1995-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
 
The GNU C Library is free software; you can redistribute it and/or
@@ -336,7 +336,8 @@ typedef struct
 #define EM_BA2 202 /* Beyond BA2 */
 #define EM_XCORE   203 /* XMOS xCORE */
 #define EM_MCHP_PIC204 /* Microchip 8-bit PIC(r) */
-   /* reserved 205-209 */
+#define EM_INTELGT 205 /* Intel Graphics Technology */
+   /* reserved 206-209 */
 #define EM_KM32210 /* KM211 KM32 */
 #define EM_KMX32   211 /* KM211 KMX32 */
 #define EM_EMX16   212 /* KM211 KMX16 */
@@ -813,6 +814,10 @@ typedef struct
   address keys.  */
 #define NT_ARM_PACG_KEYS   0x408   /* ARM pointer authentication
   generic key.  */
+#define NT_ARM_TAGGED_ADDR_CTRL0x409   /* AArch64 tagged address
+  control.  */
+#define NT_ARM_PAC_ENABLED_KEYS0x40a   /* AArch64 pointer 
authentication
+  enabled keys.  */
 #define NT_VMCOREDD0x700   /* Vmcore Device Dump Note.  */
 #define NT_MIPS_DSP0x800   /* MIPS DSP ASE registers.  */
 #define NT_MIPS_FP_MODE0x801   /* MIPS floating-point mode.  */
@@ -1226,8 +1231,7 @@ typedef struct
 #define AT_L3_CACHESIZE46
 #define AT_L3_CACHEGEOMETRY47
 
-#define AT_MINSIGSTKSZ 51 /* Stack needed for signal delivery
- (AArch64).  */
+#define AT_MINSIGSTKSZ 51 /* Stack needed for signal delivery  */
 
 /* Note section contents.  Each entry in the note section begins with
a header of a fixed form.  */
@@ -1254,6 +1258,8 @@ typedef struct
 /* Note entries for GNU systems have this name.  */
 #define ELF_NOTE_GNU   "GNU"
 
+/* Note entries for freedesktop.org have this name.  */
+#define ELF_NOTE_FDO   "FDO"
 
 /* Defined types of notes for Solaris.  */
 
@@ -1297,6 +1303,10 @@ typedef struct
 /* Program property.  */
 #define NT_GNU_PROPERTY_TYPE_0 5
 
+/* Packaging metadata as defined on
+   https://systemd.io/COREDUMP_PACKAGE_METADATA/ */
+#define NT_FDO_PACKAGING_METADATA 0xcafe1a7e
+
 /* Note section name of program property.   */
 #define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
 
@@ -1307,6 +1317,23 @@ typedef struct
 /* No copy relocation on protected data symbol.  */
 #define GNU_PROPERTY_NO_COPY_ON_PROTECTED  2
 
+/* A 4-byte unsigned integer property: A bit is set if it is set in all
+   relocatable inputs.  */
+#define GNU_PROPERTY_UINT32_AND_LO 0xb000
+#define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff
+
+/* A 4-byte unsigned integer property: A bit is 

[PATCH 2/3] libebl: recognize FDO Packaging Metadata ELF note

2022-03-24 Thread Mark Wielaard
From: Luca Boccassi 

As defined on: https://systemd.io/COREDUMP_PACKAGE_METADATA/
this note will be used starting from Fedora 36. Allow
readelf --notes to pretty print it:

Note section [ 3] '.note.package' of 76 bytes at offset 0x2e8:
  Owner  Data size  Type
  FDO   57  FDO_PACKAGING_METADATA
Packaging Metadata: {"type":"deb","name":"fsverity-utils","version":"1.3-1"}

Signed-off-by: Luca Boccassi 
---
 libebl/ChangeLog| 5 +
 libebl/eblobjnote.c | 4 
 libebl/eblobjnotetypename.c | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index da690a40..2e31e75d 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,8 @@
+2021-12-21  Luca Boccassi  
+
+   * eblobjnote.c (ebl_object_note): Handle NT_FDO_PACKAGING_METADATA.
+   * eblobjnotetypename.c (ebl_object_note_type_name): Likewise.
+
 2021-09-06  Dmitry V. Levin  
 
* eblopenbackend.c (openbackend): Remove cast of calloc return value.
diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
index 36efe275..5a7c5c62 100644
--- a/libebl/eblobjnote.c
+++ b/libebl/eblobjnote.c
@@ -288,6 +288,10 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char 
*name, uint32_t type,
   if (descsz == 0 && type == NT_VERSION)
return;
 
+  if (strcmp ("FDO", name) == 0 && type == NT_FDO_PACKAGING_METADATA
+ && descsz > 0 && desc[descsz - 1] == '\0')
+   printf("Packaging Metadata: %.*s\n", (int) descsz, desc);
+
   /* Everything else should have the "GNU" owner name.  */
   if (strcmp ("GNU", name) != 0)
return;
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 4662906d..473a1f2f 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -101,6 +101,9 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, 
uint32_t type,
  return buf;
}
 
+  if (strcmp (name, "FDO") == 0 && type == NT_FDO_PACKAGING_METADATA)
+   return "FDO_PACKAGING_METADATA";
+
   if (strcmp (name, "GNU") != 0)
{
  /* NT_VERSION is special, all data is in the name.  */
-- 
2.30.2



[PATCH 3/3] elflint: Recognize NT_FDO_PACKAGING_METADATA

2022-03-24 Thread Mark Wielaard
Signed-off-by: Mark Wielaard 
---
 src/ChangeLog | 4 
 src/elflint.c | 7 +++
 2 files changed, 11 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index 0e705b7d..1e3c31a8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2022-03-24  Mark Wielaard  
+
+   * elflint.c (check_note_data): Recognize NT_FDO_PACKAGING_METADATA.
+
 2022-03-11  Mark Wielaard  
 
* addr2line.c (OPT_RELATIVE): New constant.
diff --git a/src/elflint.c b/src/elflint.c
index ef7725ce..d919936f 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -4384,6 +4384,13 @@ section [%2d] '%s': unknown core file note type %" PRIu32
else
  goto unknown_note;
 
+ case NT_FDO_PACKAGING_METADATA:
+   if (nhdr.n_namesz == sizeof ELF_NOTE_FDO
+   && strcmp (data->d_buf + name_offset, ELF_NOTE_FDO) == 0)
+ break;
+   else
+ goto unknown_note;
+
  case 0:
/* Linux vDSOs use a type 0 note for the kernel version word.  */
if (nhdr.n_namesz == sizeof "Linux"
-- 
2.30.2



[Bug libelf/29000] New: Conditional jump or move depends on uninitialised value in elf_compress_gnu

2022-03-24 Thread evvers at ya dot ru via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29000

Bug ID: 29000
   Summary: Conditional jump or move depends on uninitialised
value in elf_compress_gnu
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: libelf
  Assignee: unassigned at sourceware dot org
  Reporter: evvers at ya dot ru
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Created attachment 14035
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14035&action=edit
file triggering valgrind warning

It was found with MSan on OSS-Fuzz but can be reproduced with Valgrind by
applying https://sourceware.org/pipermail/elfutils-devel/2022q1/004767.html and
running the following commands:
```
autoreconf -i -f
./configure --enable-maintainer-mode
make V=1 -j$(nproc)
make -C tests fuzz-libelf V=1
LD_LIBRARY_PATH="$(pwd)/libelf;$(pwd)/libdw" DEBUGINFOD_URLS= valgrind
--track-origins=yes ./tests/fuzz-libelf
clusterfuzz-testcase-minimized-fuzz-libelf-6467719510228992
```
```
unning: ../clusterfuzz-testcase-minimized-fuzz-libelf-6467719510228992
==65519== Conditional jump or move depends on uninitialised value(s)
==65519==at 0x4868734: elf_compress_gnu (elf_compress_gnu.c:155)
==65519==by 0x401553: fuzz_logic_one (fuzz-libelf.c:41)
==65519==by 0x4016D9: LLVMFuzzerTestOneInput (fuzz-libelf.c:82)
==65519==by 0x4012B8: main (fuzz-main.c:33)
==65519==  Uninitialised value was created by a heap allocation
==65519==at 0x484486F: malloc (vg_replace_malloc.c:381)
==65519==by 0x48606C6: convert_data (elf_getdata.c:168)
==65519==by 0x48606C6: __libelf_set_data_list_rdlock (elf_getdata.c:457)
==65519==by 0x48608C7: __elf_getdata_rdlock (elf_getdata.c:564)
==65519==by 0x486870A: elf_compress_gnu (elf_compress_gnu.c:150)
==65519==by 0x401553: fuzz_logic_one (fuzz-libelf.c:41)
==65519==by 0x4016D9: LLVMFuzzerTestOneInput (fuzz-libelf.c:82)
==65519==by 0x4012B8: main (fuzz-main.c:33)
==65519==
Done:../clusterfuzz-testcase-minimized-fuzz-libelf-6467719510228992: (608
bytes)
==65519==
```

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