Skip to content

Commit

Permalink
ext4 crypto: check for too-short encrypted file names
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tytso committed Jul 17, 2015
1 parent 806c24a commit 27977b6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/ext4/crypto_fname.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 27977b6

Please sign in to comment.