From: Eric Biggers <ebiggers@google.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Eric Biggers <ebiggers3@gmail.com>,
Ext4 Developers List <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] ext4: don't BUG when truncating encrypted inodes on the orphan list
Date: Mon, 13 Feb 2017 10:19:55 -0800 [thread overview]
Message-ID: <20170213181955.GA44321@google.com> (raw)
In-Reply-To: <20170213151927.vi4pzuggm5t6kqe5@thunk.org>
On Mon, Feb 13, 2017 at 10:19:27AM -0500, Theodore Ts'o wrote:
>
> > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> > > index bc282f9d0969..831d025e59ad 100644
> > > --- a/fs/ext4/inode.c
> > > +++ b/fs/ext4/inode.c
> > > @@ -3944,6 +3944,10 @@ static int ext4_block_truncate_page(handle_t *handle,
> > > unsigned blocksize;
> > > struct inode *inode = mapping->host;
> > >
> > > + /* If we are processing an encrypted inode during orphan list handling */
> > > + if (!fscrypt_has_encryption_key(inode))
> > > + return 0;
> > > +
> > > blocksize = inode->i_sb->s_blocksize;
> > > length = blocksize - (offset & (blocksize - 1));
> >
> > Shouldn't it be:
> >
> > if (ext4_encrypted_inode(inode) && S_ISREG(inode->i_mode) &&
> > !fscrypt_has_encryption_key(inode))
> > return 0;
> >
> > ... since only encrypted regular files should be skipped?
>
> We certainly don't want to add the ext4_encrypted_inode() test, since
> this can fail even if -O encrypt is not enabled. As for checking for
> regular files, we could potentially fall into this code path for
> non-regular files too (symlinks with length greater than 60 bytes come
> to mind), and if we don't have the encryption key, there's no *point*
> to try to zero beyond i_size --- and if we do, we're going to fail
> with a BUG.
>
Are you sure? ext4_encrypted_inode() only checks the inode flag; it doesn't
check the superblock flag too. If we check for just
!fscrypt_has_encryption_key(), the zeroing will get skipped for all
*unencrypted* files too.
Also, my suggestion matches the logic in
__ext4_block_zero_page_range() where the BUG() is actually being hit:
if (S_ISREG(inode->i_mode) &&
ext4_encrypted_inode(inode)) {
/* We expect the key to be set. */
BUG_ON(!fscrypt_has_encryption_key(inode));
BUG_ON(blocksize != PAGE_SIZE);
WARN_ON_ONCE(fscrypt_decrypt_page(page->mapping->host,
page, PAGE_SIZE, 0, page->index));
}
- Eric
next prev parent reply other threads:[~2017-02-13 18:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-11 3:19 [PATCH] ext4: don't BUG when truncating encrypted inodes on the orphan list Theodore Ts'o
2017-02-11 7:26 ` Andreas Dilger
2017-02-12 2:27 ` Theodore Ts'o
2017-03-09 13:47 ` Jan Kara
2017-03-09 19:21 ` Andreas Dilger
2017-02-12 8:38 ` Vegard Nossum
2017-02-13 0:31 ` Theodore Ts'o
2017-02-13 2:58 ` Vegard Nossum
2017-02-13 15:27 ` Theodore Ts'o
2017-02-12 22:09 ` Eric Biggers
2017-02-13 15:19 ` Theodore Ts'o
2017-02-13 18:19 ` Eric Biggers [this message]
2017-02-14 5:03 ` [PATCH -v2] " Theodore Ts'o
-- strict thread matches above, loose matches on Subject: below --
2017-03-15 22:23 [PATCH] " Eric Biggers
2017-03-16 13:54 ` Greg Kroah-Hartman
2017-03-15 22:26 Eric Biggers
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=20170213181955.GA44321@google.com \
--to=ebiggers@google.com \
--cc=ebiggers3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.