Skip to content

Commit afabada

Browse files
author
Al Viro
committed
elf{,_fdpic} coredump: get rid of pointless if (siginfo->si_signo)
we can't get to do_coredump() if that condition isn't satisfied... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent ec57941 commit afabada

2 files changed

Lines changed: 31 additions & 37 deletions

File tree

‎fs/binfmt_elf.c‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,31 +1833,28 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,
18331833
const siginfo_t *siginfo, struct pt_regs *regs)
18341834
{
18351835
struct list_head *t;
1836+
struct core_thread *ct;
1837+
struct elf_thread_status *ets;
18361838

18371839
if (!elf_note_info_init(info))
18381840
return 0;
18391841

1840-
if (siginfo->si_signo) {
1841-
struct core_thread *ct;
1842-
struct elf_thread_status *ets;
1843-
1844-
for (ct = current->mm->core_state->dumper.next;
1845-
ct; ct = ct->next) {
1846-
ets = kzalloc(sizeof(*ets), GFP_KERNEL);
1847-
if (!ets)
1848-
return 0;
1842+
for (ct = current->mm->core_state->dumper.next;
1843+
ct; ct = ct->next) {
1844+
ets = kzalloc(sizeof(*ets), GFP_KERNEL);
1845+
if (!ets)
1846+
return 0;
18491847

1850-
ets->thread = ct->task;
1851-
list_add(&ets->list, &info->thread_list);
1852-
}
1848+
ets->thread = ct->task;
1849+
list_add(&ets->list, &info->thread_list);
1850+
}
18531851

1854-
list_for_each(t, &info->thread_list) {
1855-
int sz;
1852+
list_for_each(t, &info->thread_list) {
1853+
int sz;
18561854

1857-
ets = list_entry(t, struct elf_thread_status, list);
1858-
sz = elf_dump_thread_status(siginfo->si_signo, ets);
1859-
info->thread_status_size += sz;
1860-
}
1855+
ets = list_entry(t, struct elf_thread_status, list);
1856+
sz = elf_dump_thread_status(siginfo->si_signo, ets);
1857+
info->thread_status_size += sz;
18611858
}
18621859
/* now collect the dump for the current */
18631860
memset(info->prstatus, 0, sizeof(*info->prstatus));

‎fs/binfmt_elf_fdpic.c‎

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,8 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15611561
struct elf_shdr *shdr4extnum = NULL;
15621562
Elf_Half e_phnum;
15631563
elf_addr_t e_shoff;
1564+
struct core_thread *ct;
1565+
struct elf_thread_status *tmp;
15641566

15651567
/*
15661568
* We no longer stop all VM operations.
@@ -1596,28 +1598,23 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15961598
goto cleanup;
15971599
#endif
15981600

1599-
if (cprm->siginfo->si_signo) {
1600-
struct core_thread *ct;
1601-
struct elf_thread_status *tmp;
1602-
1603-
for (ct = current->mm->core_state->dumper.next;
1604-
ct; ct = ct->next) {
1605-
tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
1606-
if (!tmp)
1607-
goto cleanup;
1601+
for (ct = current->mm->core_state->dumper.next;
1602+
ct; ct = ct->next) {
1603+
tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
1604+
if (!tmp)
1605+
goto cleanup;
16081606

1609-
tmp->thread = ct->task;
1610-
list_add(&tmp->list, &thread_list);
1611-
}
1607+
tmp->thread = ct->task;
1608+
list_add(&tmp->list, &thread_list);
1609+
}
16121610

1613-
list_for_each(t, &thread_list) {
1614-
struct elf_thread_status *tmp;
1615-
int sz;
1611+
list_for_each(t, &thread_list) {
1612+
struct elf_thread_status *tmp;
1613+
int sz;
16161614

1617-
tmp = list_entry(t, struct elf_thread_status, list);
1618-
sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp);
1619-
thread_status_size += sz;
1620-
}
1615+
tmp = list_entry(t, struct elf_thread_status, list);
1616+
sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp);
1617+
thread_status_size += sz;
16211618
}
16221619

16231620
/* now collect the dump for the current */

0 commit comments

Comments
 (0)