From: Chao Yu <chao@kernel.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] proc: fix to check name length in proc_lookup_de()
Date: Wed, 11 Jan 2023 17:13:17 +0800 [thread overview]
Message-ID: <e015e927-283a-2685-07b5-11b28f12e4f9@kernel.org> (raw)
In-Reply-To: <Y72oBFXX6DiEh2/p@p183>
On 2023/1/11 2:01, Alexey Dobriyan wrote:
> On Tue, Jan 10, 2023 at 11:21:12PM +0800, Chao Yu wrote:
>> __proc_create() has limited dirent's max name length with 255, let's
>> add this limitation in proc_lookup_de(), so that it can return
>> -ENAMETOOLONG correctly instead of -ENOENT when stating a file which
>> has out-of-range name length.
>
> Both returns are correct and this is trading one errno for another.
Oh, but it looks ENOENT is a little bit ambiguity, it may indicate file name
length is valid for procfs, but the entry is not exist.
This change is trying to make lookup logic keeping align w/ most other
filesystems' behavior. Also it can avoid running into unneeded lookup logic
in proc_lookup_de() for such ENAMETOOLONG case.
How do you think? :)
Thanks,
>
>> --- a/fs/proc/generic.c
>> +++ b/fs/proc/generic.c
>> @@ -246,6 +246,9 @@ struct dentry *proc_lookup_de(struct inode *dir, struct dentry *dentry,
>> {
>> struct inode *inode;
>>
>> + if (dentry->d_name.len > PROC_NAME_LEN)
>> + return ERR_PTR(-ENAMETOOLONG);
prev parent reply other threads:[~2023-01-11 9:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-10 15:21 [PATCH] proc: fix to check name length in proc_lookup_de() Chao Yu
2023-01-10 18:01 ` Alexey Dobriyan
2023-01-11 9:13 ` Chao Yu [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=e015e927-283a-2685-07b5-11b28f12e4f9@kernel.org \
--to=chao@kernel.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).