aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/proc.txt15
-rw-r--r--fs/binfmt_elf.c12
-rw-r--r--include/linux/sched.h7
3 files changed, 25 insertions, 9 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index c032bf39e8b9..02cb7faeed6b 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -2412,24 +2412,29 @@ will be dumped when the <pid> process is dumped. coredump_filter is a bitmask
2412of memory types. If a bit of the bitmask is set, memory segments of the 2412of memory types. If a bit of the bitmask is set, memory segments of the
2413corresponding memory type are dumped, otherwise they are not dumped. 2413corresponding memory type are dumped, otherwise they are not dumped.
2414 2414
2415The following 4 memory types are supported: 2415The following 7 memory types are supported:
2416 - (bit 0) anonymous private memory 2416 - (bit 0) anonymous private memory
2417 - (bit 1) anonymous shared memory 2417 - (bit 1) anonymous shared memory
2418 - (bit 2) file-backed private memory 2418 - (bit 2) file-backed private memory
2419 - (bit 3) file-backed shared memory 2419 - (bit 3) file-backed shared memory
2420 - (bit 4) ELF header pages in file-backed private memory areas (it is 2420 - (bit 4) ELF header pages in file-backed private memory areas (it is
2421 effective only if the bit 2 is cleared) 2421 effective only if the bit 2 is cleared)
2422 - (bit 5) hugetlb private memory
2423 - (bit 6) hugetlb shared memory
2422 2424
2423 Note that MMIO pages such as frame buffer are never dumped and vDSO pages 2425 Note that MMIO pages such as frame buffer are never dumped and vDSO pages
2424 are always dumped regardless of the bitmask status. 2426 are always dumped regardless of the bitmask status.
2425 2427
2426Default value of coredump_filter is 0x3; this means all anonymous memory 2428 Note bit 0-4 doesn't effect any hugetlb memory. hugetlb memory are only
2427segments are dumped. 2429 effected by bit 5-6.
2430
2431Default value of coredump_filter is 0x23; this means all anonymous memory
2432segments and hugetlb private memory are dumped.
2428 2433
2429If you don't want to dump all shared memory segments attached to pid 1234, 2434If you don't want to dump all shared memory segments attached to pid 1234,
2430write 1 to the process's proc file. 2435write 0x21 to the process's proc file.
2431 2436
2432 $ echo 0x1 > /proc/1234/coredump_filter 2437 $ echo 0x21 > /proc/1234/coredump_filter
2433 2438
2434When a new process is created, the process inherits the bitmask status from its 2439When a new process is created, the process inherits the bitmask status from its
2435parent. It is useful to set up coredump_filter before the program runs. 2440parent. It is useful to set up coredump_filter before the program runs.
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index c76afa26edf7..e2159063198a 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1156,16 +1156,24 @@ static int dump_seek(struct file *file, loff_t off)
1156static unsigned long vma_dump_size(struct vm_area_struct *vma, 1156static unsigned long vma_dump_size(struct vm_area_struct *vma,
1157 unsigned long mm_flags) 1157 unsigned long mm_flags)
1158{ 1158{
1159#define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
1160
1159 /* The vma can be set up to tell us the answer directly. */ 1161 /* The vma can be set up to tell us the answer directly. */
1160 if (vma->vm_flags & VM_ALWAYSDUMP) 1162 if (vma->vm_flags & VM_ALWAYSDUMP)
1161 goto whole; 1163 goto whole;
1162 1164
1165 /* Hugetlb memory check */
1166 if (vma->vm_flags & VM_HUGETLB) {
1167 if ((vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_SHARED))
1168 goto whole;
1169 if (!(vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_PRIVATE))
1170 goto whole;
1171 }
1172
1163 /* Do not dump I/O mapped devices or special mappings */ 1173 /* Do not dump I/O mapped devices or special mappings */
1164 if (vma->vm_flags & (VM_IO | VM_RESERVED)) 1174 if (vma->vm_flags & (VM_IO | VM_RESERVED))
1165 return 0; 1175 return 0;
1166 1176
1167#define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
1168
1169 /* By default, dump shared memory if mapped from an anonymous file. */ 1177 /* By default, dump shared memory if mapped from an anonymous file. */
1170 if (vma->vm_flags & VM_SHARED) { 1178 if (vma->vm_flags & VM_SHARED) {
1171 if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0 ? 1179 if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0 ?
diff --git a/include/linux/sched.h b/include/linux/sched.h
index c226c7b82946..017cc914ef1f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -403,12 +403,15 @@ extern int get_dumpable(struct mm_struct *mm);
403#define MMF_DUMP_MAPPED_PRIVATE 4 403#define MMF_DUMP_MAPPED_PRIVATE 4
404#define MMF_DUMP_MAPPED_SHARED 5 404#define MMF_DUMP_MAPPED_SHARED 5
405#define MMF_DUMP_ELF_HEADERS 6 405#define MMF_DUMP_ELF_HEADERS 6
406#define MMF_DUMP_HUGETLB_PRIVATE 7
407#define MMF_DUMP_HUGETLB_SHARED 8
406#define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS 408#define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS
407#define MMF_DUMP_FILTER_BITS 5 409#define MMF_DUMP_FILTER_BITS 7
408#define MMF_DUMP_FILTER_MASK \ 410#define MMF_DUMP_FILTER_MASK \
409 (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT) 411 (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
410#define MMF_DUMP_FILTER_DEFAULT \ 412#define MMF_DUMP_FILTER_DEFAULT \
411 ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED)) 413 ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED) |\
414 (1 << MMF_DUMP_HUGETLB_PRIVATE))
412 415
413struct sighand_struct { 416struct sighand_struct {
414 atomic_t count; 417 atomic_t count;