From: Thorsten Blum <thorsten.blum@linux.dev>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
wangzijie <wangzijie1@honor.com>,
Christian Brauner <brauner@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Wei Yang <albinwyang@tencent.com>, Jan Kara <jack@suse.cz>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] proc: use strnlen() for name validation in __proc_create
Date: Tue, 21 Apr 2026 16:17:06 +0200 [thread overview]
Message-ID: <aeeG4vcIZpxCwlB3@linux.dev> (raw)
In-Reply-To: <40e8e922-7962-4ab2-a0ee-8475701b1110@p183>
On Tue, Apr 21, 2026 at 04:02:24PM +0300, Alexey Dobriyan wrote:
> On Tue, Apr 21, 2026 at 02:26:47PM +0200, Thorsten Blum wrote:
> > 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.
>
> 256 in the code is really U8_MAX+1 (see proc_dir_entry.namelen).
>
> The fact that NAME_MAX is also 255 is a coincidence. I didn't thought
> about NAME_MAX when writing this code.
>
> Can you just change 256 to NAME_MAX?
I assume you meant U8_MAX here ^^
I don't mind switching to U8_MAX, but NAME_MAX seems semantically better
since we're validating a filename.
Thanks,
Thorsten
prev parent reply other threads:[~2026-04-21 14:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 12:26 [PATCH] proc: use strnlen() for name validation in __proc_create Thorsten Blum
2026-04-21 12:39 ` Jan Kara
2026-04-21 13:02 ` Alexey Dobriyan
2026-04-21 14:17 ` Thorsten Blum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aeeG4vcIZpxCwlB3@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=albinwyang@tencent.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=wangzijie1@honor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.