]> git.openpandora.org Git - pandora-kernel.git/commitdiff
ext4 crypto: handle unexpected lack of encryption keys
authorTheodore Ts'o <tytso@mit.edu>
Sun, 31 May 2015 17:35:39 +0000 (13:35 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 31 May 2015 17:35:39 +0000 (13:35 -0400)
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 <tytso@mit.edu>
fs/ext4/crypto.c
fs/ext4/crypto_policy.c
fs/ext4/file.c

index 1c9a8c499369f43d12c3e49c6e48a10319143532..efcb7c04d172ba4eb43cf997964d009a8e0cc903 100644 (file)
@@ -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
index a1d434d0dea8f89686e236e18d566500cc7c0185..02c4e5df7afb92986d13116777194bda133857f9 100644 (file)
@@ -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))) {
diff --cc fs/ext4/file.c
Simple merge