Skip to contentSkip to conversation

Secure Deletion and Trash-Bin Support for Ext4

PATCH In review Harry Papaxenopoulos 1 participant 1 message Jan 31, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 Secure Deletion and Trash-Bin Support for Ext4

Note:
-----
These patches are being resubmitted as part of the call for all ext4 patches. It uses the 2.6.20-rc6 version as its base. All the changes that have been requested are completed.

Original patch description:
---------------------------
The patch moves the files marked with the -s (secure deletion) or the -u (undelete) ext2/3/4 attributes to a .trash/<uid>/ directory. It does so reliably because it does it in the kernel upon every unlink operation. User-mode tools can miss some unlinks, which is unacceptable for secure deletion. The per-user subdirectories allow us to solve the problem with permissions. The .trash directory is owned by root and has drwxr-xr-x permissions. The per-uid subdirectories are owned and only accessible by their corresponding owners (drwx------) so users cannot read each other's files in the trash. Alternative solutions would require changing a lot of ext3 code.

Right now we do not store the whole path to the file moved into the trash-bin. We keep the filenames or append them with numbers in case of collisions. In the future we may change it to store the whole path information if necessary.

Later (e.g., when the system is idle) a user-mode daemon can just scan .trash's subdirectories, overwrite the files marked with -s, and unlink the files. The purging and data overwriting is performed entirely in user space. It may or may not be necessary to add a mechanism for the file system to initiate the user-mode deletion once the space becomes scarce.

The benefits of this secure deletion approach are obvious:
1) small kernel patch;
2) two solutions (trash-bin and secure deletion) in one;
3) the user-mode part can be made arbitrarily complex and overwrite with many patterns, many times, and at configurable times; and
4) most of the code can be reused for other file systems in the future.

Changes from the last submission:
---------------------------------
1. Since most of the code is done in the vfs layer, we decided - as suggested - to hook the vfs layer so we get a universal undelete implementation for all filesystems. All that needs to be done by the underlying filesystem is simply make the undelete call at the necessary points.
2. Filenames have been renamed to: trashbin.c and trashbin.h as requested.
3. We have added Trash-Bin functionality for the following filesystems:
ext2, ext3, ext4, jfs.

We will really appreciate any comments, help, and feedback.

Thank you,
Harry Papaxenopoulos, Nikolai Joukov, and Erez Zadok. Filesystems and Storage Laboratory,
Stony Brook University

src/linux-2.6.20-rc6-trashbin/include/linux/trashbin.h new file +16 -0
Index: sdfs/src/linux-2.6.20-rc6-trashbin/include/linux/trashbin.h
===================================================================
@@ -0,0 +1,16 @@
+/* include/linux/trashbin.h
+ *
+ * Copyright (C) 2007 Stony Brook University
+ * Harry Papaxenopoulos, Nikolai Joukov, and Erez Zadok
+ */
+
+#define TB_NAME ".trash"
+#define TB_NAME_LEN 6
+#define TB_MODE S_IRUGO | S_IXUGO | S_IRWXU | S_IFDIR
+#define TB_USER_MODE S_IRWXU | S_IFDIR
+#define TB_UID_MAX_LEN 6
+
+extern int vfs_create_trash_bin(struct super_block *);
+extern int vfs_trash_entry(struct inode *, struct dentry *);
+extern struct dentry *vfs_get_user_dentry(struct inode *old_dir, int create);
+
src/linux-2.6.20-rc6-trashbin/fs/trashbin.c new file +241 -0

241 lines not on this page · raw message

src/linux-2.6.20-rc6-trashbin/include/linux/fs.h +1 -0
Index: sdfs/src/linux-2.6.20-rc6-trashbin/include/linux/fs.h
===================================================================
@@ -121,6 +121,7 @@ extern int dir_notify_enable;
 #define MS_SLAVE	(1<<19)	/* change to slave */
 #define MS_SHARED	(1<<20)	/* change to shared */
 #define MS_RELATIME	(1<<21)	/* Update atime relative to mtime/ctime. */
+#define MS_TRASHBIN	(1<<22) /* VFS trashbin functionality */
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
 
src/linux-2.6.20-rc6-trashbin/fs/Makefile +2 -0
Index: sdfs/src/linux-2.6.20-rc6-trashbin/fs/Makefile
===================================================================
@@ -59,6 +59,8 @@ obj-y				+= devpts/
 
 obj-$(CONFIG_PROFILING)		+= dcookies.o
 obj-$(CONFIG_DLM)		+= dlm/
+
+obj-$(CONFIG_TRASHBIN)		+= trashbin.o
 
 # Do not add any filesystems before this line
 obj-$(CONFIG_REISERFS_FS)	+= reiserfs/
src/linux-2.6.20-rc6-trashbin/fs/Kconfig +8 -0
Index: sdfs/src/linux-2.6.20-rc6-trashbin/fs/Kconfig
===================================================================
@@ -6,6 +6,14 @@ menu "File systems"
 
 if BLOCK
 
+config TRASHBIN
+	bool "Trash-bin functionality"
+	help
+	  Trash bin functionality enables users to easily recover previously
+	  deleted files.
+
+	  If you are unsure, say N.
+
 config EXT2_FS
 	tristate "Second extended fs support"
 	help
src/linux-2.6.20-rc6-trashbin/include/linux/mount.h +1 -0
Index: sdfs/src/linux-2.6.20-rc6-trashbin/include/linux/mount.h
===================================================================
@@ -28,6 +28,7 @@ struct mnt_namespace;
 #define MNT_NOATIME	0x08
 #define MNT_NODIRATIME	0x10
 #define MNT_RELATIME	0x20
+#define MNT_TRASHBIN	0x40
 
 #define MNT_SHRINKABLE	0x100