diff mbox series

[v15,7/9] f2fs: Log error when lookup of encoded dentry fails

Message ID 20240402154842.508032-8-eugen.hristev@collabora.com
State Superseded
Headers show
Series Cache insensitive cleanup for ext4/f2fs | expand

Commit Message

Eugen Hristev April 2, 2024, 3:48 p.m. UTC
If the volume is in strict mode, generi c_ci_compare can report a broken
encoding name.  This will not trigger on a bad lookup, which is caught
earlier, only if the actual disk name is bad.

Suggested-by: Gabriel Krisman Bertazi <krisman@suse.de>
Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
---
 fs/f2fs/dir.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Eric Biggers April 3, 2024, 4:25 a.m. UTC | #1
On Tue, Apr 02, 2024 at 06:48:40PM +0300, Eugen Hristev via Linux-f2fs-devel wrote:
> If the volume is in strict mode, generi c_ci_compare can report a broken
> encoding name.  This will not trigger on a bad lookup, which is caught
> earlier, only if the actual disk name is bad.
> 
> Suggested-by: Gabriel Krisman Bertazi <krisman@suse.de>
> Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
> ---
>  fs/f2fs/dir.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> index 88b0045d0c4f..64286d80dd30 100644
> --- a/fs/f2fs/dir.c
> +++ b/fs/f2fs/dir.c
> @@ -192,11 +192,16 @@ static inline int f2fs_match_name(const struct inode *dir,
>  	struct fscrypt_name f;
>  
>  #if IS_ENABLED(CONFIG_UNICODE)
> -	if (fname->cf_name.name)
> -		return generic_ci_match(dir, fname->usr_fname,
> -					&fname->cf_name,
> -					de_name, de_name_len);
> -
> +	if (fname->cf_name.name) {
> +		int ret = generic_ci_match(dir, fname->usr_fname,
> +					   &fname->cf_name,
> +					   de_name, de_name_len);
> +		if (ret == -EINVAL)
> +			f2fs_warn(F2FS_SB(dir->i_sb),
> +				"Directory contains filename that is invalid UTF-8");
> +

Shouldn't this use f2fs_warn_ratelimited?

- Eric
Eugen Hristev April 4, 2024, 2:50 p.m. UTC | #2
On 4/3/24 07:25, Eric Biggers wrote:
> On Tue, Apr 02, 2024 at 06:48:40PM +0300, Eugen Hristev via Linux-f2fs-devel wrote:
>> If the volume is in strict mode, generi c_ci_compare can report a broken
>> encoding name.  This will not trigger on a bad lookup, which is caught
>> earlier, only if the actual disk name is bad.
>>
>> Suggested-by: Gabriel Krisman Bertazi <krisman@suse.de>
>> Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
>> ---
>>  fs/f2fs/dir.c | 15 ++++++++++-----
>>  1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
>> index 88b0045d0c4f..64286d80dd30 100644
>> --- a/fs/f2fs/dir.c
>> +++ b/fs/f2fs/dir.c
>> @@ -192,11 +192,16 @@ static inline int f2fs_match_name(const struct inode *dir,
>>  	struct fscrypt_name f;
>>  
>>  #if IS_ENABLED(CONFIG_UNICODE)
>> -	if (fname->cf_name.name)
>> -		return generic_ci_match(dir, fname->usr_fname,
>> -					&fname->cf_name,
>> -					de_name, de_name_len);
>> -
>> +	if (fname->cf_name.name) {
>> +		int ret = generic_ci_match(dir, fname->usr_fname,
>> +					   &fname->cf_name,
>> +					   de_name, de_name_len);
>> +		if (ret == -EINVAL)
>> +			f2fs_warn(F2FS_SB(dir->i_sb),
>> +				"Directory contains filename that is invalid UTF-8");
>> +
> 
> Shouldn't this use f2fs_warn_ratelimited?

f2fs_warn_ratelimited appears to be very new in the kernel,

Krisman do you think you can rebase your for-next on top of latest such that this
function is available ? I am basing the series on your for-next branch.

Thanks

> 
> - Eric
> _______________________________________________
> Kernel mailing list -- kernel@mailman.collabora.com
> To unsubscribe send an email to kernel-leave@mailman.collabora.com
> This list is managed by https://mailman.collabora.com
Gabriel Krisman Bertazi April 4, 2024, 11:05 p.m. UTC | #3
Eugen Hristev <eugen.hristev@collabora.com> writes:

> On 4/3/24 07:25, Eric Biggers wrote:
>> On Tue, Apr 02, 2024 at 06:48:40PM +0300, Eugen Hristev via Linux-f2fs-devel wrote:
>>> If the volume is in strict mode, generi c_ci_compare can report a broken
>>> encoding name.  This will not trigger on a bad lookup, which is caught
>>> earlier, only if the actual disk name is bad.
>>>
>>> Suggested-by: Gabriel Krisman Bertazi <krisman@suse.de>
>>> Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
>>> ---
>>>  fs/f2fs/dir.c | 15 ++++++++++-----
>>>  1 file changed, 10 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
>>> index 88b0045d0c4f..64286d80dd30 100644
>>> --- a/fs/f2fs/dir.c
>>> +++ b/fs/f2fs/dir.c
>>> @@ -192,11 +192,16 @@ static inline int f2fs_match_name(const struct inode *dir,
>>>  	struct fscrypt_name f;
>>>  
>>>  #if IS_ENABLED(CONFIG_UNICODE)
>>> -	if (fname->cf_name.name)
>>> -		return generic_ci_match(dir, fname->usr_fname,
>>> -					&fname->cf_name,
>>> -					de_name, de_name_len);
>>> -
>>> +	if (fname->cf_name.name) {
>>> +		int ret = generic_ci_match(dir, fname->usr_fname,
>>> +					   &fname->cf_name,
>>> +					   de_name, de_name_len);
>>> +		if (ret == -EINVAL)
>>> +			f2fs_warn(F2FS_SB(dir->i_sb),
>>> +				"Directory contains filename that is invalid UTF-8");
>>> +
>> 
>> Shouldn't this use f2fs_warn_ratelimited?
>
> f2fs_warn_ratelimited appears to be very new in the kernel,
>
> Krisman do you think you can rebase your for-next on top of latest such that this
> function is available ? I am basing the series on your for-next
> branch.

I try to make unicode/for-next a non-rebase branch, and I don't want to
pollute the tree with an unecessary backmerge.  Instead, why not base
your work on a more recent branch, since it has no dependencies on
anything from unicode/for-next?
diff mbox series

Patch

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 88b0045d0c4f..64286d80dd30 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -192,11 +192,16 @@  static inline int f2fs_match_name(const struct inode *dir,
 	struct fscrypt_name f;
 
 #if IS_ENABLED(CONFIG_UNICODE)
-	if (fname->cf_name.name)
-		return generic_ci_match(dir, fname->usr_fname,
-					&fname->cf_name,
-					de_name, de_name_len);
-
+	if (fname->cf_name.name) {
+		int ret = generic_ci_match(dir, fname->usr_fname,
+					   &fname->cf_name,
+					   de_name, de_name_len);
+		if (ret == -EINVAL)
+			f2fs_warn(F2FS_SB(dir->i_sb),
+				"Directory contains filename that is invalid UTF-8");
+
+		return ret;
+	}
 #endif
 	f.usr_fname = fname->usr_fname;
 	f.disk_name = fname->disk_name;