ext2/ext3 secure delete

Submitted by Anonymous
on June 15, 2004 - 9:21am

Hello,

I am working on modifying my 2.4.20 linux kernel to do secure deletion of files.
I want to write zeros over the data blocks before a file is deleted. I have been trying to use the destroy_block() function(included at the bottom) to accomplish this.

Here's my original plan:
I wanted to call the destroy_block() function starting at the first data block of the file and use bh->b_next to traverse through all of the data blocks. I have put the destroy_block() function into inode.c and was calling destroy_block from ext2_truncate_all() which is my modified version of ext2_truncate(). I then called ext2_truncate_all() within ext2_unlink.
The problem that I ran into with this plan was that I could not figure out how to get to the first block of the file in order to pass it to destroy_block().

Alternative plan:
I read some newsgroup postings that told me that modifying truncate() is not a safe thing to do. So I tried putting the destroy_block() function in ext2_free_blocks() instead of calling it from ext2_unlink(). Unfortunately, this causes the system to freeze up whenever I try to write to the filesystem (ext2) that I am testing with.

I am hoping to get the secure delete working on ext2 first, then port it over to ext3 in order to take advantage of journaling.
At this point, I have hit a brick wall. I am not sure what to try next and was wondering if anyone could possibly point me in the right direction.

Thanks ahead of time,
Ken

static inline void destroy_block(struct inode *inode, unsigned long block)
{
struct buffer_head * bh;

bh = sb_getblk(inode->i_sb, block);
memset(bh->b_data, 0x00, bh->b_size);

mark_buffer_dirty(bh);
wait_on_buffer(bh);
brelse(bh);

return;
}

already done?

on
June 15, 2004 - 9:56am

google for 'grugq ext2 privacy'. It exists for ext3 as well. Maybe what you need is already there.

-Rik

tried that code already.

Anonymous
on
June 16, 2004 - 11:53am

I tried grugq's code and it didn't work. It caused the kernel to crash when I tried to write anything to my ext2 test partition. It ends with a segmentation fault and dumps the contents of the processor registers to the screen and it shows that ext2_free_blocks is where the problem is. That is where I implemented destroy_block().

Ken

rsbac also has secure delete

Anonymous
on
July 25, 2004 - 1:38pm

rsbac also has secure delete
www.rsbac.org

ofcourse its much more extensive than just that but maybe its useful for you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.