From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: hengyul@cs.unc.edu
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] fat: calculate data area start without overflow
Date: Thu, 03 Sep 2026 01:01:54 +0900 [thread overview]
Message-ID: <878q5jmykt.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20260902143858.4092293-1-hengyul@cs.unc.edu>
hengyul@cs.unc.edu writes:
> - sbi->data_start = sbi->dir_start + rootdir_sectors;
> + if (check_mul_overflow(sbi->fats, sbi->fat_length,
> + &dir_start) ||
Looks like unreadable "\n".
if (check_mul_overflow(sbi->fats, sbi->fat_length, &dir_start) ||
> + check_add_overflow(sbi->fat_start, dir_start, &dir_start) ||
> + check_add_overflow(dir_start, rootdir_sectors, &data_start))
> + goto out_invalid;
Maybe, better to add the error detail?
check_add_overflow(dir_start, rootdir_sectors, &data_start)) {
if (!silent)
fat_msg(sb, KERN_ERR,
"overflow of root dir or data layout");
goto out_invalid;
}
Thanks.
> total_sectors = bpb.fat_sectors;
> if (total_sectors == 0)
> total_sectors = bpb.fat_total_sect;
>
> - if (total_sectors < sbi->data_start) {
> + if (total_sectors < data_start) {
> if (!silent)
> fat_msg(sb, KERN_ERR,
> - "data area starts beyond volume (%lu > %u)",
> - sbi->data_start, total_sectors);
> + "data area starts beyond volume (%u > %u)",
> + data_start, total_sectors);
> goto out_invalid;
> }
>
> - total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus;
> + sbi->dir_start = dir_start;
> + sbi->data_start = data_start;
> + total_clusters = (total_sectors - data_start) / sbi->sec_per_clus;
>
> if (!is_fat32(sbi))
> sbi->fat_bits = (total_clusters > MAX_FAT12) ? 16 : 12;
>
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
prev parent reply other threads:[~2026-09-02 16:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 14:38 hengyul
2026-09-02 16:01 ` OGAWA Hirofumi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878q5jmykt.fsf@mail.parknet.co.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=hengyul@cs.unc.edu \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®