Skip to contentSkip to conversation

mm: shmem: Fix error checking on utf8_parse_version failures

PATCH In review Colin Ian King 2 participants 3 messages Nov 12, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: shmem: Fix error checking on utf8_parse_version failures

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")
---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
index 7987deb2be9b..b69e1d8816fa 100644
@@ -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);
 	}
 
Signature · 1 line
2.39.5
#1 lore raw

Hi Colin,

Em 12/11/2024 06:54, Colin Ian King escreveu:

Quoted 4 lines

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?

Quoted 3 lines
Fixes 58e55efd6c72 ("tmpfs: Add casefold lookup support")

Another fix was already sent: https://lore.kernel.org/lkml/[email protected]/

#2 lore raw
Quoted 9 lines · André Almeida

Hi Colin,

Em 12/11/2024 06:54, Colin Ian King escreveu:

Quoted 4 lines

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

Quoted 6 lines
Quoted 4 lines
Fixes 58e55efd6c72 ("tmpfs: Add casefold lookup support")

Another fix was already sent: https://lore.kernel.org/lkml/20241111- [email protected]/