- Enhancing find_elf_note to allow calling lib functions with dlopen (#1287752)
This commit is contained in:
parent
714819e917
commit
638dc370bf
78
procps-ng-3.3.10-find_elf_note-memory-error-fix.patch
Normal file
78
procps-ng-3.3.10-find_elf_note-memory-error-fix.patch
Normal file
@ -0,0 +1,78 @@
|
||||
diff -Naur procps-ng-3.3.10.orig/proc/sysinfo.c procps-ng-3.3.10/proc/sysinfo.c
|
||||
--- procps-ng-3.3.10.orig/proc/sysinfo.c 2014-09-23 13:40:36.000000000 +0200
|
||||
+++ procps-ng-3.3.10/proc/sysinfo.c 2016-01-14 13:46:42.710000000 +0100
|
||||
@@ -36,6 +36,9 @@
|
||||
#include <netinet/in.h> /* htons */
|
||||
#endif
|
||||
|
||||
+#include <link.h>
|
||||
+#include <elf.h>
|
||||
+
|
||||
long smp_num_cpus; /* number of CPUs */
|
||||
long page_bytes; /* this architecture's page size */
|
||||
|
||||
@@ -249,14 +252,58 @@
|
||||
|
||||
extern char** environ;
|
||||
|
||||
-/* for ELF executables, notes are pushed before environment and args */
|
||||
-static unsigned long find_elf_note(unsigned long findme){
|
||||
+static unsigned long find_elf_note(unsigned long type)
|
||||
+{
|
||||
+ ElfW(auxv_t) auxv_struct;
|
||||
+ ElfW(auxv_t) *auxv_temp;
|
||||
+ FILE *fd;
|
||||
+ int i;
|
||||
+ static ElfW(auxv_t) *auxv = NULL;
|
||||
unsigned long *ep = (unsigned long *)environ;
|
||||
- while(*ep++);
|
||||
- while(*ep){
|
||||
- if(ep[0]==findme) return ep[1];
|
||||
- ep+=2;
|
||||
+
|
||||
+ if(!auxv) {
|
||||
+
|
||||
+ fd = fopen("/proc/self/auxv", "rb");
|
||||
+
|
||||
+ if(!fd) { // can't open auxv? that could be caused by euid change
|
||||
+ // ... and we need to fall back to the old and unsafe
|
||||
+ // ... method that doesn't work when calling library
|
||||
+ // ... functions with dlopen -> FIXME :(
|
||||
+
|
||||
+ while(*ep++); // for ELF executables, notes are pushed
|
||||
+ while(*ep){ // ... before environment and args
|
||||
+ if(ep[0]==type) return ep[1];
|
||||
+ ep+=2;
|
||||
+ }
|
||||
+ return NOTE_NOT_FOUND;
|
||||
+ }
|
||||
+
|
||||
+ auxv = (ElfW(auxv_t) *) malloc(getpagesize());
|
||||
+ if (!auxv) {
|
||||
+ perror("malloc");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+
|
||||
+ i = 0;
|
||||
+ do {
|
||||
+ fread(&auxv_struct, sizeof(ElfW(auxv_t)), 1, fd);
|
||||
+ auxv[i] = auxv_struct;
|
||||
+ i++;
|
||||
+ } while (auxv_struct.a_type != AT_NULL);
|
||||
+
|
||||
+ fclose(fd);
|
||||
+
|
||||
}
|
||||
+
|
||||
+ auxv_temp = auxv;
|
||||
+ i = 0;
|
||||
+ do {
|
||||
+ if(auxv_temp[i].a_type == type) {
|
||||
+ return (unsigned long)auxv_temp[i].a_un.a_val;
|
||||
+ }
|
||||
+ i++;
|
||||
+ } while (auxv_temp[i].a_type != AT_NULL);
|
||||
+
|
||||
return NOTE_NOT_FOUND;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
Summary: System and process monitoring utilities
|
||||
Name: procps-ng
|
||||
Version: 3.3.10
|
||||
Release: 9%{?dist}
|
||||
Release: 10%{?dist}
|
||||
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
|
||||
Group: Applications/System
|
||||
URL: https://sourceforge.net/projects/procps-ng/
|
||||
@ -12,6 +12,7 @@ URL: https://sourceforge.net/projects/procps-ng/
|
||||
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
|
||||
|
||||
Patch0: procps-ng-3.3.10-top-fix-deep-forking-forest-crash.patch
|
||||
Patch1: procps-ng-3.3.10-find_elf_note-memory-error-fix.patch
|
||||
|
||||
Requires(post): /sbin/ldconfig
|
||||
Requires(postun): /sbin/ldconfig
|
||||
@ -87,6 +88,7 @@ Internationalization pack for procps-ng
|
||||
%setup -q -n %{name}-%{version}
|
||||
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
|
||||
%build
|
||||
# The following stuff is needed for git archives only
|
||||
@ -160,6 +162,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
||||
%files i18n -f %{name}.lang
|
||||
|
||||
%changelog
|
||||
* Thu Jan 14 2016 Jaromir Capik <jcapik@redhat.com> - 3.3.10-10
|
||||
- Enhancing find_elf_note to allow calling lib functions with dlopen (#1287752)
|
||||
|
||||
* Fri Aug 14 2015 Adam Jackson <ajax@redhat.com> 3.3.10-9
|
||||
- Use %%configure so the hardened cflags get applied correctly
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user