lkml.org 
[lkml]   [2023]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] proc: fix to check name length in proc_lookup_de()
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.

> --- 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);

\
 
 \ /
  Last update: 2023-03-26 23:35    [W:0.045 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site