summaryrefslogtreecommitdiff
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-02-06 03:37:27 (GMT)
committerJaegeuk Kim <jaegeuk@kernel.org>2016-02-23 00:07:23 (GMT)
commit1dafa51d45c6332f255faee101d9c47eb56ea7c7 (patch)
tree9a555cf6ecacc8d20e3ee153836a2297e69f541e /fs/f2fs
parentce855a3bd0922f548a3c4937d6447c2ed4d4b1bc (diff)
downloadlinux-1dafa51d45c6332f255faee101d9c47eb56ea7c7.tar.xz
f2fs crypto: check for too-short encrypted file names
This patch adopts: ext4 crypto: check for too-short encrypted file names 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> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/crypto_fname.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/f2fs/crypto_fname.c b/fs/f2fs/crypto_fname.c
index e7aa67c..905c065 100644
--- a/fs/f2fs/crypto_fname.c
+++ b/fs/f2fs/crypto_fname.c
@@ -317,7 +317,10 @@ int f2fs_fname_disk_to_usr(struct inode *inode,
oname->len = iname->len;
return oname->len;
}
-
+ if (iname->len < F2FS_CRYPTO_BLOCK_SIZE) {
+ printk("encrypted inode too small");
+ return -EUCLEAN;
+ }
if (F2FS_I(inode)->i_crypt_info)
return f2fs_fname_decrypt(inode, iname, oname);