@@ -1482,7 +1482,8 @@ static struct elf_thread_status *elf_dump_thread_status(long signr, struct task_
1482
1482
t -> num_notes ++ ;
1483
1483
* sz += notesize (& t -> notes [0 ]);
1484
1484
1485
- t -> prstatus .pr_fpvalid = elf_core_copy_task_fpregs (p , NULL , & t -> fpu );
1485
+ t -> prstatus .pr_fpvalid = elf_core_copy_task_fpregs (p , task_pt_regs (p ),
1486
+ & t -> fpu );
1486
1487
if (t -> prstatus .pr_fpvalid ) {
1487
1488
fill_note (& t -> notes [1 ], "CORE" , NT_PRFPREG , sizeof (t -> fpu ),
1488
1489
& t -> fpu );
@@ -1568,19 +1569,15 @@ static size_t elf_core_vma_data_size(unsigned long mm_flags)
1568
1569
*/
1569
1570
static int elf_fdpic_core_dump (struct coredump_params * cprm )
1570
1571
{
1571
- #define NUM_NOTES 6
1572
1572
int has_dumped = 0 ;
1573
1573
int segs ;
1574
1574
int i ;
1575
1575
struct vm_area_struct * vma ;
1576
1576
struct elfhdr * elf = NULL ;
1577
1577
loff_t offset = 0 , dataoff ;
1578
- int numnote ;
1579
- struct memelfnote * notes = NULL ;
1580
- struct elf_prstatus_fdpic * prstatus = NULL ; /* NT_PRSTATUS */
1578
+ struct memelfnote psinfo_note , auxv_note ;
1581
1579
struct elf_prpsinfo * psinfo = NULL ; /* NT_PRPSINFO */
1582
1580
struct elf_thread_status * thread_list = NULL ;
1583
- elf_fpregset_t * fpu = NULL ;
1584
1581
int thread_status_size = 0 ;
1585
1582
elf_addr_t * auxv ;
1586
1583
struct elf_phdr * phdr4note = NULL ;
@@ -1606,19 +1603,9 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
1606
1603
elf = kmalloc (sizeof (* elf ), GFP_KERNEL );
1607
1604
if (!elf )
1608
1605
goto end_coredump ;
1609
- prstatus = kzalloc (sizeof (* prstatus ), GFP_KERNEL );
1610
- if (!prstatus )
1611
- goto end_coredump ;
1612
1606
psinfo = kmalloc (sizeof (* psinfo ), GFP_KERNEL );
1613
1607
if (!psinfo )
1614
1608
goto end_coredump ;
1615
- notes = kmalloc_array (NUM_NOTES , sizeof (struct memelfnote ),
1616
- GFP_KERNEL );
1617
- if (!notes )
1618
- goto end_coredump ;
1619
- fpu = kmalloc (sizeof (* fpu ), GFP_KERNEL );
1620
- if (!fpu )
1621
- goto end_coredump ;
1622
1609
1623
1610
for (ct = current -> mm -> core_state -> dumper .next ;
1624
1611
ct ; ct = ct -> next ) {
@@ -1632,8 +1619,12 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
1632
1619
}
1633
1620
1634
1621
/* now collect the dump for the current */
1635
- fill_prstatus (prstatus , current , cprm -> siginfo -> si_signo );
1636
- elf_core_copy_regs (& prstatus -> pr_reg , cprm -> regs );
1622
+ tmp = elf_dump_thread_status (cprm -> siginfo -> si_signo ,
1623
+ current , & thread_status_size );
1624
+ if (!tmp )
1625
+ goto end_coredump ;
1626
+ tmp -> next = thread_list ;
1627
+ thread_list = tmp ;
1637
1628
1638
1629
segs = current -> mm -> map_count ;
1639
1630
segs += elf_core_extra_phdrs ();
@@ -1655,46 +1646,28 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
1655
1646
* with info from their /proc.
1656
1647
*/
1657
1648
1658
- fill_note (notes + 0 , "CORE" , NT_PRSTATUS , sizeof (* prstatus ), prstatus );
1659
1649
fill_psinfo (psinfo , current -> group_leader , current -> mm );
1660
- fill_note (notes + 1 , "CORE" , NT_PRPSINFO , sizeof (* psinfo ), psinfo );
1661
-
1662
- numnote = 2 ;
1650
+ fill_note (& psinfo_note , "CORE" , NT_PRPSINFO , sizeof (* psinfo ), psinfo );
1651
+ thread_status_size += notesize (& psinfo_note );
1663
1652
1664
1653
auxv = (elf_addr_t * ) current -> mm -> saved_auxv ;
1665
-
1666
1654
i = 0 ;
1667
1655
do
1668
1656
i += 2 ;
1669
1657
while (auxv [i - 2 ] != AT_NULL );
1670
- fill_note (& notes [ numnote ++ ] , "CORE" , NT_AUXV ,
1671
- i * sizeof ( elf_addr_t ), auxv );
1658
+ fill_note (& auxv_note , "CORE" , NT_AUXV , i * sizeof ( elf_addr_t ), auxv );
1659
+ thread_status_size += notesize ( & auxv_note );
1672
1660
1673
- /* Try to dump the FPU. */
1674
- if ((prstatus -> pr_fpvalid =
1675
- elf_core_copy_task_fpregs (current , cprm -> regs , fpu )))
1676
- fill_note (notes + numnote ++ ,
1677
- "CORE" , NT_PRFPREG , sizeof (* fpu ), fpu );
1678
-
1679
- offset += sizeof (* elf ); /* Elf header */
1661
+ offset = sizeof (* elf ); /* Elf header */
1680
1662
offset += segs * sizeof (struct elf_phdr ); /* Program headers */
1681
1663
1682
1664
/* Write notes phdr entry */
1683
- {
1684
- int sz = 0 ;
1685
-
1686
- for (i = 0 ; i < numnote ; i ++ )
1687
- sz += notesize (notes + i );
1688
-
1689
- sz += thread_status_size ;
1690
-
1691
- phdr4note = kmalloc (sizeof (* phdr4note ), GFP_KERNEL );
1692
- if (!phdr4note )
1693
- goto end_coredump ;
1665
+ phdr4note = kmalloc (sizeof (* phdr4note ), GFP_KERNEL );
1666
+ if (!phdr4note )
1667
+ goto end_coredump ;
1694
1668
1695
- fill_elf_note_phdr (phdr4note , sz , offset );
1696
- offset += sz ;
1697
- }
1669
+ fill_elf_note_phdr (phdr4note , thread_status_size , offset );
1670
+ offset += thread_status_size ;
1698
1671
1699
1672
/* Page-align dumped data */
1700
1673
dataoff = offset = roundup (offset , ELF_EXEC_PAGESIZE );
@@ -1747,12 +1720,18 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
1747
1720
goto end_coredump ;
1748
1721
1749
1722
/* write out the notes section */
1750
- for (i = 0 ; i < numnote ; i ++ )
1751
- if (!writenote (notes + i , cprm ))
1723
+ if (!writenote (thread_list -> notes , cprm ))
1724
+ goto end_coredump ;
1725
+ if (!writenote (& psinfo_note , cprm ))
1726
+ goto end_coredump ;
1727
+ if (!writenote (& auxv_note , cprm ))
1728
+ goto end_coredump ;
1729
+ for (i = 1 ; i < thread_list -> num_notes ; i ++ )
1730
+ if (!writenote (thread_list -> notes + i , cprm ))
1752
1731
goto end_coredump ;
1753
1732
1754
1733
/* write out the thread status notes section */
1755
- for (tmp = thread_list ; tmp ; tmp = tmp -> next ) {
1734
+ for (tmp = thread_list -> next ; tmp ; tmp = tmp -> next ) {
1756
1735
for (i = 0 ; i < tmp -> num_notes ; i ++ )
1757
1736
if (!writenote (& tmp -> notes [i ], cprm ))
1758
1737
goto end_coredump ;
@@ -1787,13 +1766,9 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
1787
1766
}
1788
1767
kfree (phdr4note );
1789
1768
kfree (elf );
1790
- kfree (prstatus );
1791
1769
kfree (psinfo );
1792
- kfree (notes );
1793
- kfree (fpu );
1794
1770
kfree (shdr4extnum );
1795
1771
return has_dumped ;
1796
- #undef NUM_NOTES
1797
1772
}
1798
1773
1799
1774
#endif /* CONFIG_ELF_CORE */
0 commit comments