summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-03-30 23:13:16 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-05-05 00:49:12 +0300
commit5ca2636ec33c4857eae6061f4b97e52d0688b1f3 (patch)
tree498b0c36f89080a75fea9f5dcdbc7a365824f87c
parentb44d9268b28264da0b0777e3ec4d4d70bc91d09d (diff)
downloadlinux-5ca2636ec33c4857eae6061f4b97e52d0688b1f3.tar.xz
f2fs crypto: fix corrupted symlink in encrypted case
commit c90e09f7fb498f81cd4e8bb6460d3a26ccebeca3 upstream. In the encrypted symlink case, we should check its corrupted symname after decrypting it. Otherwise, we can report -ENOENT incorrectly, if encrypted symname starts with '\0'. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/f2fs/namei.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 6f944e5eb76e..7e9e38769660 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -980,12 +980,6 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
}
memcpy(cstr.name, sd->encrypted_path, cstr.len);
- /* this is broken symlink case */
- if (unlikely(cstr.name[0] == 0)) {
- res = -ENOENT;
- goto errout;
- }
-
if ((cstr.len + sizeof(struct f2fs_encrypted_symlink_data) - 1) >
max_size) {
/* Symlink data on the disk is corrupted */
@@ -1002,6 +996,12 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
kfree(cstr.name);
+ /* this is broken symlink case */
+ if (unlikely(pstr.name[0] == 0)) {
+ res = -ENOENT;
+ goto errout;
+ }
+
paddr = pstr.name;
/* Null-terminate the name */