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]
Date:	Tue, 12 Jun 2012 17:36:03 +0200
From:	Paolo Bonzini <pbonzini@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	linux-fsdevel@...r.kernel.org, xfs@....sgi.com,
	Al Viro <viro@...iv.linux.org.uk>
Subject: [PATCH 1/2] vfs: add FALLOC_FL_ZERO_RANGE to fallocate

Add a new operation mode to fallocate, called FALLOC_FL_ZERO_RANGE.
It resembles the similarly named XFS ioctl.  Filesystems should
preallocate blocks for regions that span holes in the file, and convert
the entire range to unwritten extents.   This operation is a fast method
of overwriting any from the range specified with zeros without removing
any blocks or having to write zeros to disk.  Any subsequent read in
the given range will return zeros until new data is written.

This functionality requires filesystems to support unwritten extents.
If xfs_info(8) reports unwritten=1, then the filesystem was made to
flag unwritten extents.  It is okay to report EOPNOTSUPP and let the
application deal with the outcome, but it is not okay to succeed or
report EOPNOTSUPP for the same inode depending on the other arguments.

FALLOC_FL_PUNCH_HOLE|FALLOC_FL_ZERO_RANGE is ruled out here, at the
vfs level, rather than leaving it to the filesystems.  This way, in the
future 0x6 could be used as a third mode.

Cc: Al Viro <viro@...iv.linux.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
---
 fs/open.c              |    8 +++++++-
 include/linux/falloc.h |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index d6c79a0..dd812b3 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -222,8 +222,14 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
 	if (offset < 0 || len <= 0)
 		return -EINVAL;
 
+	/* Punch hole and write-zeroes are mutually exclusive */
+	if ((mode & FALLOC_FL_PUNCH_HOLE) &&
+	    (mode & FALLOC_FL_ZERO_RANGE))
+		return -EINVAL;
+
 	/* Return error if mode is not supported */
-	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
+		     FALLOC_FL_ZERO_RANGE))
 		return -EOPNOTSUPP;
 
 	/* Punch hole must have keep size set */
diff --git a/include/linux/falloc.h b/include/linux/falloc.h
index 73e0b62..9aa9599 100644
--- a/include/linux/falloc.h
+++ b/include/linux/falloc.h
@@ -3,6 +3,7 @@
 
 #define FALLOC_FL_KEEP_SIZE	0x01 /* default is extend size */
 #define FALLOC_FL_PUNCH_HOLE	0x02 /* de-allocates range */
+#define FALLOC_FL_ZERO_RANGE	0x04 /* write zeroes */
 
 #ifdef __KERNEL__
 
-- 
1.7.1


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ