Re: [PROGS PATCH] Import btrfs-extent-same

David Sterba
Tue, 03 Sep 2013 13:28:07 -0000

On Mon, Sep 02, 2013 at 05:53:42PM +0100, Simon Farnsworth
wrote:
> On Monday 2 September 2013 18:43:58 David Sterba wrote:
> > Yes that''s what I meant and that''s what dupremove in
your git tree does,
> > right?
> >
> > Using the EXTENT_SAME ioctl without any checks is dangerous, and
that''s
> > what btrfs-extent-same.c does, so it''s suitable for testing
but not
> > about to be given to users as-is.
> >
> Why is using EXTENT_SAME without any checks dangerous?
>
> If userspace has to do checks to guarantee safety, what stops an attacker
> deliberately triggering a TOCTTOU race against a checked user of
EXTENT_SAME?
> I would expect that unchecked use of EXTENT_SAME simply causes the kernel
to
> return BTRFS_SAME_DATA_DIFFERS most of the time, thus slowing you down.

I was mistaken, the ioctl does checks before merging the extents. Sorry
for confusion.