lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9ad217bd-c21d-49e5-af0a-9059a3bdf911@163.com>
Date: Wed, 14 Jan 2026 11:07:07 +0800
From: Chi Zhiling <chizhiling@....com>
To: "Yuezhang.Mo@...y.com" <Yuezhang.Mo@...y.com>,
 "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
 "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc: Namjae Jeon <linkinjeon@...nel.org>, Sungjong Seo
 <sj1557.seo@...sung.com>, Chi Zhiling <chizhiling@...inos.cn>
Subject: Re: [PATCH v2 10/13] exfat: support multi-cluster for
 exfat_map_cluster

On 1/13/26 18:26, Yuezhang.Mo@...y.com wrote:
>> On 1/13/26 14:37, Yuezhang.Mo@...y.com wrote:
>>>> @@ -281,7 +285,7 @@ static int exfat_get_block(struct inode *inode, sector_t iblock,
>>>>          sec_offset = iblock & (sbi->sect_per_clus - 1);
>>>>
>>>>          phys = exfat_cluster_to_sector(sbi, cluster) + sec_offset;
>>>> -       mapped_blocks = sbi->sect_per_clus - sec_offset;
>>>> +       mapped_blocks = (count << sbi->sect_per_clus_bits) - sec_offset;
>>>
>>> This left shift will cause an overflow if the file is larger than 2TB
>>> and the clusters are contiguous.
>>
>> Thank you for pointing this out, I will change the type to blkcnt_t in
>> v3 to fix this bug.
> 
> I don't think it's necessary to change the type to blkcnt_t, because the type
> of bh_result->b_size is size_t (aka unsigned long int).
> 
> The overflow was caused by '*count' being increased in exfat_map_cluster().
> I think it should be fixed as below.
> 
> --- a/fs/exfat/inode.c
> +++ b/fs/exfat/inode.c
> @@ -153,7 +153,7 @@ static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
>                  last_clu += num_clusters - 1;
>                  if (clu_offset < num_clusters) {
>                          *clu += clu_offset;
> -                       *count = num_clusters - clu_offset;
> +                       *count = min(num_clusters - clu_offset, *count);
>                  } else {
>                          *clu = EXFAT_EOF_CLUSTER;
>                          *count = 0;
> @@ -284,7 +284,7 @@ static int exfat_get_block(struct inode *inode, sector_t iblock,
>          sec_offset = iblock & (sbi->sect_per_clus - 1);
>   
>          phys = exfat_cluster_to_sector(sbi, cluster) + sec_offset;
> -       mapped_blocks = (count << sbi->sect_per_clus_bits) - sec_offset;
> +       mapped_blocks = ((unsigned long)count << sbi->sect_per_clus_bits) - sec_offset;
>          max_blocks = min(mapped_blocks, max_blocks);
>   
>          map_bh(bh_result, sb, phys);
> 

Okay, I got it, so the exfat_get_cluster should be updated as well.


diff --git a/fs/exfat/cache.c b/fs/exfat/cache.c
index 18d304d1d4cc..7c8b4182f5de 100644
--- a/fs/exfat/cache.c
+++ b/fs/exfat/cache.c
@@ -303,7 +303,7 @@ int exfat_get_cluster(struct inode *inode, unsigned 
int cluster,

         /* Return if the cache covers the entire range. */
         if (cid.fcluster + cid.nr_contig >= end) {
-               *count = cid.fcluster + cid.nr_contig - cluster + 1;
+               *count = end - cluster + 1;
                 return 0;
         }


Thanks,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ