linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* write/write/fallocate quota leakage
@ 2010-06-03  8:21 Dmitry Monakhov
  2010-06-04  9:03 ` Aneesh Kumar K. V
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Monakhov @ 2010-06-03  8:21 UTC (permalink / raw)
  To: Aneesh Kumar K. V.; +Cc: linux-ext4

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

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?


[-- Attachment #2: falloc_opt.c --]
[-- Type: text/plain, Size: 1171 bytes --]

/* 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;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-04  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-03  8:21 write/write/fallocate quota leakage Dmitry Monakhov
2010-06-04  9:03 ` Aneesh Kumar K. V

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).