From 7e9e4616dc4cfd9ae28502000366b20d62abf516 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 21 Jul 2015 23:52:38 -0400 Subject: [PATCH] add patch detect-short-encrypted-directories --- detect-short-encrypted-directories | 31 +++++++++++++++++++++++++++++++ series | 1 + 2 files changed, 32 insertions(+) create mode 100644 detect-short-encrypted-directories diff --git a/detect-short-encrypted-directories b/detect-short-encrypted-directories new file mode 100644 index 00000000..fe33fdfb --- /dev/null +++ b/detect-short-encrypted-directories @@ -0,0 +1,31 @@ +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 +--- + fs/ext4/crypto_fname.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/fs/ext4/crypto_fname.c b/fs/ext4/crypto_fname.c +index 7dc4eb5..86ee996 100644 +--- a/fs/ext4/crypto_fname.c ++++ b/fs/ext4/crypto_fname.c +@@ -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); + diff --git a/series b/series index 310c4348..75eebd1c 100644 --- a/series +++ b/series @@ -2,6 +2,7 @@ speedup-jbd2_journal_dirty_metadata use-transaction-when-adding-crypto-policy +detect-short-encrypted-directories ########################################## # unstable patches -- 2.11.4.GIT