From: Alexander Holler <holler@ahsoftware.de>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Alexander Holler <holler@ahsoftware.de>
Subject: [PATCH 2/5] WIP: fs: fat: support unlinkat_s() for secure deletion of files
Date: Mon, 2 Feb 2015 18:05:10 +0100 [thread overview]
Message-ID: <1422896713-25367-3-git-send-email-holler@ahsoftware.de> (raw)
In-Reply-To: <1422896713-25367-1-git-send-email-holler@ahsoftware.de>
Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
fs/fat/fat.h | 1 +
fs/fat/fatent.c | 20 ++++++++++++++++++++
fs/fat/inode.c | 13 +++++++++++++
3 files changed, 34 insertions(+)
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index e0c4ba3..b9febda 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -81,6 +81,7 @@ struct msdos_sb_info {
unsigned int prev_free; /* previously allocated cluster number */
unsigned int free_clusters; /* -1 if undefined */
unsigned int free_clus_valid; /* is free_clusters valid? */
+ atomic_t secure_delete; /* delete blocks securely? */
struct fat_mount_options options;
struct nls_table *nls_disk; /* Codepage used on disk */
struct nls_table *nls_io; /* Charset used for input and display */
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index 260705c..b3b9c11 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -575,6 +575,10 @@ int fat_free_clusters(struct inode *inode, int cluster)
goto error;
}
+ // TODO:
+ // if (atomic_read(&sbi->secure_delete) && secure_trim_available)
+ // use secure trim
+ // else
if (sbi->options.discard) {
/*
* Issue discard for the sectors we no longer
@@ -591,6 +595,22 @@ int fat_free_clusters(struct inode *inode, int cluster)
first_cl = cluster;
}
+ } else if (atomic_read(&sbi->secure_delete)) {
+ /*
+ * Fill blocks with zero for the sectors we no
+ * longer care about, batching contiguous clusters
+ * into one request.
+ */
+ if (cluster != fatent.entry + 1) {
+ int nr_clus = fatent.entry - first_cl + 1;
+
+ sb_issue_zeroout(sb,
+ fat_clus_to_blknr(sbi, first_cl),
+ nr_clus * sbi->sec_per_clus,
+ GFP_NOFS);
+
+ first_cl = cluster;
+ }
}
ops->ent_put(&fatent, FAT_ENT_FREE);
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..9073690 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -816,6 +816,17 @@ int fat_sync_inode(struct inode *inode)
EXPORT_SYMBOL_GPL(fat_sync_inode);
+static void fat_set_secure_delete(struct super_block *sb, bool secure)
+{
+ struct msdos_sb_info *sbi = MSDOS_SB(sb);
+ // TODO: will overflow with a very large number of
+ // concurrent calls of unlinkat_s().
+ if (secure)
+ atomic_inc(&sbi->secure_delete);
+ else
+ atomic_dec(&sbi->secure_delete);
+}
+
static int fat_show_options(struct seq_file *m, struct dentry *root);
static const struct super_operations fat_sops = {
.alloc_inode = fat_alloc_inode,
@@ -827,6 +838,7 @@ static const struct super_operations fat_sops = {
.remount_fs = fat_remount,
.show_options = fat_show_options,
+ .set_secure_delete = fat_set_secure_delete,
};
static int fat_show_options(struct seq_file *m, struct dentry *root)
@@ -1580,6 +1592,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
sbi->root_cluster = 0;
sbi->free_clusters = -1; /* Don't know yet */
sbi->free_clus_valid = 0;
+ atomic_set(&sbi->secure_delete, 0);
sbi->prev_free = FAT_START_ENT;
sb->s_maxbytes = 0xffffffff;
--
2.1.0
next prev parent reply other threads:[~2015-02-02 17:05 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-02 17:05 [PATCH 0/5] RFC: Offer a way for userspace to request real deletion of files Alexander Holler
2015-02-02 17:05 ` [PATCH 1/5] WIP: Add syscall unlinkat_s (currently x86* only) Alexander Holler
2015-02-03 6:05 ` Al Viro
2015-02-03 6:58 ` Alexander Holler
2015-02-03 7:56 ` Al Viro
2015-02-03 8:01 ` Alexander Holler
2015-02-03 8:10 ` Al Viro
2015-02-03 8:17 ` Alexander Holler
2015-02-03 8:51 ` Alexander Holler
2015-02-03 9:23 ` Alexander Holler
2015-02-03 12:48 ` Alexander Holler
2015-02-03 12:54 ` Alexander Holler
2015-02-03 17:48 ` Theodore Ts'o
2015-02-03 18:01 ` Alexander Holler
2015-02-03 23:33 ` Al Viro
2015-02-04 0:18 ` Alex Elsayed
2015-02-04 4:16 ` Andreas Dilger
2015-02-04 10:19 ` Alexander Holler
2015-02-04 12:07 ` Lukáš Czerner
2015-02-04 12:22 ` Alexander Holler
2015-02-04 12:42 ` Alexander Holler
2015-02-04 12:50 ` Alexander Holler
2015-02-04 13:07 ` Alexander Holler
2015-02-04 13:06 ` Michael Kerrisk
2015-02-04 13:21 ` Alexander Holler
[not found] ` <54D21CC8.4020705-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 13:29 ` Alexander Holler
[not found] ` <54D21EB8.6020208-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 14:19 ` Alexander Holler
[not found] ` <54D22A63.7090603-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 15:00 ` Austin S Hemmelgarn
2015-02-04 14:52 ` Lukáš Czerner
[not found] ` <alpine.LFD.2.00.1502041533130.26766-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-02-04 16:12 ` Alexander Holler
2015-02-04 16:25 ` Lukáš Czerner
[not found] ` <alpine.LFD.2.00.15020 41724180.26766@localhost.localdomain>
[not found] ` <alpine.LFD.2.00.1502041724180.26766-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-02-04 16:45 ` Alexander Holler
[not found] ` <54D24CA5.6080603-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 16:53 ` Alexander Holler
2015-02-04 19:33 ` Theodore Ts'o
2015-02-04 19:56 ` Alexander Holler
2015-02-03 16:44 ` Alex Elsayed
2015-02-03 7:58 ` Davidlohr Bueso
2015-02-03 7:52 ` Alexander Holler
[not found] ` <1422896713-25367-2-git-send-email-holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 8:01 ` Michael Kerrisk
2015-02-02 17:05 ` Alexander Holler [this message]
2015-02-02 17:05 ` [PATCH 3/5] WIP: fs: ext4: support unlinkat_s() for secure deletion of files Alexander Holler
2015-02-03 13:50 ` Lukáš Czerner
2015-02-03 14:50 ` Alexander Holler
2015-02-03 15:13 ` Alexander Holler
2015-02-03 15:24 ` Alexander Holler
2015-02-03 15:41 ` Lukáš Czerner
2015-02-03 15:46 ` Alexander Holler
2015-02-03 16:38 ` Alexander Holler
2015-02-03 18:50 ` Alexander Holler
2015-02-02 17:05 ` [PATCH 4/5] WIP: Add patch for coreutils to support unlinkat_s (x86_64 only) Alexander Holler
2015-02-02 17:05 ` [PATCH 5/5] WIP: Add test for unlinkat_s Alexander Holler
2015-02-03 15:15 ` [PATCH 0/5] RFC: Offer a way for userspace to request real deletion of files One Thousand Gnomes
2015-02-03 15:45 ` Alexander Holler
[not found] ` <1422896713-25367-1-git-send-email-holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 8:01 ` Michael Kerrisk
2015-02-06 12:17 ` Alexander Holler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422896713-25367-3-git-send-email-holler@ahsoftware.de \
--to=holler@ahsoftware.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).