[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 02/16: Record executable entry for PIE core dumps
From: |
Samuel Thibault |
Subject: |
[hurd] 02/16: Record executable entry for PIE core dumps |
Date: |
Tue, 09 Jan 2018 01:35:29 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 0ca198f1f90071a054287c204a3fd1b4ea315e18
Author: Samuel Thibault <address@hidden>
Date: Mon Dec 11 02:32:26 2017 +0100
Record executable entry for PIE core dumps
* hurd/process.defs (proc_set_entry, proc_get_entry): New RPCs.
* hurd/process_reply.defs: Add skips for proc_set_entry, proc_get_entry.
* hurd/process_request.defs: Likewise.
* exec/exec.c (do_exec): Call proc_set_entry.
* proc/proc.h (proc): Add p_entry field.
* proc/mgt.c (S_proc_set_entry, S_proc_get_entry): New RPC
implementations.
* exec/elfcore.c (dump_core): Add at_entry note, call proc_get_entry to
get it, and write it with WRITE_NOTE.
---
exec/elfcore.c | 13 +++++++++++++
exec/exec.c | 5 +++++
hurd/process.defs | 10 ++++++++++
hurd/process_reply.defs | 3 +++
hurd/process_request.defs | 3 +++
proc/mgt.c | 18 ++++++++++++++++++
proc/proc.h | 1 +
7 files changed, 53 insertions(+)
diff --git a/exec/elfcore.c b/exec/elfcore.c
index 12ecf34..2dd499b 100644
--- a/exec/elfcore.c
+++ b/exec/elfcore.c
@@ -331,6 +331,7 @@ dump_core (task_t task, file_t file, off_t corelimit,
{
DEFINE_NOTE (psinfo_t) psinfo;
DEFINE_NOTE (pstatus_t) pstatus;
+ DEFINE_NOTE (ElfW(auxv_t)) at_entry;
int flags = PI_FETCH_TASKINFO | PI_FETCH_THREADS | PI_FETCH_THREAD_BASIC;
char *waits = 0;
mach_msg_type_number_t num_waits = 0;
@@ -410,6 +411,18 @@ dump_core (task_t task, file_t file, off_t corelimit,
err = proc_get_arg_locations (proc,
&psinfo.data.pr_argv,
&psinfo.data.pr_envp);
+ if (err == 0)
+ {
+ /* Write position of executable. */
+ vm_address_t addr;
+ err = proc_get_entry (proc, &addr);
+ if (err == 0)
+ {
+ at_entry.data.a_type = AT_ENTRY;
+ at_entry.data.a_un.a_val = addr;
+ err = WRITE_NOTE (NT_AUXV, at_entry);
+ }
+ }
mach_port_deallocate (mach_task_self (), proc);
}
{
diff --git a/exec/exec.c b/exec/exec.c
index d78c54c..2d74ee1 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -1234,6 +1234,11 @@ do_exec (file_t file,
goto out;
set_name (newtask, argv, pid);
+
+ e.error = proc_set_entry (boot->portarray[INIT_PORT_PROC],
+ e.entry);
+ if (e.error)
+ goto out;
}
else
set_name (newtask, argv, 0);
diff --git a/hurd/process.defs b/hurd/process.defs
index c395705..725326a 100644
--- a/hurd/process.defs
+++ b/hurd/process.defs
@@ -416,3 +416,13 @@ routine proc_make_task_namespace (
skip; /* proc_set_exe */
skip; /* proc_get_exe */
+
+/* Set the locations of the executable entry. */
+routine proc_set_entry (
+ process: process_t;
+ entry: vm_address_t);
+
+/* Fetch the locations of the executable entry. */
+routine proc_get_entry (
+ process: process_t;
+ out entry: vm_address_t);
diff --git a/hurd/process_reply.defs b/hurd/process_reply.defs
index 84621e8..2eefcc3 100644
--- a/hurd/process_reply.defs
+++ b/hurd/process_reply.defs
@@ -197,3 +197,6 @@ skip; /* proc_make_task_namespace */
skip; /* proc_set_exe */
skip; /* proc_get_exe */
+
+skip; /* proc_set_entry */
+skip; /* proc_get_entry */
diff --git a/hurd/process_request.defs b/hurd/process_request.defs
index e5518f0..fc9127a 100644
--- a/hurd/process_request.defs
+++ b/hurd/process_request.defs
@@ -420,3 +420,6 @@ simpleroutine proc_make_task_namespace_request (
skip; /* proc_set_exe */
skip; /* proc_get_exe */
+
+skip; /* proc_set_entry */
+skip; /* proc_get_entry */
diff --git a/proc/mgt.c b/proc/mgt.c
index 750073a..354f378 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -348,6 +348,24 @@ S_proc_get_arg_locations (struct proc *p,
return 0;
}
+/* Implement proc_set_entry as described in <hurd/process.defs>. */
+kern_return_t
+S_proc_set_entry (struct proc *p, vm_address_t entry)
+{
+ if (!p)
+ return EOPNOTSUPP;
+ p->p_entry = entry;
+ return 0;
+}
+
+/* Implement proc_get_entry as described in <hurd/process.defs>. */
+kern_return_t
+S_proc_get_entry (struct proc *p, vm_address_t *entry)
+{
+ *entry = p->p_entry;
+ return 0;
+}
+
/* Implement proc_dostop as described in <hurd/process.defs>. */
kern_return_t
S_proc_dostop (struct proc *p,
diff --git a/proc/proc.h b/proc/proc.h
index 333e884..b33845d 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -71,6 +71,7 @@ struct proc
vm_address_t p_argv, p_envp;
vm_address_t start_code; /* all executable segments are in this range */
vm_address_t end_code;
+ vm_address_t p_entry; /* executable entry */
int p_status; /* to return via wait */
int p_sigcode;
struct rusage p_rusage; /* my usage if I'm dead, to return via wait */
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] branch upstream updated (83fef6c -> 104f312), Samuel Thibault, 2018/01/08
- [hurd] 07/16: libfshelp/get-identity.c: Avoid spurious ihash removal, Samuel Thibault, 2018/01/08
- [hurd] 09/16: libfshelp/get-identity.c: Simplify checking weak references, Samuel Thibault, 2018/01/08
- [hurd] 06/16: libfshelp/get-identity: Use 64bit hashing for inodes, Samuel Thibault, 2018/01/08
- [hurd] 08/16: libihash: Make sure we do not remove a locp several times, Samuel Thibault, 2018/01/08
- [hurd] 02/16: Record executable entry for PIE core dumps,
Samuel Thibault <=
- [hurd] 04/16: libfshelp: Add weak reference for hash table reference, Samuel Thibault, 2018/01/08
- [hurd] 13/16: rpctrace: Pass prefixed_name to _hurd_exec_paths., Samuel Thibault, 2018/01/08
- [hurd] 05/16: libfshelp/get-identity.c: add FIXME, Samuel Thibault, 2018/01/08
- [hurd] 01/16: Reserve IDs for proc_set_exe and proc_get_exe, Samuel Thibault, 2018/01/08
- [hurd] 12/16: Use the new _hurd_exec_file_name function, Samuel Thibault, 2018/01/08
- [hurd] 16/16: Implement /proc/<pid>/exe, Samuel Thibault, 2018/01/08
- [hurd] 14/16: Fix exec_paths through fakeroot or chroot, Samuel Thibault, 2018/01/08
- [hurd] 10/16: Add a new exec_exec_paths RPC, Samuel Thibault, 2018/01/08
- [hurd] 15/16: Add support for $ORIGIN rpath expansion, Samuel Thibault, 2018/01/08
- [hurd] 11/16: Add a file_exec_file_name RPC, Samuel Thibault, 2018/01/08