From nobody Wed Dec 17 03:58:29 2025 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 858CC7082D for ; Mon, 15 Dec 2025 14:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765808556; cv=none; b=j3vIgZh5Pc3FtjbUKHdacAyPIXerYQWTR4dQCyQGx6zF4XUUM0Q1BK7eJJPhIofswAm8qqFTPRAw15+W7fT6bTltX+fXi3wKfXjYpgcTLq+x68Vyn4glYL0qfCHBtRxTzDqJgEBin1NxLLzEeTAAdWXXOgbbGOekHOVJCT8YvhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765808556; c=relaxed/simple; bh=VVxlGRJqgm6h/A2F29eEBc68kiajVqMaNL+Jct7i4Rc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=P9BLw63eQT8RkHuSaZN6hHBvvV7J5PsryFNSWU+sjVZb2D8PBjO00EyTgEp9cc03Mk47OgkoZOwBO5kToZKeNVLX5ntiGRngoiNAI8HOyo+XogeHlNJkusiJUG6931fh7Sw5Q6xn8lDjo/mpi5FziC+nPdD6UHDMQDJRENrR5Wk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=X4MVnBCq; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="X4MVnBCq" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1765808547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CvrumJAslAc1VCvcVwMaYcAZmX60tTP0CKkJ3CwjBvA=; b=X4MVnBCq3TuzMMFEHdiDHgjOKrU5telV2QGDdWrd0jZWwybBSbH3Wd5IbvSMxu/9ClYcYH j1SOnveZPw6UehtJaEFsmevAYtk5dP5zmUsZoo3uXUTU2oLI8b5Z6HNmSDDnCM1ZgJeonC qs2aBd7aaVnaP3pse6EsDMdbXD+dPsQ= From: Thorsten Blum To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook Cc: Thorsten Blum , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] fork: Replace simple_strtoul with kstrtoul in coredump_filter_setup Date: Mon, 15 Dec 2025 15:21:52 +0100 Message-ID: <20251215142152.4082-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace simple_strtoul() with the recommended kstrtoul() for parsing the 'coredump_filter=3D' 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 =3D 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. Signed-off-by: Thorsten Blum --- kernel/fork.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index b1f3915d5f8e..f33ee7fe53ad 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1012,13 +1012,14 @@ static struct task_struct *dup_task_struct(struct t= ask_struct *orig, int node) =20 __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock); =20 -static unsigned long default_dump_filter =3D MMF_DUMP_FILTER_DEFAULT; +static unsigned long coredump_filter =3D MMF_DUMP_FILTER_DEFAULT; =20 static int __init coredump_filter_setup(char *s) { - default_dump_filter =3D - (simple_strtoul(s, NULL, 0) << MMF_DUMP_FILTER_SHIFT) & - MMF_DUMP_FILTER_MASK; + if (kstrtoul(s, 0, &coredump_filter)) + return 0; + coredump_filter <<=3D MMF_DUMP_FILTER_SHIFT; + coredump_filter &=3D MMF_DUMP_FILTER_MASK; return 1; } =20 @@ -1104,7 +1105,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm= , struct task_struct *p, __mm_flags_overwrite_word(mm, mmf_init_legacy_flags(flags)); mm->def_flags =3D current->mm->def_flags & VM_INIT_DEF_MASK; } else { - __mm_flags_overwrite_word(mm, default_dump_filter); + __mm_flags_overwrite_word(mm, coredump_filter); mm->def_flags =3D 0; } =20 --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4