* [PATCH] exfat: Fix bitwise operation having different size
2026-03-03 10:59 [PATCH] exfat: Fix 2 issues found by static code analysis Philipp Hahn
@ 2026-03-03 10:59 ` Philipp Hahn
2026-03-03 10:59 ` [PATCH] exfat: Drop dead assignment of num_clusters Philipp Hahn
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Philipp Hahn @ 2026-03-03 10:59 UTC (permalink / raw)
To: Namjae Jeon, Sungjong Seo, Yuezhang Mo
Cc: Philipp Hahn, linux-fsdevel, linux-kernel
cpos has type loff_t (long long), while s_blocksize has type u32. The
inversion wil happen on u32, the coercion to s64 happens afterwards and
will do 0-left-paddding, resulting in the upper bits getting masked out.
Cast s_blocksize to loff_t before negating it.
Found by static code analysis using Klocwork.
Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
---
fs/exfat/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 3a4853693d8bf..e710dd196e2f0 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -249,7 +249,7 @@ static int exfat_iterate(struct file *file, struct dir_context *ctx)
*/
if (err == -EIO) {
cpos += 1 << (sb->s_blocksize_bits);
- cpos &= ~(sb->s_blocksize - 1);
+ cpos &= ~(loff_t)(sb->s_blocksize - 1);
}
err = -EIO;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH] exfat: Drop dead assignment of num_clusters
2026-03-03 10:59 [PATCH] exfat: Fix 2 issues found by static code analysis Philipp Hahn
2026-03-03 10:59 ` [PATCH] exfat: Fix bitwise operation having different size Philipp Hahn
@ 2026-03-03 10:59 ` Philipp Hahn
2026-03-03 11:50 ` Markus Elfring
2026-03-04 8:40 ` exfat: Fix 2 issues found by static code analysis Markus Elfring
2026-03-04 10:25 ` [PATCH] " Namjae Jeon
3 siblings, 1 reply; 9+ messages in thread
From: Philipp Hahn @ 2026-03-03 10:59 UTC (permalink / raw)
To: Namjae Jeon, Sungjong Seo, Yuezhang Mo
Cc: Philipp Hahn, linux-fsdevel, linux-kernel
num_clusters is not used naywhere afterwards. Remove assignment.
Found by static code analysis using Klocwork.
Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
---
fs/exfat/inode.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 2fb2d2d5d503a..d17ef2f9a7e2b 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -213,7 +213,6 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
return -EIO;
}
- num_clusters += num_to_be_allocated;
*clu = new_clu.dir;
inode->i_blocks += EXFAT_CLU_TO_B(num_to_be_allocated, sbi) >> 9;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: exfat: Fix 2 issues found by static code analysis
2026-03-03 10:59 [PATCH] exfat: Fix 2 issues found by static code analysis Philipp Hahn
2026-03-03 10:59 ` [PATCH] exfat: Fix bitwise operation having different size Philipp Hahn
2026-03-03 10:59 ` [PATCH] exfat: Drop dead assignment of num_clusters Philipp Hahn
@ 2026-03-04 8:40 ` Markus Elfring
2026-03-04 15:12 ` Philipp Hahn
2026-03-04 10:25 ` [PATCH] " Namjae Jeon
3 siblings, 1 reply; 9+ messages in thread
From: Markus Elfring @ 2026-03-04 8:40 UTC (permalink / raw)
To: Philipp Hahn, linux-fsdevel
Cc: LKML, kernel-janitors, Namjae Jeon, Sungjong Seo, Yuezhang Mo
By the way:
It can be helpful to number prefixes according to message subjects in patch series.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc2#n711
> I'm going through our list of issues found by static code analysis using Klocwork.
Does this tool point any more implementation details out for further development considerations
(with other software components)?
Regards,
Markus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: exfat: Fix 2 issues found by static code analysis
2026-03-04 8:40 ` exfat: Fix 2 issues found by static code analysis Markus Elfring
@ 2026-03-04 15:12 ` Philipp Hahn
2026-03-05 10:51 ` Markus Elfring
0 siblings, 1 reply; 9+ messages in thread
From: Philipp Hahn @ 2026-03-04 15:12 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-fsdevel, LKML, kernel-janitors, Namjae Jeon, Sungjong Seo,
Yuezhang Mo
Hello Markus,
Am Wed, Mar 04, 2026 at 09:40:37AM +0100 schrieb Markus Elfring:
> By the way:
> It can be helpful to number prefixes according to message subjects in patch series.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc2#n711
Yes, thank you for the reminder.
> > I'm going through our list of issues found by static code analysis using Klocwork.
>
> Does this tool point any more implementation details out for further development considerations
> (with other software components)?
This was a run on our internal version of exfat, which matches
'github.com/namjaejeon/linux-exfat-oot/for-kernel-version-from-4.1.0'.
Klocwork found no other issues worth fixing in that version.
If my time permits I will run it again on latest 'linux-7.0-rc`
respective 'master' to see if anything "new" crept in.
I'll also report any other findings outside of exfat when I find them.
Philipp
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: exfat: Fix 2 issues found by static code analysis
2026-03-04 15:12 ` Philipp Hahn
@ 2026-03-05 10:51 ` Markus Elfring
0 siblings, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2026-03-05 10:51 UTC (permalink / raw)
To: Philipp Hahn, linux-fsdevel
Cc: LKML, kernel-janitors, Namjae Jeon, Sungjong Seo, Yuezhang Mo
>>> I'm going through our list of issues found by static code analysis using Klocwork.
>>
>> Does this tool point any more implementation details out for further development considerations
>> (with other software components)?
>
> This was a run on our internal version of exfat, which matches
> 'github.com/namjaejeon/linux-exfat-oot/for-kernel-version-from-4.1.0'.
Thanks for such background information.
> If my time permits I will run it again on latest 'linux-7.0-rc`
> respective 'master' to see if anything "new" crept in.
It is probably nicer to repeat source code analyses on more recent
software revisions occasionally.
> I'll also report any other findings outside of exfat when I find them.
I became curious on the aspect on how many development resources
you may invest then.
Regards,
Markus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] exfat: Fix 2 issues found by static code analysis
2026-03-03 10:59 [PATCH] exfat: Fix 2 issues found by static code analysis Philipp Hahn
` (2 preceding siblings ...)
2026-03-04 8:40 ` exfat: Fix 2 issues found by static code analysis Markus Elfring
@ 2026-03-04 10:25 ` Namjae Jeon
3 siblings, 0 replies; 9+ messages in thread
From: Namjae Jeon @ 2026-03-04 10:25 UTC (permalink / raw)
To: Philipp Hahn; +Cc: Sungjong Seo, Yuezhang Mo, linux-fsdevel, linux-kernel
On Tue, Mar 3, 2026 at 7:59 PM Philipp Hahn <phahn-oss@avm.de> wrote:
>
> Hello,
>
> I'm going through our list of issues found by static code analysis using Klocwork.
> It found two issues worth fixing:
>
> 1. The 1st seems to be a real bug due to C's integer coercion, where the
> inverted bitmask `s_blocksize` gets 0 extended.
> 2. The 2nd might just be a dead variable assignment, but maybe `num_clusters`
> is supposed to be returned or stored elsewhere?
>
> I hope my alaysis is correct. If yes, please apply. Thank you.
>
> Philipp Hahn (2):
> exfat: Fix bitwise operation having different size
> exfat: Drop dead assignment of num_clusters
Applied them to #dev.
Thanks!
^ permalink raw reply [flat|nested] 9+ messages in thread