lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1248211771.20743.2.camel@bobble.smo.corp.google.com>
Date:	Tue, 21 Jul 2009 14:29:31 -0700
From:	Frank Mayhar <fmayhar@...gle.com>
To:	Eric Sandeen <sandeen@...hat.com>
Cc:	Curt Wohlgemuth <curtw@...gle.com>,
	ext4 development <linux-ext4@...r.kernel.org>
Subject: Re: Question on fallocate/ftruncate sequence

On Mon, 2009-07-20 at 17:45 -0500, Eric Sandeen wrote: 
> Curt Wohlgemuth wrote:
> > We've recently seen some interesting behavior with ftruncate()
> > following a fallocate() call on ext4, and would like to know if this
> > is intended or not.
> > 
> > The sequence used from user space:
> > 
> > fd = open()
> > fallocate(fd, FALLOC_FL_KEEP_SIZE, 8MB)
> > write(fd, buf, 64KB)
> > ftruncate(fd, 64KB)
> > close(fd)
> > 
> > Since inode_setattr() only does something if the input size is not the
> > same as inode->i_size, the ftruncate() call above does nothing; no
> > blocks from the fallocate() are freed up.
> > 
> > Yes, removing the KEEP_SIZE flag gets the behavior I'm expecting, but
> > KEEP_SIZE is quite convenient in recovering from errors.
> > 
> > I would have thought that ftruncate() would alter i_disksize even if
> > this value is different from i_size.
> > 
> > Any comments?  I looked at other Linux file systems, and none that I
> > saw that support fallocate() have this issue.
> > 
> > Thanks,
> > Curt
> 
> Yep, I think you've found a bug, I will look into this soon unless
> someone beats me to it :)

I've spent a little while today digging into this.  My guess (only a
guess at this point until I have a chance to prove it) is that
i_disksize should be updated by fallocate() even when KEEP_SIZE is
specified.  It's currently not updated in that case.  It's my
understanding that i_disksize should be the real allocation, right?
While i_size is the size that has actually been used?  If so, then
setting i_disksize is probably what's missing.
-- 
Frank Mayhar <fmayhar@...gle.com>
Google, Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ