Commit 5ab1c309 authored by Denys Vlasenko's avatar Denys Vlasenko Committed by Linus Torvalds

coredump: pass siginfo_t* to do_coredump() and below, not merely signr

This is a preparatory patch for the introduction of NT_SIGINFO elf note.

With this patch we pass "siginfo_t *siginfo" instead of "int signr" to
do_coredump() and put it into coredump_params.  It will be used by the
next patch.  Most changes are simple s/signr/siginfo->si_signo/.
Signed-off-by: default avatarDenys Vlasenko <vda.linux@googlemail.com>
Reviewed-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Amerigo Wang <amwang@redhat.com>
Cc: "Jonathan M. Foote" <jmfoote@cert.org>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: Pedro Alves <palves@redhat.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0f4cfb2e
...@@ -65,7 +65,7 @@ static int aout_core_dump(struct coredump_params *cprm) ...@@ -65,7 +65,7 @@ static int aout_core_dump(struct coredump_params *cprm)
current->flags |= PF_DUMPCORE; current->flags |= PF_DUMPCORE;
strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
dump.u_ar0 = offsetof(struct user, regs); dump.u_ar0 = offsetof(struct user, regs);
dump.signal = cprm->signr; dump.signal = cprm->siginfo->si_signo;
aout_dump_thread(cprm->regs, &dump); aout_dump_thread(cprm->regs, &dump);
/* If the size of the dump file exceeds the rlimit, then see what would happen /* If the size of the dump file exceeds the rlimit, then see what would happen
......
...@@ -1480,7 +1480,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, ...@@ -1480,7 +1480,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
static int fill_note_info(struct elfhdr *elf, int phdrs, static int fill_note_info(struct elfhdr *elf, int phdrs,
struct elf_note_info *info, struct elf_note_info *info,
long signr, struct pt_regs *regs) siginfo_t *siginfo, struct pt_regs *regs)
{ {
struct task_struct *dump_task = current; struct task_struct *dump_task = current;
const struct user_regset_view *view = task_user_regset_view(dump_task); const struct user_regset_view *view = task_user_regset_view(dump_task);
...@@ -1550,7 +1550,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, ...@@ -1550,7 +1550,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
* Now fill in each thread's information. * Now fill in each thread's information.
*/ */
for (t = info->thread; t != NULL; t = t->next) for (t = info->thread; t != NULL; t = t->next)
if (!fill_thread_core_info(t, view, signr, &info->size)) if (!fill_thread_core_info(t, view, siginfo->si_signo, &info->size))
return 0; return 0;
/* /*
...@@ -1713,14 +1713,14 @@ static int elf_note_info_init(struct elf_note_info *info) ...@@ -1713,14 +1713,14 @@ static int elf_note_info_init(struct elf_note_info *info)
static int fill_note_info(struct elfhdr *elf, int phdrs, static int fill_note_info(struct elfhdr *elf, int phdrs,
struct elf_note_info *info, struct elf_note_info *info,
long signr, struct pt_regs *regs) siginfo_t *siginfo, struct pt_regs *regs)
{ {
struct list_head *t; struct list_head *t;
if (!elf_note_info_init(info)) if (!elf_note_info_init(info))
return 0; return 0;
if (signr) { if (siginfo->si_signo) {
struct core_thread *ct; struct core_thread *ct;
struct elf_thread_status *ets; struct elf_thread_status *ets;
...@@ -1738,13 +1738,13 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, ...@@ -1738,13 +1738,13 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
int sz; int sz;
ets = list_entry(t, struct elf_thread_status, list); ets = list_entry(t, struct elf_thread_status, list);
sz = elf_dump_thread_status(signr, ets); sz = elf_dump_thread_status(siginfo->si_signo, ets);
info->thread_status_size += sz; info->thread_status_size += sz;
} }
} }
/* now collect the dump for the current */ /* now collect the dump for the current */
memset(info->prstatus, 0, sizeof(*info->prstatus)); memset(info->prstatus, 0, sizeof(*info->prstatus));
fill_prstatus(info->prstatus, current, signr); fill_prstatus(info->prstatus, current, siginfo->si_signo);
elf_core_copy_regs(&info->prstatus->pr_reg, regs); elf_core_copy_regs(&info->prstatus->pr_reg, regs);
/* Set up header */ /* Set up header */
...@@ -1951,7 +1951,7 @@ static int elf_core_dump(struct coredump_params *cprm) ...@@ -1951,7 +1951,7 @@ static int elf_core_dump(struct coredump_params *cprm)
* Collect all the non-memory information about the process for the * Collect all the non-memory information about the process for the
* notes. This also sets up the file header. * notes. This also sets up the file header.
*/ */
if (!fill_note_info(elf, e_phnum, &info, cprm->signr, cprm->regs)) if (!fill_note_info(elf, e_phnum, &info, cprm->siginfo, cprm->regs))
goto cleanup; goto cleanup;
has_dumped = 1; has_dumped = 1;
......
...@@ -1642,7 +1642,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) ...@@ -1642,7 +1642,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
goto cleanup; goto cleanup;
#endif #endif
if (cprm->signr) { if (cprm->siginfo->si_signo) {
struct core_thread *ct; struct core_thread *ct;
struct elf_thread_status *tmp; struct elf_thread_status *tmp;
...@@ -1661,13 +1661,13 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) ...@@ -1661,13 +1661,13 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
int sz; int sz;
tmp = list_entry(t, struct elf_thread_status, list); tmp = list_entry(t, struct elf_thread_status, list);
sz = elf_dump_thread_status(cprm->signr, tmp); sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp);
thread_status_size += sz; thread_status_size += sz;
} }
} }
/* now collect the dump for the current */ /* now collect the dump for the current */
fill_prstatus(prstatus, current, cprm->signr); fill_prstatus(prstatus, current, cprm->siginfo->si_signo);
elf_core_copy_regs(&prstatus->pr_reg, cprm->regs); elf_core_copy_regs(&prstatus->pr_reg, cprm->regs);
segs = current->mm->map_count; segs = current->mm->map_count;
......
...@@ -107,7 +107,7 @@ static struct linux_binfmt flat_format = { ...@@ -107,7 +107,7 @@ static struct linux_binfmt flat_format = {
static int flat_core_dump(struct coredump_params *cprm) static int flat_core_dump(struct coredump_params *cprm)
{ {
printk("Process %s:%d received signr %d and should have core dumped\n", printk("Process %s:%d received signr %d and should have core dumped\n",
current->comm, current->pid, (int) cprm->signr); current->comm, current->pid, (int) cprm->siginfo->si_signo);
return(1); return(1);
} }
......
...@@ -200,7 +200,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm) ...@@ -200,7 +200,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
break; break;
/* signal that caused the coredump */ /* signal that caused the coredump */
case 's': case 's':
err = cn_printf(cn, "%ld", cprm->signr); err = cn_printf(cn, "%ld", cprm->siginfo->si_signo);
break; break;
/* UNIX time of coredump */ /* UNIX time of coredump */
case 't': { case 't': {
...@@ -457,7 +457,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) ...@@ -457,7 +457,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
return 0; return 0;
} }
void do_coredump(long signr, int exit_code, struct pt_regs *regs) void do_coredump(siginfo_t *siginfo, struct pt_regs *regs)
{ {
struct core_state core_state; struct core_state core_state;
struct core_name cn; struct core_name cn;
...@@ -472,7 +472,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) ...@@ -472,7 +472,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
bool need_nonrelative = false; bool need_nonrelative = false;
static atomic_t core_dump_count = ATOMIC_INIT(0); static atomic_t core_dump_count = ATOMIC_INIT(0);
struct coredump_params cprm = { struct coredump_params cprm = {
.signr = signr, .siginfo = siginfo,
.regs = regs, .regs = regs,
.limit = rlimit(RLIMIT_CORE), .limit = rlimit(RLIMIT_CORE),
/* /*
...@@ -483,7 +483,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) ...@@ -483,7 +483,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
.mm_flags = mm->flags, .mm_flags = mm->flags,
}; };
audit_core_dumps(signr); audit_core_dumps(siginfo->si_signo);
binfmt = mm->binfmt; binfmt = mm->binfmt;
if (!binfmt || !binfmt->core_dump) if (!binfmt || !binfmt->core_dump)
...@@ -507,7 +507,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) ...@@ -507,7 +507,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
need_nonrelative = true; need_nonrelative = true;
} }
retval = coredump_wait(exit_code, &core_state); retval = coredump_wait(siginfo->si_signo, &core_state);
if (retval < 0) if (retval < 0)
goto fail_creds; goto fail_creds;
......
...@@ -72,7 +72,7 @@ struct linux_binprm { ...@@ -72,7 +72,7 @@ struct linux_binprm {
/* Function parameter for binfmt->coredump */ /* Function parameter for binfmt->coredump */
struct coredump_params { struct coredump_params {
long signr; siginfo_t *siginfo;
struct pt_regs *regs; struct pt_regs *regs;
struct file *file; struct file *file;
unsigned long limit; unsigned long limit;
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
extern int dump_write(struct file *file, const void *addr, int nr); extern int dump_write(struct file *file, const void *addr, int nr);
extern int dump_seek(struct file *file, loff_t off); extern int dump_seek(struct file *file, loff_t off);
#ifdef CONFIG_COREDUMP #ifdef CONFIG_COREDUMP
extern void do_coredump(long signr, int exit_code, struct pt_regs *regs); extern void do_coredump(siginfo_t *siginfo, struct pt_regs *regs);
#else #else
static inline void do_coredump(long signr, int exit_code, struct pt_regs *regs) {} static inline void do_coredump(siginfo_t *siginfo, struct pt_regs *regs) {}
#endif #endif
#endif /* _LINUX_COREDUMP_H */ #endif /* _LINUX_COREDUMP_H */
...@@ -2360,7 +2360,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, ...@@ -2360,7 +2360,7 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
* first and our do_group_exit call below will use * first and our do_group_exit call below will use
* that value and ignore the one we pass it. * that value and ignore the one we pass it.
*/ */
do_coredump(info->si_signo, info->si_signo, regs); do_coredump(info, regs);
} }
/* /*
......
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