Commit 4cb0e11b15d2badad455fcd538af0cccf05dc012

Authored by Hidehiro Kawai
Committed by Linus Torvalds
1 parent 9cd4fd1043

coredump_filter: permit changing of the default filter

Introduce a new kernel parameter `coredump_filter'.  Setting a value to
this parameter causes the default bitmask of coredump_filter to be
changed.

It is useful for users to change coredump_filter settings for the whole
system at boot time.  Without this parameter, users have to change
coredump_filter settings for each /proc/<pid>/ in an initializing script.

Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 18 additions and 2 deletions Side-by-side Diff

Documentation/kernel-parameters.txt
... ... @@ -551,6 +551,11 @@
551 551 not work reliably with all consoles, but is known
552 552 to work with serial and VGA consoles.
553 553  
  554 + coredump_filter=
  555 + [KNL] Change the default value for
  556 + /proc/<pid>/coredump_filter.
  557 + See also Documentation/filesystems/proc.txt.
  558 +
554 559 cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver
555 560 Format:
556 561 <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
... ... @@ -400,6 +400,18 @@
400 400 #define allocate_mm() (kmem_cache_alloc(mm_cachep, GFP_KERNEL))
401 401 #define free_mm(mm) (kmem_cache_free(mm_cachep, (mm)))
402 402  
  403 +static unsigned long default_dump_filter = MMF_DUMP_FILTER_DEFAULT;
  404 +
  405 +static int __init coredump_filter_setup(char *s)
  406 +{
  407 + default_dump_filter =
  408 + (simple_strtoul(s, NULL, 0) << MMF_DUMP_FILTER_SHIFT) &
  409 + MMF_DUMP_FILTER_MASK;
  410 + return 1;
  411 +}
  412 +
  413 +__setup("coredump_filter=", coredump_filter_setup);
  414 +
403 415 #include <linux/init_task.h>
404 416  
405 417 static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p)
... ... @@ -408,8 +420,7 @@
408 420 atomic_set(&mm->mm_count, 1);
409 421 init_rwsem(&mm->mmap_sem);
410 422 INIT_LIST_HEAD(&mm->mmlist);
411   - mm->flags = (current->mm) ? current->mm->flags
412   - : MMF_DUMP_FILTER_DEFAULT;
  423 + mm->flags = (current->mm) ? current->mm->flags : default_dump_filter;
413 424 mm->core_state = NULL;
414 425 mm->nr_ptes = 0;
415 426 set_mm_counter(mm, file_rss, 0);