Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 149186 Details for
Bug 230850
/proc/PID/mem is not readable
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
elfutils-0.126 workaround using PTRACE_PEEKTEXT instead of `/proc/%d/mem'.
elfutils-0.126-mem-ptrace.patch (text/plain), 2.96 KB, created by
Jan Kratochvil
on 2007-03-03 18:43:24 UTC
(
hide
)
Description:
elfutils-0.126 workaround using PTRACE_PEEKTEXT instead of `/proc/%d/mem'.
Filename:
MIME Type:
Creator:
Jan Kratochvil
Created:
2007-03-03 18:43:24 UTC
Size:
2.96 KB
patch
obsolete
>--- elfutils-0.126-orig/libdwfl/linux-proc-maps.c 2007-01-30 17:19:22.000000000 +0100 >+++ elfutils-0.126/libdwfl/linux-proc-maps.c 2007-03-03 19:33:33.000000000 +0100 >@@ -62,8 +62,18 @@ > #include <endian.h> > > >+/* Value of 0 directs using PTRACE_PEEKTEXT workaround instead >+ of `/proc/%d/mem' which is failing on some Linux kernels with ESRCH. */ >+#define PROC_MEM_WORKS 0 >+ >+ > #define PROCMAPSFMT "/proc/%d/maps" >+#if PROC_MEM_WORKS > #define PROCMEMFMT "/proc/%d/mem" >+#else >+#include <sys/ptrace.h> >+#include <sys/wait.h> >+#endif > #define PROCAUXVFMT "/proc/%d/auxv" > > >@@ -261,6 +271,8 @@ dwfl_linux_proc_report (Dwfl *dwfl, pid_ > } > INTDEF (dwfl_linux_proc_report) > >+#if PROC_MEM_WORKS >+ > static ssize_t > read_proc_memory (void *arg, void *data, GElf_Addr address, > size_t minread, size_t maxread) >@@ -272,6 +284,57 @@ read_proc_memory (void *arg, void *data, > return nread; > } > >+#else /* !PROC_MEM_WORKS */ >+ >+struct read_ptrace_memory >+ { >+ int pid; >+ unsigned ptraced:1; >+ }; >+ >+static ssize_t >+read_ptrace_memory (void *arg, void *data, GElf_Addr address, >+ size_t minread, size_t maxread) >+{ >+ struct read_ptrace_memory *arg_typed = arg; >+ const int pid = arg_typed->pid; >+ ssize_t nread = 0; >+ while ((size_t) nread < maxread) >+ { >+ long result; >+ unsigned align = address & (sizeof (result) - 1); >+ unsigned xfer_size = sizeof (result) - align; >+ unsigned char *addr = (void *) (unsigned long) (address - align); >+ >+ errno = 0; >+ result = ptrace (PTRACE_PEEKTEXT, pid, addr, NULL); >+ >+ if (!arg_typed->ptraced && errno == ESRCH) >+ { >+ if (ptrace (PTRACE_ATTACH, pid, NULL, NULL) != 0) >+ break; >+ arg_typed->ptraced = 1; >+ if (waitpid (pid, NULL, 0) != pid) >+ break; >+ >+ errno = 0; >+ result = ptrace (PTRACE_PEEKTEXT, pid, addr, NULL); >+ } >+ if (errno != 0) >+ break; >+ >+ memcpy (data, (unsigned char *) &result + align, xfer_size); >+ data += xfer_size; >+ address += xfer_size; >+ nread += xfer_size; >+ } >+ if (nread > 0 && (size_t) nread < minread) >+ nread = 0; >+ return nread; >+} >+ >+#endif /* !PROC_MEM_WORKS */ >+ > extern Elf *elf_from_remote_memory (GElf_Addr ehdr_vma, > GElf_Addr *loadbasep, > ssize_t (*read_memory) (void *arg, >@@ -310,6 +373,8 @@ dwfl_linux_proc_find_elf (Dwfl_Module *m > { > /* Special case for in-memory ELF image. */ > >+#if PROC_MEM_WORKS >+ > char *fname; > if (asprintf (&fname, PROCMEMFMT, pid) < 0) > return -1; >@@ -323,6 +388,23 @@ dwfl_linux_proc_find_elf (Dwfl_Module *m > > close (fd); > >+#else /* !PROC_MEM_WORKS */ >+ >+ struct read_ptrace_memory arg_typed; >+ >+ arg_typed.pid = pid; >+ arg_typed.ptraced = 0; >+ *elfp = elf_from_remote_memory (base, NULL, &read_ptrace_memory, >+ &arg_typed); >+ >+ if (arg_typed.ptraced) >+ { >+ if (ptrace (PTRACE_DETACH, pid, NULL, NULL) != 0) >+ return -1; >+ } >+ >+#endif /* !PROC_MEM_WORKS */ >+ > *file_name = NULL; > return -1; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 230850
:
149185
|
149186
|
149248
|
149350