linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] mm: shmem: Fix error checking on utf8_parse_version failures
@ 2024-11-12  9:54 Colin Ian King
  2024-11-12 10:06 ` André Almeida
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2024-11-12  9:54 UTC (permalink / raw)
  To: Hugh Dickins, Andrew Morton, Gabriel Krisman Bertazi,
	Christian Brauner, André Almeida, linux-mm
  Cc: kernel-janitors, linux-kernel

Currently the error check on the call to utf8_parse_version is always
false because version is an unsigned int and this can never be less
than zero. Because version is required to be an unsigned int, fix the
issue by casting it to int just for the error check.

Fixes: 58e55efd6c72 ("tmpfs: Add casefold lookup support")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 7987deb2be9b..b69e1d8816fa 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4377,7 +4377,7 @@ static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *
 				       "in the format: utf8-<version number>");
 
 		version = utf8_parse_version(version_str);
-		if (version < 0)
+		if ((int)version < 0)
 			return invalfc(fc, "Invalid UTF-8 version: %s", version_str);
 	}
 
-- 
2.39.5



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] mm: shmem: Fix error checking on utf8_parse_version failures
  2024-11-12  9:54 [PATCH][next] mm: shmem: Fix error checking on utf8_parse_version failures Colin Ian King
@ 2024-11-12 10:06 ` André Almeida
  2024-11-12 10:12   ` Colin King (gmail)
  0 siblings, 1 reply; 3+ messages in thread
From: André Almeida @ 2024-11-12 10:06 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Hugh Dickins, linux-mm, Christian Brauner,
	Gabriel Krisman Bertazi, Andrew Morton, kernel-janitors,
	linux-kernel

Hi Colin,

Em 12/11/2024 06:54, Colin Ian King escreveu:
> Currently the error check on the call to utf8_parse_version is always
> false because version is an unsigned int and this can never be less
> than zero. Because version is required to be an unsigned int, fix the
> issue by casting it to int just for the error check.

Why is it required to be an unsigned int?

> 
> Fixes: 58e55efd6c72 ("tmpfs: Add casefold lookup support")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

Another fix was already sent: 
https://lore.kernel.org/lkml/20241111-unsignedcompare1601569-v1-1-c4a9c3c75a52@gmail.com/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] mm: shmem: Fix error checking on utf8_parse_version failures
  2024-11-12 10:06 ` André Almeida
@ 2024-11-12 10:12   ` Colin King (gmail)
  0 siblings, 0 replies; 3+ messages in thread
From: Colin King (gmail) @ 2024-11-12 10:12 UTC (permalink / raw)
  To: André Almeida
  Cc: Hugh Dickins, linux-mm, Christian Brauner,
	Gabriel Krisman Bertazi, Andrew Morton, kernel-janitors,
	linux-kernel

On 12/11/2024 10:06, André Almeida wrote:
> Hi Colin,
> 
> Em 12/11/2024 06:54, Colin Ian King escreveu:
>> Currently the error check on the call to utf8_parse_version is always
>> false because version is an unsigned int and this can never be less
>> than zero. Because version is required to be an unsigned int, fix the
>> issue by casting it to int just for the error check.
> 
> Why is it required to be an unsigned int?

It's being passed to various functions that expect unsigned int, so I 
presume it was intended to be of that type.

Colin

> 
>>
>> Fixes: 58e55efd6c72 ("tmpfs: Add casefold lookup support")
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> 
> Another fix was already sent: https://lore.kernel.org/lkml/20241111- 
> unsignedcompare1601569-v1-1-c4a9c3c75a52@gmail.com/



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-12 10:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12  9:54 [PATCH][next] mm: shmem: Fix error checking on utf8_parse_version failures Colin Ian King
2024-11-12 10:06 ` André Almeida
2024-11-12 10:12   ` Colin King (gmail)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox