linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Antonov <saproj@gmail.com>
To: Anton Altaparmakov <anton@tuxera.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Anton Altaparmakov <aia21@cantab.net>
Subject: Re: [PATCH] ntfs: add code to make FIBMAP ioctl work
Date: Thu, 16 Oct 2014 17:07:06 +0200	[thread overview]
Message-ID: <CABikg9xu-DGAg+FZ9uTkG5+eA-zO1BE-qTrtKFSb52MHd1tkdQ@mail.gmail.com> (raw)
In-Reply-To: <C53A5210-0DD1-4F6F-8FF5-856BF11F5303@tuxera.com>

On 16 October 2014 15:20, Anton Altaparmakov <anton@tuxera.com> wrote:
> Hi Sergei,
>
> On 15 Oct 2014, at 20:19, Sergei Antonov <saproj@gmail.com> wrote:
>> Implement ntfs_bmap() function for the "bmap" address space operation.
>> Now user space programs can send FIBMAP ioctl to get files' placement on
>> NTFS the same way they can do it on a number of other linux filesystems.
>>
>> The result is returned in FIGETBSZ units, which is equal to sector size
>> in ntfs driver. An error value zero is returned for resident, compressed,
>> encrypted files, and for holes in sparse files.
>>
>> Tested on drives with different sector sizes and different cluster sizes.
>
> Thanks for your patch.  It skirts/looks over some limitations so instead of applying your patch I have open sourced the bmap implementation from Tuxera NTFS driver (with permission) and have pushed it to the open source NTFS tree at git://git.kernel.org/pub/scm/linux/kernel/git/aia21/ntfs.git.

Cool. Thanks.
It is good you liberate the code.

> I have sent a pull request to Linus so he will hopefully merge it into mainline.
>
> You can compare it to yours but most important points are that you do not forbid non-data attributes and you completely ignore initialized size which leads to exposing stale on-disk data on read and to losing the written data on writes which is obviously bad.  You also don't verify that the value to be returned isn't too large to fit in the return value size so you can potentially return truncated values on 32-bit kernels with 32-bit sector_t on a large volume where the sector number would need 64-bits which would then lead to disk corruption as the user would read/write random sectors on disk instead of the correct ones.

I looked at your code and do not quite understand the handling of
initialized size. You read it into a local copy while holding the
lock, but then after the lock is released it may change and, I'm
afraid, cause the same problems you mentioned.

What is an example of a platform with 32-bit sector_t? Interesting to know.

Is it really possible that ntfs_bmap() is called for non-data
attributes? In other words, what other attributes are accessible as
files? Just curious.

  reply	other threads:[~2014-10-16 15:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15 19:19 [PATCH] ntfs: add code to make FIBMAP ioctl work Sergei Antonov
2014-10-15 23:12 ` Andreas Dilger
2014-10-16 11:37   ` Sergei Antonov
2014-10-16 13:23   ` Anton Altaparmakov
2014-10-16 13:20 ` Anton Altaparmakov
2014-10-16 15:07   ` Sergei Antonov [this message]
2014-10-16 15:36     ` Anton Altaparmakov
2014-10-16 20:03       ` Sergei Antonov
2014-10-16 20:43         ` Anton Altaparmakov
2014-10-16 21:55           ` Anton Altaparmakov

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=CABikg9xu-DGAg+FZ9uTkG5+eA-zO1BE-qTrtKFSb52MHd1tkdQ@mail.gmail.com \
    --to=saproj@gmail.com \
    --cc=aia21@cantab.net \
    --cc=anton@tuxera.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).