Re: [PATCH 2/2] hfsplus: abort hfsplus_lookup if name is too long
From: Viacheslav Dubeyko
Date: Fri Aug 08 2025 - 17:54:56 EST
On Wed, 2025-08-06 at 11:11 -0600, Yangtao Li wrote:
> Long file names for hfs is 255 characters.
You already mentioned in another patch that HFS has limitation in 31
symbols. I think this patch requires more explanation why you've
selected hfsplus_lookup().
>
> Signed-off-by: Yangtao Li <frank.li@xxxxxxxx>
> ---
> fs/hfsplus/dir.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 876bbb80fb4d..d8fb401e7fdc 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -38,6 +38,9 @@ static struct dentry *hfsplus_lookup(struct inode
> *dir, struct dentry *dentry,
> u32 cnid, linkid = 0;
> u16 type;
>
> + if (dentry->d_name.len > HFSPLUS_MAX_STRLEN)
> + return ERR_PTR(-ENAMETOOLONG);
> +
Are you sure that we really need to abort the hfsplus_lookup()? We
already have the logic that checks the name length. We call
hfsplus_cat_build_key() [1], then hfsplus_asc2uni() [2]. And
hfsplus_asc2uni() checks the maximum name length and it returns -
ENAMETOOLONG [3].
Thanks,
Slava.
> sb = dir->i_sb;
>
> dentry->d_fsdata = NULL;
[1] https://elixir.bootlin.com/linux/v6.16/source/fs/hfsplus/dir.c#L47
[2]
https://elixir.bootlin.com/linux/v6.16/source/fs/hfsplus/catalog.c#L49
[3]
https://elixir.bootlin.com/linux/v6.16/source/fs/hfsplus/unicode.c#L375