public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Leah Rumancik <leah.rumancik@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH v3] ext4: wipe filename upon file deletion
Date: Mon, 19 Apr 2021 15:53:52 -0700	[thread overview]
Message-ID: <YH4KAHWphO+0xubA@gmail.com> (raw)
In-Reply-To: <20210419162100.1284475-1-leah.rumancik@gmail.com>

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

  reply	other threads:[~2021-04-19 22:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 16:21 [PATCH v3] ext4: wipe filename upon file deletion Leah Rumancik
2021-04-19 22:53 ` Eric Biggers [this message]
2021-04-20  1:59   ` Theodore Ts'o
2021-04-20 14:55     ` Leah Rumancik
2021-04-22 17:44     ` Andreas Dilger
2021-04-22 19:58       ` Theodore Ts'o

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=YH4KAHWphO+0xubA@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=leah.rumancik@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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