* + proc-use-strnlen-for-name-validation-in-__proc_create.patch added to mm-nonmm-unstable branch
@ 2026-04-23 15:09 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-04-23 15:09 UTC (permalink / raw)
To: mm-commits, wangzijie1, viro, jack, brauner, adobriyan,
thorsten.blum, akpm
The patch titled
Subject: proc: use strnlen() for name validation in __proc_create
has been added to the -mm mm-nonmm-unstable branch. Its filename is
proc-use-strnlen-for-name-validation-in-__proc_create.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/proc-use-strnlen-for-name-validation-in-__proc_create.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Thorsten Blum <thorsten.blum@linux.dev>
Subject: proc: use strnlen() for name validation in __proc_create
Date: Tue, 21 Apr 2026 14:26:47 +0200
Replace strlen(fn) with strnlen(fn, NAME_MAX + 1) when validating the
final path component in __proc_create().
This preserves the existing name limit while bounding the length scan to
one byte past the maximum name length. Handle empty names separately, and
treat names longer than NAME_MAX as too long.
Link: https://lore.kernel.org/20260421122648.56723-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Thorsten Blum <thorsten.blum@linux.dev>
Cc: wangzijie <wangzijie1@honor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/proc/generic.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
--- a/fs/proc/generic.c~proc-use-strnlen-for-name-validation-in-__proc_create
+++ a/fs/proc/generic.c
@@ -427,9 +427,13 @@ static struct proc_dir_entry *__proc_cre
if (xlate_proc_name(name, parent, &fn) != 0)
goto out;
qstr.name = fn;
- qstr.len = strlen(fn);
- if (qstr.len == 0 || qstr.len >= 256) {
- WARN(1, "name len %u\n", qstr.len);
+ qstr.len = strnlen(fn, NAME_MAX + 1);
+ if (qstr.len == 0) {
+ WARN(1, "empty name\n");
+ return NULL;
+ }
+ if (qstr.len > NAME_MAX) {
+ WARN(1, "name too long\n");
return NULL;
}
if (qstr.len == 1 && fn[0] == '.') {
_
Patches currently in -mm which might be from thorsten.blum@linux.dev are
proc-use-strnlen-for-name-validation-in-__proc_create.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-23 15:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 15:09 + proc-use-strnlen-for-name-validation-in-__proc_create.patch added to mm-nonmm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.