diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/binfmt_aout.c | 16 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 5 | ||||
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 5 | ||||
-rw-r--r-- | fs/binfmt_flat.c | 4 | ||||
-rw-r--r-- | fs/binfmt_som.c | 2 | ||||
-rw-r--r-- | fs/exec.c | 19 |
6 files changed, 28 insertions, 23 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 813a887cd2b3..e176d195e7e5 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); | 32 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); |
33 | static int load_aout_library(struct file*); | 33 | static int load_aout_library(struct file*); |
34 | static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file); | 34 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); |
35 | 35 | ||
36 | static struct linux_binfmt aout_format = { | 36 | static struct linux_binfmt aout_format = { |
37 | .module = THIS_MODULE, | 37 | .module = THIS_MODULE, |
@@ -88,7 +88,7 @@ if (file->f_op->llseek) { \ | |||
88 | * dumping of the process results in another error.. | 88 | * dumping of the process results in another error.. |
89 | */ | 89 | */ |
90 | 90 | ||
91 | static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file) | 91 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) |
92 | { | 92 | { |
93 | mm_segment_t fs; | 93 | mm_segment_t fs; |
94 | int has_dumped = 0; | 94 | int has_dumped = 0; |
@@ -123,23 +123,19 @@ static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file) | |||
123 | /* If the size of the dump file exceeds the rlimit, then see what would happen | 123 | /* If the size of the dump file exceeds the rlimit, then see what would happen |
124 | if we wrote the stack, but not the data area. */ | 124 | if we wrote the stack, but not the data area. */ |
125 | #ifdef __sparc__ | 125 | #ifdef __sparc__ |
126 | if ((dump.u_dsize+dump.u_ssize) > | 126 | if ((dump.u_dsize + dump.u_ssize) > limit) |
127 | current->signal->rlim[RLIMIT_CORE].rlim_cur) | ||
128 | dump.u_dsize = 0; | 127 | dump.u_dsize = 0; |
129 | #else | 128 | #else |
130 | if ((dump.u_dsize+dump.u_ssize+1) * PAGE_SIZE > | 129 | if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit) |
131 | current->signal->rlim[RLIMIT_CORE].rlim_cur) | ||
132 | dump.u_dsize = 0; | 130 | dump.u_dsize = 0; |
133 | #endif | 131 | #endif |
134 | 132 | ||
135 | /* Make sure we have enough room to write the stack and data areas. */ | 133 | /* Make sure we have enough room to write the stack and data areas. */ |
136 | #ifdef __sparc__ | 134 | #ifdef __sparc__ |
137 | if ((dump.u_ssize) > | 135 | if (dump.u_ssize > limit) |
138 | current->signal->rlim[RLIMIT_CORE].rlim_cur) | ||
139 | dump.u_ssize = 0; | 136 | dump.u_ssize = 0; |
140 | #else | 137 | #else |
141 | if ((dump.u_ssize+1) * PAGE_SIZE > | 138 | if ((dump.u_ssize + 1) * PAGE_SIZE > limit) |
142 | current->signal->rlim[RLIMIT_CORE].rlim_cur) | ||
143 | dump.u_ssize = 0; | 139 | dump.u_ssize = 0; |
144 | #endif | 140 | #endif |
145 | 141 | ||
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 2f31c4c3fd48..3dc6a123fa10 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -52,7 +52,7 @@ static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, i | |||
52 | * don't even try. | 52 | * don't even try. |
53 | */ | 53 | */ |
54 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 54 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) |
55 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file); | 55 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); |
56 | #else | 56 | #else |
57 | #define elf_core_dump NULL | 57 | #define elf_core_dump NULL |
58 | #endif | 58 | #endif |
@@ -1488,7 +1488,7 @@ static struct vm_area_struct *next_vma(struct vm_area_struct *this_vma, | |||
1488 | * and then they are actually written out. If we run out of core limit | 1488 | * and then they are actually written out. If we run out of core limit |
1489 | * we just truncate. | 1489 | * we just truncate. |
1490 | */ | 1490 | */ |
1491 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | 1491 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) |
1492 | { | 1492 | { |
1493 | #define NUM_NOTES 6 | 1493 | #define NUM_NOTES 6 |
1494 | int has_dumped = 0; | 1494 | int has_dumped = 0; |
@@ -1499,7 +1499,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) | |||
1499 | struct vm_area_struct *vma, *gate_vma; | 1499 | struct vm_area_struct *vma, *gate_vma; |
1500 | struct elfhdr *elf = NULL; | 1500 | struct elfhdr *elf = NULL; |
1501 | loff_t offset = 0, dataoff, foffset; | 1501 | loff_t offset = 0, dataoff, foffset; |
1502 | unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; | ||
1503 | int numnote; | 1502 | int numnote; |
1504 | struct memelfnote *notes = NULL; | 1503 | struct memelfnote *notes = NULL; |
1505 | struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */ | 1504 | struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */ |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index faae02189598..033861c6b8f1 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -75,7 +75,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *, | |||
75 | struct file *, struct mm_struct *); | 75 | struct file *, struct mm_struct *); |
76 | 76 | ||
77 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 77 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) |
78 | static int elf_fdpic_core_dump(long, struct pt_regs *, struct file *); | 78 | static int elf_fdpic_core_dump(long, struct pt_regs *, struct file *, unsigned long limit); |
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | static struct linux_binfmt elf_fdpic_format = { | 81 | static struct linux_binfmt elf_fdpic_format = { |
@@ -1552,7 +1552,7 @@ static int elf_fdpic_dump_segments(struct file *file, size_t *size, | |||
1552 | * we just truncate. | 1552 | * we just truncate. |
1553 | */ | 1553 | */ |
1554 | static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | 1554 | static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, |
1555 | struct file *file) | 1555 | struct file *file, unsigned long limit) |
1556 | { | 1556 | { |
1557 | #define NUM_NOTES 6 | 1557 | #define NUM_NOTES 6 |
1558 | int has_dumped = 0; | 1558 | int has_dumped = 0; |
@@ -1563,7 +1563,6 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
1563 | struct vm_area_struct *vma; | 1563 | struct vm_area_struct *vma; |
1564 | struct elfhdr *elf = NULL; | 1564 | struct elfhdr *elf = NULL; |
1565 | loff_t offset = 0, dataoff; | 1565 | loff_t offset = 0, dataoff; |
1566 | unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; | ||
1567 | int numnote; | 1566 | int numnote; |
1568 | struct memelfnote *notes = NULL; | 1567 | struct memelfnote *notes = NULL; |
1569 | struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */ | 1568 | struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */ |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index fcb3405bb14e..265fac868067 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -75,7 +75,7 @@ static int load_flat_shared_library(int id, struct lib_info *p); | |||
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs); | 77 | static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs); |
78 | static int flat_core_dump(long signr, struct pt_regs * regs, struct file *file); | 78 | static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); |
79 | 79 | ||
80 | static struct linux_binfmt flat_format = { | 80 | static struct linux_binfmt flat_format = { |
81 | .module = THIS_MODULE, | 81 | .module = THIS_MODULE, |
@@ -90,7 +90,7 @@ static struct linux_binfmt flat_format = { | |||
90 | * Currently only a stub-function. | 90 | * Currently only a stub-function. |
91 | */ | 91 | */ |
92 | 92 | ||
93 | static int flat_core_dump(long signr, struct pt_regs * regs, struct file *file) | 93 | static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) |
94 | { | 94 | { |
95 | printk("Process %s:%d received signr %d and should have core dumped\n", | 95 | printk("Process %s:%d received signr %d and should have core dumped\n", |
96 | current->comm, current->pid, (int) signr); | 96 | current->comm, current->pid, (int) signr); |
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c index 5bcdaaf4eae0..9208c41209f9 100644 --- a/fs/binfmt_som.c +++ b/fs/binfmt_som.c | |||
@@ -44,7 +44,7 @@ static int load_som_library(struct file *); | |||
44 | * don't even try. | 44 | * don't even try. |
45 | */ | 45 | */ |
46 | #if 0 | 46 | #if 0 |
47 | static int som_core_dump(long signr, struct pt_regs * regs); | 47 | static int som_core_dump(long signr, struct pt_regs *regs, unsigned long limit); |
48 | #else | 48 | #else |
49 | #define som_core_dump NULL | 49 | #define som_core_dump NULL |
50 | #endif | 50 | #endif |
@@ -1697,6 +1697,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
1697 | int fsuid = current->fsuid; | 1697 | int fsuid = current->fsuid; |
1698 | int flag = 0; | 1698 | int flag = 0; |
1699 | int ispipe = 0; | 1699 | int ispipe = 0; |
1700 | unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; | ||
1700 | 1701 | ||
1701 | audit_core_dumps(signr); | 1702 | audit_core_dumps(signr); |
1702 | 1703 | ||
@@ -1730,9 +1731,6 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
1730 | */ | 1731 | */ |
1731 | clear_thread_flag(TIF_SIGPENDING); | 1732 | clear_thread_flag(TIF_SIGPENDING); |
1732 | 1733 | ||
1733 | if (current->signal->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump) | ||
1734 | goto fail_unlock; | ||
1735 | |||
1736 | /* | 1734 | /* |
1737 | * lock_kernel() because format_corename() is controlled by sysctl, which | 1735 | * lock_kernel() because format_corename() is controlled by sysctl, which |
1738 | * uses lock_kernel() | 1736 | * uses lock_kernel() |
@@ -1740,7 +1738,20 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
1740 | lock_kernel(); | 1738 | lock_kernel(); |
1741 | ispipe = format_corename(corename, core_pattern, signr); | 1739 | ispipe = format_corename(corename, core_pattern, signr); |
1742 | unlock_kernel(); | 1740 | unlock_kernel(); |
1741 | /* | ||
1742 | * Don't bother to check the RLIMIT_CORE value if core_pattern points | ||
1743 | * to a pipe. Since we're not writing directly to the filesystem | ||
1744 | * RLIMIT_CORE doesn't really apply, as no actual core file will be | ||
1745 | * created unless the pipe reader choses to write out the core file | ||
1746 | * at which point file size limits and permissions will be imposed | ||
1747 | * as it does with any other process | ||
1748 | */ | ||
1749 | if ((!ispipe) && | ||
1750 | (core_limit < binfmt->min_coredump)) | ||
1751 | goto fail_unlock; | ||
1752 | |||
1743 | if (ispipe) { | 1753 | if (ispipe) { |
1754 | core_limit = RLIM_INFINITY; | ||
1744 | /* SIGPIPE can happen, but it's just never processed */ | 1755 | /* SIGPIPE can happen, but it's just never processed */ |
1745 | if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) { | 1756 | if(call_usermodehelper_pipe(corename+1, NULL, NULL, &file)) { |
1746 | printk(KERN_INFO "Core dump to %s pipe failed\n", | 1757 | printk(KERN_INFO "Core dump to %s pipe failed\n", |
@@ -1770,7 +1781,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) | |||
1770 | if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0) | 1781 | if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0) |
1771 | goto close_fail; | 1782 | goto close_fail; |
1772 | 1783 | ||
1773 | retval = binfmt->core_dump(signr, regs, file); | 1784 | retval = binfmt->core_dump(signr, regs, file, core_limit); |
1774 | 1785 | ||
1775 | if (retval) | 1786 | if (retval) |
1776 | current->signal->group_exit_code |= 0x80; | 1787 | current->signal->group_exit_code |= 0x80; |