[PATCH 05/10] e2fsck: validate fscrypt_symlink_data.len for fast symlinks too

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Eric Biggers <ebiggers@xxxxxxxxxx>

Both fast and slow encrypted symlinks are prefixed with the ciphertext
length field (fscrypt_symlink_data.len).  But e2fsck was only checking
it for slow symlinks.  Start checking it for fast symlinks too.  This
matches the kernel handling of encrypted symlinks.

Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
---
 e2fsck/pass1.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 723acf09..d9df28ed 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -183,6 +183,7 @@ int e2fsck_pass1_check_device_inode(ext2_filsys fs EXT2FS_ATTR((unused)),
 int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
 			       struct ext2_inode *inode, char *buf)
 {
+	unsigned int buflen;
 	unsigned int len;
 	int i;
 	ext2_extent_handle_t	handle;
@@ -232,9 +233,8 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
 		if (inode->i_size >= sizeof(inode->i_block))
 			return 0;
 
-		len = strnlen((char *)inode->i_block, sizeof(inode->i_block));
-		if (len == sizeof(inode->i_block))
-			return 0;
+		buf = (char *)inode->i_block;
+		buflen = sizeof(inode->i_block);
 	} else {
 		if ((inode->i_size >= fs->blocksize) ||
 		    (inode->i_block[0] < fs->super->s_first_data_block) ||
@@ -248,14 +248,17 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
 		if (io_channel_read_blk64(fs->io, inode->i_block[0], 1, buf))
 			return 0;
 
-		if (inode->i_flags & EXT4_ENCRYPT_FL) {
-			len = ext2fs_le16_to_cpu(*((__u16 *)buf)) + 2;
-		} else {
-			len = strnlen(buf, fs->blocksize);
-		}
-		if (len >= fs->blocksize)
-			return 0;
+		buflen = fs->blocksize;
 	}
+
+	if (inode->i_flags & EXT4_ENCRYPT_FL)
+		len = ext2fs_le16_to_cpu(*(__u16 *)buf) + 2;
+	else
+		len = strnlen(buf, buflen);
+
+	if (len >= buflen)
+		return 0;
+
 	if (len != inode->i_size)
 		if ((inode->i_flags & EXT4_ENCRYPT_FL) == 0)
 			return 0;
-- 
2.16.2.395.g2e18187dfd-goog




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux