Re: [PATCH] ntfs: reject invalid MFT LCNs from boot sector

Namjae Jeon <[email protected]>
Newsgroups dev.linux.lists.ntfs,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <CAKYAXd9TdWEMuMbd_uEuAW1whxsAJ_PvrWhBRypDNNHEWOTd_A@mail.gmail.com>
> @@ -755,14 +755,14 @@ static bool parse_ntfs_boot_sector(struct ntfs_volume *vol,
>          * the same as it is much faster on 32-bit CPUs.
>          */
>         ll = le64_to_cpu(b->number_of_sectors) >> sectors_per_cluster_bits;
> -       if ((u64)ll >= 1ULL << 32) {
> +       if (ll >= 1ULL << 32) {
>                 ntfs_error(vol->sb, "Cannot handle 64-bit clusters.");
>                 return false;
>         }
>         vol->nr_clusters = ll;
>         ntfs_debug("vol->nr_clusters = 0x%llx", vol->nr_clusters);
>         ll = le64_to_cpu(b->mft_lcn);
> -       if (ll >= vol->nr_clusters) {
> +       if (ll >= (u64)vol->nr_clusters) {
>                 ntfs_error(vol->sb, "MFT LCN (%lli, 0x%llx) is beyond end of volume.  Weird.",
Should we change %lli to %llu ?
>                                 ll, ll);
>                 return false;
> @@ -770,7 +770,7 @@ static bool parse_ntfs_boot_sector(struct ntfs_volume *vol,
>         vol->mft_lcn = ll;
>         ntfs_debug("vol->mft_lcn = 0x%llx", vol->mft_lcn);
>         ll = le64_to_cpu(b->mftmirr_lcn);
> -       if (ll >= vol->nr_clusters) {
> +       if (ll >= (u64)vol->nr_clusters) {
>                 ntfs_error(vol->sb, "MFTMirr LCN (%lli, 0x%llx) is beyond end of volume.  Weird.",
>                                 ll, ll);
Ditto.
Thanks!
>                 return false;
>
> ---
> base-commit: df7dce2090342170b7643d36f694204cae7792a9
> change-id: 20260818-fix-negative-mft-lcn-596257dd23c8
>
> Best regards,
> --
> Thanks,
> Hyunchul
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.