From: Chao Yu <chao@kernel.org>
To: akpm@linux-foundation.org
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, adobriyan@gmail.com
Subject: Re: [PATCH 1/2] proc: fix to check name length in proc_lookup_de()
Date: Wed, 1 Feb 2023 21:01:14 +0800 [thread overview]
Message-ID: <93c1e281-82a5-d7d0-04b1-67ac2cf3d0fa@kernel.org> (raw)
In-Reply-To: <20230131155559.35800-1-chao@kernel.org>
Hi Andrew,
Could you please take a look at this patchset? Or should I ping
Alexey Dobriyan?
Thanks,
On 2023/1/31 23:55, 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.
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> fs/proc/generic.c | 5 ++++-
> fs/proc/internal.h | 3 +++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 878d7c6db919..f547e9593a77 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -245,6 +245,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);
> +
> read_lock(&proc_subdir_lock);
> de = pde_subdir_find(de, dentry->d_name.name, dentry->d_name.len);
> if (de) {
> @@ -401,7 +404,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
> goto out;
> qstr.name = fn;
> qstr.len = strlen(fn);
> - if (qstr.len == 0 || qstr.len >= 256) {
> + if (qstr.len == 0 || qstr.len > PROC_NAME_LEN) {
> WARN(1, "name len %u\n", qstr.len);
> return NULL;
> }
> diff --git a/fs/proc/internal.h b/fs/proc/internal.h
> index b701d0207edf..7611bc684d9e 100644
> --- a/fs/proc/internal.h
> +++ b/fs/proc/internal.h
> @@ -142,6 +142,9 @@ unsigned name_to_int(const struct qstr *qstr);
> /* Worst case buffer size needed for holding an integer. */
> #define PROC_NUMBUF 13
>
> +/* Max name length of procfs dirent */
> +#define PROC_NAME_LEN 255
> +
> /*
> * array.c
> */
next prev parent reply other threads:[~2023-02-01 13:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 15:55 [PATCH 1/2] proc: fix to check name length in proc_lookup_de() Chao Yu
2023-01-31 15:55 ` [PATCH 2/2] proc: fix .s_blocksize and .s_blocksize_bits Chao Yu
2023-02-01 13:01 ` Chao Yu [this message]
2023-02-02 23:41 ` [PATCH 1/2] proc: fix to check name length in proc_lookup_de() Andrew Morton
2023-02-05 12:21 ` Alexey Dobriyan
2023-02-11 1:22 ` Chao Yu
2023-02-11 1:13 ` Chao Yu
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=93c1e281-82a5-d7d0-04b1-67ac2cf3d0fa@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).