Commit ce65f2f7 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

dump, kernel: Add start/end_code data

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent b2c4ebf2
...@@ -416,7 +416,8 @@ err: ...@@ -416,7 +416,8 @@ err:
#define assign_reg(dst, src, e) dst.e = (__typeof__(dst.e))src.e #define assign_reg(dst, src, e) dst.e = (__typeof__(dst.e))src.e
#define assign_array(dst, src, e) memcpy(&dst.e, &src.e, sizeof(dst.e)) #define assign_array(dst, src, e) memcpy(&dst.e, &src.e, sizeof(dst.e))
static int get_task_stat(pid_t pid, u8 *comm, u32 *flags) static int get_task_stat(pid_t pid, u8 *comm, u32 *flags,
u64 *start_code, u64 *end_code)
{ {
FILE *file = NULL; FILE *file = NULL;
char *tok1, *tok2; char *tok1, *tok2;
...@@ -446,21 +447,43 @@ static int get_task_stat(pid_t pid, u8 *comm, u32 *flags) ...@@ -446,21 +447,43 @@ static int get_task_stat(pid_t pid, u8 *comm, u32 *flags)
if (!ret) { if (!ret) {
ret = -1; ret = -1;
for (i = 0; i < 8; i++) { for (i = 0; i < 7; i++) {
tok1 = strtok(NULL, " "); tok1 = strtok(NULL, " ");
if (!tok1) { if (!tok1)
pr_err("/proc/%d/stat is corrupted", pid); goto err_corrupted;
goto err;
}
} }
*flags = atoi(tok1); *flags = atoi(tok1);
ret = 0; ret = 0;
} }
if (!ret) {
ret = -1;
for (i = 0; i < 15; i++) {
tok1 = strtok(NULL, " ");
if (!tok1)
goto err_corrupted;
}
tok1 = strtok(NULL, " ");
if (!tok1)
goto err_corrupted;
*start_code = atol(tok1);
tok1 = strtok(NULL, " ");
if (!tok1)
goto err_corrupted;
*end_code = atol(tok1);
ret = 0;
}
err: err:
if (file) if (file)
fclose(file); fclose(file);
return ret; return ret;
err_corrupted:
pr_err("/proc/%d/stat is corrupted", pid);
goto err;
} }
static int get_task_personality(pid_t pid, u32 *personality) static int get_task_personality(pid_t pid, u32 *personality)
...@@ -619,7 +642,10 @@ static int dump_task_core_seized(pid_t pid, struct cr_fdset *cr_fdset) ...@@ -619,7 +642,10 @@ static int dump_task_core_seized(pid_t pid, struct cr_fdset *cr_fdset)
pr_info("OK\n"); pr_info("OK\n");
pr_info("Obtainting task stat ... "); pr_info("Obtainting task stat ... ");
ret = get_task_stat(pid, core->task_comm, &core->task_flags); ret = get_task_stat(pid, core->task_comm,
&core->task_flags,
&core->mm_start_code,
&core->mm_end_code);
if (ret) if (ret)
goto err_free; goto err_free;
pr_info("OK\n"); pr_info("OK\n");
......
...@@ -107,7 +107,7 @@ static void show_core_rest(struct cr_fdset *cr_fdset) ...@@ -107,7 +107,7 @@ static void show_core_rest(struct cr_fdset *cr_fdset)
int fd_core, i; int fd_core, i;
u32 personality; u32 personality;
char comm[TASK_COMM_LEN]; char comm[TASK_COMM_LEN];
u64 mm_brk; u64 mm_brk, mm_start_code, mm_end_code;
fd_core = cr_fdset->desc[CR_FD_CORE].fd; fd_core = cr_fdset->desc[CR_FD_CORE].fd;
if (fd_core < 0) if (fd_core < 0)
...@@ -122,9 +122,17 @@ static void show_core_rest(struct cr_fdset *cr_fdset) ...@@ -122,9 +122,17 @@ static void show_core_rest(struct cr_fdset *cr_fdset)
lseek(fd_core, GET_FILE_OFF(struct core_entry, mm_brk), SEEK_SET); lseek(fd_core, GET_FILE_OFF(struct core_entry, mm_brk), SEEK_SET);
read_ptr_safe(fd_core, &mm_brk, err); read_ptr_safe(fd_core, &mm_brk, err);
lseek(fd_core, GET_FILE_OFF(struct core_entry, mm_start_code), SEEK_SET);
read_ptr_safe(fd_core, &mm_start_code, err);
lseek(fd_core, GET_FILE_OFF(struct core_entry, mm_end_code), SEEK_SET);
read_ptr_safe(fd_core, &mm_end_code, err);
pr_info("Personality: %x\n", personality); pr_info("Personality: %x\n", personality);
pr_info("Command: %s\n", comm); pr_info("Command: %s\n", comm);
pr_info("Brk: %lx\n", mm_brk); pr_info("Brk: %lx\n", mm_brk);
pr_info("Start code: %lx\n", mm_start_code);
pr_info("End code: %lx\n", mm_end_code);
err: err:
return; return;
} }
......
...@@ -182,6 +182,8 @@ struct core_entry { ...@@ -182,6 +182,8 @@ struct core_entry {
u8 task_comm[TASK_COMM_LEN]; u8 task_comm[TASK_COMM_LEN];
u32 task_flags; u32 task_flags;
u64 mm_brk; u64 mm_brk;
u64 mm_start_code;
u64 mm_end_code;
}; };
u8 __core_pad[CKPT_CORE_SIZE]; u8 __core_pad[CKPT_CORE_SIZE];
}; };
......
...@@ -35,8 +35,8 @@ Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> ...@@ -35,8 +35,8 @@ Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
fs/binfmt_elf_ckpt.c | 389 ++++++++++++++++++++++++++++++++++++++++ fs/binfmt_elf_ckpt.c | 389 ++++++++++++++++++++++++++++++++++++++++
fs/exec.c | 27 +- fs/exec.c | 27 +-
include/linux/binfmts.h | 1 include/linux/binfmts.h | 1
include/linux/elf_ckpt.h | 97 +++++++++ include/linux/elf_ckpt.h | 99 ++++++++++
12 files changed, 799 insertions(+), 12 deletions(-) 12 files changed, 801 insertions(+), 12 deletions(-)
Index: linux-2.6.git/arch/x86/include/asm/elf.h Index: linux-2.6.git/arch/x86/include/asm/elf.h
=================================================================== ===================================================================
...@@ -719,8 +719,8 @@ Index: linux-2.6.git/fs/binfmt_elf_ckpt.c ...@@ -719,8 +719,8 @@ Index: linux-2.6.git/fs/binfmt_elf_ckpt.c
+ goto out_unmap; + goto out_unmap;
+ } + }
+ +
+ current->mm->start_code = start_code; + current->mm->start_code = core_entry->mm_start_code;
+ current->mm->end_code = end_code; + current->mm->end_code = core_entry->mm_end_code;
+ current->mm->start_data = start_data; + current->mm->start_data = start_data;
+ current->mm->end_data = end_data; + current->mm->end_data = end_data;
+ current->mm->start_stack = start_stack; + current->mm->start_stack = start_stack;
...@@ -886,7 +886,7 @@ Index: linux-2.6.git/include/linux/elf_ckpt.h ...@@ -886,7 +886,7 @@ Index: linux-2.6.git/include/linux/elf_ckpt.h
=================================================================== ===================================================================
--- /dev/null --- /dev/null
+++ linux-2.6.git/include/linux/elf_ckpt.h +++ linux-2.6.git/include/linux/elf_ckpt.h
@@ -0,0 +1,97 @@ @@ -0,0 +1,99 @@
+#ifndef _LINUX_ELF_CHECKPOINT_H +#ifndef _LINUX_ELF_CHECKPOINT_H
+#define _LINUX_ELF_CHECKPOINT_H +#define _LINUX_ELF_CHECKPOINT_H
+ +
...@@ -965,6 +965,8 @@ Index: linux-2.6.git/include/linux/elf_ckpt.h ...@@ -965,6 +965,8 @@ Index: linux-2.6.git/include/linux/elf_ckpt.h
+ __u8 task_comm[CKPT_TASK_COMM_LEN]; + __u8 task_comm[CKPT_TASK_COMM_LEN];
+ __u32 task_flags; + __u32 task_flags;
+ __u64 mm_brk; + __u64 mm_brk;
+ __u64 mm_start_code;
+ __u64 mm_end_code;
+ }; + };
+ __u8 __core_pad[CKPT_CORE_SIZE]; + __u8 __core_pad[CKPT_CORE_SIZE];
+ }; + };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment