diff mbox series

[3/6] Check that the new path while moving a file is not too long

Message ID 20191009133157.14028-4-philipp.ammann@posteo.de (mailing list archive)
State New, archived
Headers show
Series Various exfat fixes | expand

Commit Message

Philipp Ammann Oct. 9, 2019, 1:31 p.m. UTC
From: Andreas Schneider <asn@cryptomilk.org>

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
---
 drivers/staging/exfat/exfat_super.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Gao Xiang Oct. 9, 2019, 3:25 p.m. UTC | #1
On Wed, Oct 09, 2019 at 03:31:54PM +0200, philipp.ammann@posteo.de wrote:
> From: Andreas Schneider <asn@cryptomilk.org>

[no subject prefix, and maybe use scripts/get_maintainer.pl... ]

> 
> Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
> ---
>  drivers/staging/exfat/exfat_super.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
> index 5f6caee819a6..b63186a67af6 100644
> --- a/drivers/staging/exfat/exfat_super.c
> +++ b/drivers/staging/exfat/exfat_super.c
> @@ -1300,6 +1300,9 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
>  	}
>  
>  	/* check the validity of directory name in the given new pathname */
> +	if (strlen(new_path) >= MAX_NAME_LENGTH)
> +		return FFS_NAMETOOLONG;
> +

odd here, AFAIK, namelen should be checked in ->lookup()
for many filesystems (why such dentries exist?) and
the length can be also gotten by dentry->d_name.len
(it's also stable here).

Maybe sort out what original problem here is better and
not blindly get patches from random github repos...

Thanks,
Gao Xiang

>  	ret = resolve_path(new_parent_inode, new_path, &newdir, &uni_name);
>  	if (ret)
>  		goto out2;
> -- 
> 2.21.0
>
Philipp Ammann Oct. 9, 2019, 5:45 p.m. UTC | #2
Am 09.10.19 um 17:25 schrieb Gao Xiang:
> Maybe sort out what original problem here is better and
> not blindly get patches from random github repos...

That's kinda hard to do given that Samsung doesn't provide a history of 
the code...and my lack of knowledge of FS drivers ;-)
I just posted Bugfixes that probably originated from Samsung and somehow 
haven't made it in the initial mainline exfat commit.

Do you know where the code originally came from?

Regards
Philipp

> 
> Thanks,
> Gao Xiang
> 
>>   	ret = resolve_path(new_parent_inode, new_path, &newdir, &uni_name);
>>   	if (ret)
>>   		goto out2;
>> -- 
>> 2.21.0
>>
>
diff mbox series

Patch

diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c
index 5f6caee819a6..b63186a67af6 100644
--- a/drivers/staging/exfat/exfat_super.c
+++ b/drivers/staging/exfat/exfat_super.c
@@ -1300,6 +1300,9 @@  static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid,
 	}
 
 	/* check the validity of directory name in the given new pathname */
+	if (strlen(new_path) >= MAX_NAME_LENGTH)
+		return FFS_NAMETOOLONG;
+
 	ret = resolve_path(new_parent_inode, new_path, &newdir, &uni_name);
 	if (ret)
 		goto out2;