From 1da828b8bf9cb49a274e5a2fc76fdc843d19396f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 7 Nov 2020 17:42:02 +0100 Subject: Ext2FS: Zero out inode metadata when deleting them This isn't strictly necessary but it seems like a reasonable thing to be doing. Note that we still populate the dtime field with the time of deletion. --- Kernel/FileSystem/Ext2FileSystem.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index d991924b95..10750282f5 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -522,11 +522,6 @@ void Ext2FS::free_inode(Ext2FSInode& inode) dbg() << "Ext2FS: Inode " << inode.identifier() << " has no more links, time to delete!"; #endif - struct timeval now; - kgettimeofday(now); - inode.m_raw_inode.i_dtime = now.tv_sec; - write_ext2_inode(inode.index(), inode.m_raw_inode); - auto block_list = block_list_for_inode(inode.m_raw_inode, true); for (auto block_index : block_list) { @@ -535,6 +530,12 @@ void Ext2FS::free_inode(Ext2FSInode& inode) set_block_allocation_state(block_index, false); } + struct timeval now; + kgettimeofday(now); + memset(&inode.m_raw_inode, 0, sizeof(ext2_inode)); + inode.m_raw_inode.i_dtime = now.tv_sec; + write_ext2_inode(inode.index(), inode.m_raw_inode); + set_inode_allocation_state(inode.index(), false); if (inode.is_directory()) { -- cgit v1.2.3