From: Theodore Ts'o Date: Sun, 31 May 2015 17:35:39 +0000 (-0400) Subject: ext4 crypto: handle unexpected lack of encryption keys X-Git-Tag: omap-for-v4.2/fixes-rc1^2~122^2~33 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abdd438b26b409eaccf9c847fcf9c3ab52f1959e;p=pandora-kernel.git ext4 crypto: handle unexpected lack of encryption keys Fix up attempts by users to try to write to a file when they don't have access to the encryption key. Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index 1c9a8c499369..efcb7c04d172 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c @@ -104,7 +104,8 @@ struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode) unsigned long flags; struct ext4_crypt_info *ci = EXT4_I(inode)->i_crypt_info; - BUG_ON(ci == NULL); + if (ci == NULL) + return ERR_PTR(-ENOKEY); /* * We first try getting the ctx from a free list because in diff --git a/fs/ext4/crypto_policy.c b/fs/ext4/crypto_policy.c index a1d434d0dea8..02c4e5df7afb 100644 --- a/fs/ext4/crypto_policy.c +++ b/fs/ext4/crypto_policy.c @@ -183,7 +183,8 @@ int ext4_inherit_context(struct inode *parent, struct inode *child) if (res < 0) return res; ci = EXT4_I(parent)->i_crypt_info; - BUG_ON(ci == NULL); + if (ci == NULL) + return -ENOKEY; ctx.format = EXT4_ENCRYPTION_CONTEXT_FORMAT_V1; if (DUMMY_ENCRYPTION_ENABLED(EXT4_SB(parent->i_sb))) { Reading git-diff-tree failed