[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YH4KAHWphO+0xubA@gmail.com>
Date: Mon, 19 Apr 2021 15:53:52 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: Leah Rumancik <leah.rumancik@...il.com>
Cc: linux-ext4@...r.kernel.org, tytso@....edu
Subject: Re: [PATCH v3] ext4: wipe filename upon file deletion
On Mon, Apr 19, 2021 at 04:21:00PM +0000, Leah Rumancik wrote:
> Upon file deletion, zero out all fields in ext4_dir_entry2 besides inode
> and rec_len. In case sensitive data is stored in filenames, this ensures
> no potentially sensitive data is left in the directory entry upon deletion.
> Also, wipe these fields upon moving a directory entry during the conversion
> to an htree and when splitting htree nodes.
This should include more explanation about why this is useful, and what its
limitations are (e.g. how do the properties of the storage device affect whether
the filename is *really* deleted)...
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 883e2a7cd4ab..df7809a4821f 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -1778,6 +1778,11 @@ dx_move_dirents(char *from, char *to, struct dx_map_entry *map, int count,
> ((struct ext4_dir_entry_2 *) to)->rec_len =
> ext4_rec_len_to_disk(rec_len, blocksize);
> de->inode = 0;
> +
> + /* wipe name_len through and name field */
> + memset(&de->name_len, 0, ext4_rec_len_from_disk(de->rec_len,
> + blocksize) - 6);
> +
The comment is confusing. IMO it would make more sense to mention what is *not*
being zeroed:
/* wipe the dir_entry excluding the rec_len field */
de->inode = 0;
memset(&de->name_len, 0, ext4_rec_len_from_disk(de->rec_len,
blocksize) - 6);
> @@ -2492,6 +2498,11 @@ int ext4_generic_delete_entry(struct inode *dir,
> else
> de->inode = 0;
> inode_inc_iversion(dir);
> +
> + /* wipe name_len through name field */
> + memset(&de->name_len, 0,
> + ext4_rec_len_from_disk(de->rec_len, blocksize) - 6);
> +
> return 0;
And maybe here too, although here why is the condition for setting the inode to
0 not the same as the condition for zeroing the other fields?
Also, maybe use offsetof(struct ext4_dir_entry_2, name_len) instead of '6'...
- Eric
Powered by blists - more mailing lists