linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions
@ 2024-11-11 17:10 Karan Sanghavi
  2024-11-11 17:19 ` André Almeida
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Karan Sanghavi @ 2024-11-11 17:10 UTC (permalink / raw)
  To: Hugh Dickins, Andrew Morton, Gabriel Krisman Bertazi,
	André Almeida, Christian Brauner
  Cc: linux-mm, linux-kernel, Shuah Khan, 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")
Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com>
---
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(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 7987deb2be9b..17a1d4fa8870 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -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,
-- 
Karan Sanghavi <karansanghvi98@gmail.com>



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

* Re: [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions
  2024-11-11 17:10 [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions Karan Sanghavi
@ 2024-11-11 17:19 ` André Almeida
  2024-11-11 18:37 ` Gabriel Krisman Bertazi
  2024-11-24 11:33 ` Markus Elfring
  2 siblings, 0 replies; 5+ messages in thread
From: André Almeida @ 2024-11-11 17:19 UTC (permalink / raw)
  To: Karan Sanghavi
  Cc: linux-mm, linux-kernel, Andrew Morton, Hugh Dickins,
	Christian Brauner, Shuah Khan, Gabriel Krisman Bertazi

Em 11/11/2024 14:10, Karan Sanghavi escreveu:
> 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")
> Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com>

Reviewed-by: André Almeida <andrealmeid@igalia.com>



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

* Re: [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions
  2024-11-11 17:10 [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions Karan Sanghavi
  2024-11-11 17:19 ` André Almeida
@ 2024-11-11 18:37 ` Gabriel Krisman Bertazi
  2024-11-24  8:02   ` Karan Sanghavi
  2024-11-24 11:33 ` Markus Elfring
  2 siblings, 1 reply; 5+ messages in thread
From: Gabriel Krisman Bertazi @ 2024-11-11 18:37 UTC (permalink / raw)
  To: Karan Sanghavi
  Cc: Hugh Dickins, Andrew Morton, André Almeida,
	Christian Brauner, linux-mm, linux-kernel, Shuah Khan

Karan Sanghavi <karansanghvi98@gmail.com> writes:

> 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")
> Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com>
> ---
> 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


Reviewed-by: Gabriel Krisman Bertazi <gabriel@krisman.be>

>
> Coverity Link:
> https://scan7.scan.coverity.com/#/project-view/10043/11354?selectedIssue=1601569
> ---
>  mm/shmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 7987deb2be9b..17a1d4fa8870 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -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,

-- 
Gabriel Krisman Bertazi


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

* Re: [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions
  2024-11-11 18:37 ` Gabriel Krisman Bertazi
@ 2024-11-24  8:02   ` Karan Sanghavi
  0 siblings, 0 replies; 5+ messages in thread
From: Karan Sanghavi @ 2024-11-24  8:02 UTC (permalink / raw)
  To: Gabriel Krisman Bertazi, André Almeida
  Cc: Hugh Dickins, Andrew Morton, Christian Brauner, linux-mm,
	linux-kernel, Shuah Khan

On Mon, Nov 11, 2024 at 01:37:43PM -0500, Gabriel Krisman Bertazi wrote:
> Karan Sanghavi <karansanghvi98@gmail.com> writes:
> 
> > 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")
> > Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com>
> > ---
> > 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
> 
> 
> Reviewed-by: Gabriel Krisman Bertazi <gabriel@krisman.be>
> 
> >
> > Coverity Link:
> > https://scan7.scan.coverity.com/#/project-view/10043/11354?selectedIssue=1601569
> > ---
> >  mm/shmem.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index 7987deb2be9b..17a1d4fa8870 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -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,
> 
> -- 
> 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/20241111-unsignedcompare1601569-v1-1-c4a9c3c75a52@gmail.com/
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. 


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

* Re: [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions
  2024-11-11 17:10 [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions Karan Sanghavi
  2024-11-11 17:19 ` André Almeida
  2024-11-11 18:37 ` Gabriel Krisman Bertazi
@ 2024-11-24 11:33 ` Markus Elfring
  2 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2024-11-24 11:33 UTC (permalink / raw)
  To: Karan Sanghavi, linux-mm, André Almeida, Andrew Morton,
	Christian Brauner, Gabriel Krisman Bertazi, Hugh Dickins
  Cc: LKML, Shuah Khan

…
> ---
> 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


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-11 17:10 [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions Karan Sanghavi
2024-11-11 17:19 ` André Almeida
2024-11-11 18:37 ` Gabriel Krisman Bertazi
2024-11-24  8:02   ` Karan Sanghavi
2024-11-24 11:33 ` Markus Elfring

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