Skip to contentSkip to conversation

mm: shmem: Fix variable type to int to evaluate negative conditions

PATCH Superseded Karan Sanghavi 4 participants 5 messages Nov 11, 2024 – Nov 24, 2024

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: shmem: Fix variable type to int to evaluate negative conditions

version variable captures return value from utf8_parse_version function which can be negative, but unsigned won't
let it capture, thus missing the further checks on negative values.

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

---
Coverity Message:
CID 1601569: (#1 of 1): Unsigned compared against 0 (NO_EFFECT)
unsigned_compare: This less-than-zero comparison of an unsigned value is never true. version < 0U

Coverity Link:
https://scan7.scan.coverity.com/#/project-view/10043/11354?selectedIssue=1601569

---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
index 7987deb2be9b..17a1d4fa8870 100644
@@ -4367,7 +4367,7 @@ static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *
 				    bool latest_version)
 {
 	struct shmem_options *ctx = fc->fs_private;
-	unsigned int version = UTF8_LATEST;
+	int version = UTF8_LATEST;
 	struct unicode_map *encoding;
 	char *version_str = param->string + 5;
 

---
base-commit: 6d59cab07b8d74d0f0422b750038123334f6ecc2
change-id: 20241111-unsignedcompare1601569-05b5932145ef

Best regards,

Signature · 1 line
Karan Sanghavi <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw

Em 11/11/2024 14:10, Karan Sanghavi escreveu:

Quoted 6 lines

version variable captures return value from utf8_parse_version function which can be negative, but unsigned won't
let it capture, thus missing the further checks on negative values.

Fixes 58e55efd6c72 ("tmpfs: Add casefold lookup support")
Reviewed-by on v1 1/1
#2 lore raw
In reply to Karan Sanghavi
Quoted 11 lines · Karan Sanghavi

version variable captures return value from utf8_parse_version function which can be negative, but unsigned won't
let it capture, thus missing the further checks on negative values.

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

---
Coverity Message:
CID 1601569: (#1 of 1): Unsigned compared against 0 (NO_EFFECT)
unsigned_compare: This less-than-zero comparison of an unsigned value is never true. version < 0U

Quoted 26 lines

Coverity Link:
https://scan7.scan.coverity.com/#/project-view/10043/11354?selectedIssue=1601569

---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -2
index 7987deb2be9b..17a1d4fa8870 100644
@@ -4367,7 +4367,7 @@ static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *
 				    bool latest_version)
 {
 	struct shmem_options *ctx = fc->fs_private;
-	unsigned int version = UTF8_LATEST;
+	int version = UTF8_LATEST;
 	struct unicode_map *encoding;
 	char *version_str = param->string + 5;
 
 
---

base-commit: 6d59cab07b8d74d0f0422b750038123334f6ecc2
change-id: 20241111-unsignedcompare1601569-05b5932145ef

Best regards,

Signature · 1 line
Gabriel Krisman Bertazi
#3 lore raw
Quoted 38 lines · Gabriel Krisman Bertazi
Quoted 11 lines · Karan Sanghavi

version variable captures return value from utf8_parse_version function which can be negative, but unsigned won't
let it capture, thus missing the further checks on negative values.

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

---
Coverity Message:
CID 1601569: (#1 of 1): Unsigned compared against 0 (NO_EFFECT)
unsigned_compare: This less-than-zero comparison of an unsigned value is never true. version < 0U

Quoted 21 lines

Coverity Link:
https://scan7.scan.coverity.com/#/project-view/10043/11354?selectedIssue=1601569

---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
index 7987deb2be9b..17a1d4fa8870 100644
@@ -4367,7 +4367,7 @@ static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *
 				    bool latest_version)
 {
 	struct shmem_options *ctx = fc->fs_private;
-	unsigned int version = UTF8_LATEST;
+	int version = UTF8_LATEST;
 	struct unicode_map *encoding;
 	char *version_str = param->string + 5;
 
Quoted 8 lines
Quoted 5 lines

---
base-commit: 6d59cab07b8d74d0f0422b750038123334f6ecc2
change-id: 20241111-unsignedcompare1601569-05b5932145ef

Best regards,

Signature · 1 line
Gabriel Krisman Bertazi

Dear Gabriel and André,

I hope this email finds you well.
I'm following up on the patch I had submitted linked below.
https://lore.kernel.org/all/[email protected]/
I noticed it hasn't been applied yet, and I wanted to see if there was anything else needed from my end.
Please let me know if any further information or modifications are required. I appreciate your time and feedback.

Thank you!

Sincerely,
Karan.

#4 lore raw
In reply to Karan Sanghavi

…

Quoted 3 lines

---
Coverity Message:
CID 1601569: (#1 of 1): Unsigned compared against 0 (NO_EFFECT)

…

Can such information become a part of the change description?

Would a summary phrase like “Use signed data type for version handling in shmem_parse_opt_casefold()” be more appropriate?

Regards,
Markus