From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756311AbcBIBfJ (ORCPT ); Mon, 8 Feb 2016 20:35:09 -0500 Received: from mail.kernel.org ([198.145.29.136]:53532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932962AbcBIBe0 (ORCPT ); Mon, 8 Feb 2016 20:34:26 -0500 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , "Theodore Ts'o" Subject: [PATCH 4/5] f2fs crypto: check for too-short encrypted file names Date: Mon, 8 Feb 2016 17:34:16 -0800 Message-Id: <1454981657-25473-4-git-send-email-jaegeuk@kernel.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1454981657-25473-1-git-send-email-jaegeuk@kernel.org> References: <1454981657-25473-1-git-send-email-jaegeuk@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Jaegeuk Kim --- fs/f2fs/crypto_fname.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- 2.6.3