Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fork: replace simple_strtoul with kstrtoul in coredump_filter_setup

Replace simple_strtoul() with the recommended kstrtoul() for parsing the
'coredump_filter=' boot parameter.

Check the return value of kstrtoul() and reject invalid values. This adds
error handling while preserving behavior for existing values, and removes
use of the deprecated simple_strtoul() helper. The current code silently
sets 'default_dump_filter = 0' if parsing fails, instead of leaving the
default value (MMF_DUMP_FILTER_DEFAULT) unchanged.

Rename the static variable 'default_dump_filter' to 'coredump_filter'
since it does not necessarily contain the default value and the current
name can be misleading.

Link: https://lkml.kernel.org/r/20251215142152.4082-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Ben Segall <bsegall@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Thorsten Blum and committed by
Andrew Morton
380369ea 162e4fd9

+6 -5
+6 -5
kernel/fork.c
··· 1014 1014 1015 1015 __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock); 1016 1016 1017 - static unsigned long default_dump_filter = MMF_DUMP_FILTER_DEFAULT; 1017 + static unsigned long coredump_filter = MMF_DUMP_FILTER_DEFAULT; 1018 1018 1019 1019 static int __init coredump_filter_setup(char *s) 1020 1020 { 1021 - default_dump_filter = 1022 - (simple_strtoul(s, NULL, 0) << MMF_DUMP_FILTER_SHIFT) & 1023 - MMF_DUMP_FILTER_MASK; 1021 + if (kstrtoul(s, 0, &coredump_filter)) 1022 + return 0; 1023 + coredump_filter <<= MMF_DUMP_FILTER_SHIFT; 1024 + coredump_filter &= MMF_DUMP_FILTER_MASK; 1024 1025 return 1; 1025 1026 } 1026 1027 ··· 1107 1106 __mm_flags_overwrite_word(mm, mmf_init_legacy_flags(flags)); 1108 1107 mm->def_flags = current->mm->def_flags & VM_INIT_DEF_MASK; 1109 1108 } else { 1110 - __mm_flags_overwrite_word(mm, default_dump_filter); 1109 + __mm_flags_overwrite_word(mm, coredump_filter); 1111 1110 mm->def_flags = 0; 1112 1111 } 1113 1112