]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ext4 crypto: check for too-short encrypted file names
authorTheodore Ts'o <tytso@mit.edu>
Fri, 17 Jul 2015 15:33:16 +0000 (11:33 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 17 Jul 2015 15:33:16 +0000 (11:33 -0400)
An encrypted file name should never be shorter than an 16 bytes, the
AES block size.  The 3.10 crypto layer will oops and crash the kernel
if ciphertext shorter than the block size is passed to it.

Fortunately, in modern kernels the crypto layer will not crash the
kernel in this scenario, but nevertheless, it represents a corrupted
directory, and we should detect it and mark the file system as
corrupted so that e2fsck can fix this.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/crypto_fname.c

index 7dc4eb55913c445c5065646c99949b66d87979b5..86ee996a2bd4b2b2d4a7af1aa7c2fa51de117c7f 100644 (file)
@@ -329,6 +329,10 @@ int _ext4_fname_disk_to_usr(struct inode *inode,
                        return oname->len;
                }
        }
+       if (iname->len < EXT4_CRYPTO_BLOCK_SIZE) {
+               EXT4_ERROR_INODE(inode, "encrypted inode too small");
+               return -EUCLEAN;
+       }
        if (EXT4_I(inode)->i_crypt_info)
                return ext4_fname_decrypt(inode, iname, oname);