]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: require i_size == fscrypt_symlink_data.len + 2
authorEric Biggers <ebiggers@google.com>
Sat, 3 Mar 2018 00:59:19 +0000 (16:59 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 3 Mar 2018 22:09:25 +0000 (17:09 -0500)
e2fsck validates that unencrypted symlinks have their strlen() equal to
i_size.  But it skips the equivalent check of i_size ==
fscrypt_symlink_data.len + 2 for encrypted symlinks.  Actually, the
encrypted symlink header is redundant with i_size and shouldn't exist.
But it's there, and the kernel does in fact use the length in the header
instead of i_size -- so e2fsck should validate the header.

Thus, remove the exception for encrypted symlinks, so e2fsck will now
require i_size == fscrypt_symlink_data.len + 2.  I think the exception
was only there originally because for encrypted fast symlinks we were
calculating the length using strnlen() which was wrong.  But that was
fixed by the previous patch.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c

index d9df28edb96025f6a16a22f69f69e669d5920fe6..6a6c5969b28139534774eeffb015153e03dc86a8 100644 (file)
@@ -260,8 +260,7 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
                return 0;
 
        if (len != inode->i_size)
-               if ((inode->i_flags & EXT4_ENCRYPT_FL) == 0)
-                       return 0;
+               return 0;
        return 1;
 }