* [Buildroot] [PATCH 1/1] package/elfutils: fix build with glibc < 2.16
@ 2019-08-03 21:46 Fabrice Fontaine
2019-08-03 22:32 ` Peter Korsgaard
2019-08-30 20:29 ` Peter Korsgaard
0 siblings, 2 replies; 3+ messages in thread
From: Fabrice Fontaine @ 2019-08-03 21:46 UTC (permalink / raw)
To: buildroot
Fixes:
- autobuild.buildroot.net/results/1053e2b4b51bc225c4a1a29c93946101a7a53be9
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
...source-leak-in-elf-32-64-_updatefile.patch | 32 ++++++++++
...ix_memalign-instead-of-aligned_alloc.patch | 58 +++++++++++++++++++
2 files changed, 90 insertions(+)
create mode 100644 package/elfutils/0004-libelf-Fix-possible-resource-leak-in-elf-32-64-_updatefile.patch
create mode 100644 package/elfutils/0005-libelf-Use-posix_memalign-instead-of-aligned_alloc.patch
diff --git a/package/elfutils/0004-libelf-Fix-possible-resource-leak-in-elf-32-64-_updatefile.patch b/package/elfutils/0004-libelf-Fix-possible-resource-leak-in-elf-32-64-_updatefile.patch
new file mode 100644
index 0000000000..af5849a23b
--- /dev/null
+++ b/package/elfutils/0004-libelf-Fix-possible-resource-leak-in-elf-32-64-_updatefile.patch
@@ -0,0 +1,32 @@
+From 75e147d0ab85262d9bb2fff093db7ce67dbd4b62 Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <mark@klomp.org>
+Date: Wed, 6 Mar 2019 19:56:54 +0100
+Subject: [PATCH] libelf: Fix possible resource leak in elf[32|64]_updatefile.
+
+When we cannot allocate enough memory to convert the data in
+updatemmap we should free the scns before returning an error.
+
+Signed-off-by: Mark Wielaard <mark@klomp.org>
+[Retrieved (and sliglty updated to remove ChangeLog update) from:
+https://sourceware.org/git/?p=elfutils.git;a=patch;h=75e147d0ab85262d9bb2fff093db7ce67dbd4b62]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ libelf/elf32_updatefile.c | 1 +
+ 2 files changed, 6 insertions(+)
+
+ * gelf_xlate.c (__elf_xfctstof): Remove alias.
+diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
+index 2899c6f..457d18e 100644
+--- a/libelf/elf32_updatefile.c
++++ b/libelf/elf32_updatefile.c
+@@ -365,6 +365,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
+ char *converted = aligned_alloc (align, size);
+ if (converted == NULL)
+ {
++ free (scns);
+ __libelf_seterrno (ELF_E_NOMEM);
+ return 1;
+ }
+--
+2.9.3
+
diff --git a/package/elfutils/0005-libelf-Use-posix_memalign-instead-of-aligned_alloc.patch b/package/elfutils/0005-libelf-Use-posix_memalign-instead-of-aligned_alloc.patch
new file mode 100644
index 0000000000..70f1f9af21
--- /dev/null
+++ b/package/elfutils/0005-libelf-Use-posix_memalign-instead-of-aligned_alloc.patch
@@ -0,0 +1,58 @@
+From 6bd060a23f43a842fbc37dd1bb8d6d7964eda36e Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <mark@klomp.org>
+Date: Thu, 7 Mar 2019 17:31:53 +0100
+Subject: [PATCH] libelf: Use posix_memalign instead of aligned_alloc.
+
+Older glibc might not have aligned_alloc (it is C11).
+Use posix_memalign instead. posix_memalign requires the alignment to
+be a multiple of sizeof (void *). So use malloc for smaller alignments.
+
+Signed-off-by: Mark Wielaard <mark@klomp.org>
+[Retrieved (and slighlty updated to remove ChangeLog update) from:
+https://sourceware.org/git/?p=elfutils.git;a=patch;h=6bd060a23f43a842fbc37dd1bb8d6d7964eda36e]
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ libelf/elf32_updatefile.c | 20 +++++++++++++++++---
+ 2 files changed, 22 insertions(+), 3 deletions(-)
+
+diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
+index 457d18e..eea51a7 100644
+--- a/libelf/elf32_updatefile.c
++++ b/libelf/elf32_updatefile.c
+@@ -360,16 +360,30 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
+ else
+ {
+ /* We have to do the conversion on properly
+- aligned memory first. */
++ aligned memory first. align is a power of 2,
++ but posix_memalign only works for alignments
++ which are a multiple of sizeof (void *).
++ So use normal malloc for smaller alignments. */
+ size_t size = dl->data.d.d_size;
+- char *converted = aligned_alloc (align, size);
++ void *converted;
++ if (align < sizeof (void *))
++ converted = malloc (size);
++ else
++ {
++ int res;
++ res = posix_memalign (&converted, align, size);
++ if (res != 0)
++ converted = NULL;
++ }
++
+ if (converted == NULL)
+ {
+ free (scns);
+ __libelf_seterrno (ELF_E_NOMEM);
+ return 1;
+ }
+- (*fctp) (converted, dl->data.d.d_buf, size, 1);
++
++ (*fctp) (converted, dl->data.d.d_buf, size, 1);
+
+ /* And then write it to the mmapped file. */
+ memcpy (last_position, converted, size);
+--
+2.9.3
+
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH 1/1] package/elfutils: fix build with glibc < 2.16
2019-08-03 21:46 [Buildroot] [PATCH 1/1] package/elfutils: fix build with glibc < 2.16 Fabrice Fontaine
@ 2019-08-03 22:32 ` Peter Korsgaard
2019-08-30 20:29 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2019-08-03 22:32 UTC (permalink / raw)
To: buildroot
>>>>> "Fabrice" == Fabrice Fontaine <fontaine.fabrice@gmail.com> writes:
> Fixes:
> - autobuild.buildroot.net/results/1053e2b4b51bc225c4a1a29c93946101a7a53be9
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Committed, thanks!
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH 1/1] package/elfutils: fix build with glibc < 2.16
2019-08-03 21:46 [Buildroot] [PATCH 1/1] package/elfutils: fix build with glibc < 2.16 Fabrice Fontaine
2019-08-03 22:32 ` Peter Korsgaard
@ 2019-08-30 20:29 ` Peter Korsgaard
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2019-08-30 20:29 UTC (permalink / raw)
To: buildroot
>>>>> "Fabrice" == Fabrice Fontaine <fontaine.fabrice@gmail.com> writes:
> Fixes:
> - autobuild.buildroot.net/results/1053e2b4b51bc225c4a1a29c93946101a7a53be9
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Committed to 2019.02.x and 2019.05.x, thanks.
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-30 20:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-03 21:46 [Buildroot] [PATCH 1/1] package/elfutils: fix build with glibc < 2.16 Fabrice Fontaine
2019-08-03 22:32 ` Peter Korsgaard
2019-08-30 20:29 ` Peter Korsgaard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.