write/write/fallocate quota leakage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Recently one "write vs fallocate" quota leakage was fixed, but
not completely. It is still possible if uninitialized extent which
covers several delay allocated regions converted to initialized one.

Take a look at test-case attached.
The issue is clear enough, but I don't have a good solution for now.
Off course we can add one more restriction to zeroout logic, but this is
unproductive way because we have to keep zeroout logic simple as possible.

Aneesh, do you have any sound ideas?

/* EXT4 delalloc reservation leakage testcase
 * To make that leackage more verbose please apply following patch
 * http://download.openvz.org/~dmonakhov/junk/ext4-sanity-check.patch
 */
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>

int main(int argc, char **argv)
{
	loff_t len, offset;
	int fd, ret;
	char buf[81920];
	if (argc != 2) {
		printf("Usage: %s <fname>\n", argv[0]);
		return 1;
	}
	fd = open(argv[1], O_CREAT|O_RDWR, 0777);
	ftruncate(fd, 40960);
	fsync(fd);
	ret = pwrite(fd, buf, 4096, 0);
	if (ret != 4096) {
		perror("write failed");
		return 1;
	}
	/* Leve one page gap between dirty pages */
	ret = pwrite(fd, buf, 8192, 8192);
	if (ret != 8192) {
		perror("write failed");
		return 1;
	}
	/* Create uninitialized extent */
	ret = fallocate(fd, 0x1, 0, 4096*5);
	if (ret) {
		perror("fallocate failed");
		return 1;
	}
	/* Force block allocation.
	 * Uninitialized extent will be converted to initialized one
	 * during ext4_map_blocks() on writing first pages set.
	 * Later second pages set will discover what blocks are already
	 * initialized, so reservation for that pages will leak.
	 */
	fsync(fd);
	return 0;
}

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux