From: Zheng Lv <lv.zheng.2015@gmail.com>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fat: check whether fs size exceeds device size
Date: Fri, 24 Jun 2016 09:56:13 -0400 [thread overview]
Message-ID: <20160624135613.GA22429@ubuntu-sun> (raw)
In-Reply-To: <8737o3lyla.fsf@mail.parknet.co.jp>
On Fri, Jun 24, 2016 at 06:34:25PM +0900, OGAWA Hirofumi wrote:
> > + device_sectors = sb->s_bdev->bd_inode->i_size / logical_sector_size;
> > + if (device_sectors && total_sectors > device_sectors) {
> > + fat_msg(sb, KERN_ERR, "total sectors %u "
> > + "exceeds size of device (%llu sectors)",
> > + total_sectors, device_sectors);
> > + goto out_invalid;
>
> Hm, it is a bit hard to think what to do. But I guess it is better to
> allow access to rescue some files. (Yes, it may lost new data. But
> read-only or in-place update is safe.)
I would like to list the reasons it's better not to allow mounting.
- The "attempt to access beyond end of device" error would fill the kernel
log. It's drivers' business to prevent such kind of errors.
- Clever data rescuers won't mount the damaged device. They would instead
mount a copy of the broken image. It isn't much work to "truncate" the file
to larger after they receive the message.
- It's at least unsafe to allow mounting rw a truncated device.
- ext4 driver forbids mounting a truncated device, too.
In fact, the code was basically copied from ext4 fs driver. :-)
Reference: v4.7-rc4 fs/ext4/super.c:3605
> blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits;
> if (blocks_count && ext4_blocks_count(es) > blocks_count) {
> ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu "
> "exceeds size of device (%llu blocks)",
> ext4_blocks_count(es), blocks_count);
> goto failed_mount;
> }
On Fri, Jun 24, 2016 at 06:34:25PM +0900, OGAWA Hirofumi wrote:
> > + } else if (device_sectors && total_sectors < device_sectors) {
> > + fat_msg(sb, KERN_INFO, "%llu unused sectors at end of device",
> > + device_sectors - total_sectors);
>
> This is legal setup. So, probably, should not pollute log for each mount.
I totally agree with you.
Zheng Lv
next prev parent reply other threads:[~2016-06-24 13:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-24 8:58 [PATCH] fat: check whether fs size exceeds device size Zheng Lv
2016-06-24 9:34 ` OGAWA Hirofumi
2016-06-24 13:56 ` Zheng Lv [this message]
2016-06-25 10:08 ` OGAWA Hirofumi
2016-06-24 14:02 ` Zheng Lv
2016-06-24 15:10 ` Zheng Lv
2016-06-24 9:38 ` kbuild test robot
2016-06-24 10:39 ` kbuild test robot
2016-06-24 10:53 ` kbuild test robot
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=20160624135613.GA22429@ubuntu-sun \
--to=lv.zheng.2015@gmail.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-fsdevel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.