summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-03-30 13:13:16 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2016-03-30 13:21:15 -0700
commitc90e09f7fb498f81cd4e8bb6460d3a26ccebeca3 (patch)
tree8eab6962797d7215274be9ac542f6517f00eb579 /fs/f2fs
parentfd694733d523df1e0a583cf5c4c08e41d7bf9fa3 (diff)
downloadlinux-c90e09f7fb498f81cd4e8bb6460d3a26ccebeca3.tar.bz2
f2fs crypto: fix corrupted symlink in encrypted case
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'. Cc: stable 4.5+ <stable@vger.kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-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 7876f1052101..6214d9ec89f2 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1027,12 +1027,6 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
goto errout;
}
- /* this is broken symlink case */
- if (unlikely(cstr.name[0] == 0)) {
- res = -ENOENT;
- goto errout;
- }
-
if ((cstr.len + sizeof(struct fscrypt_symlink_data) - 1) > max_size) {
/* Symlink data on the disk is corrupted */
res = -EIO;
@@ -1046,6 +1040,12 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
if (res < 0)
goto errout;
+ /* this is broken symlink case */
+ if (unlikely(pstr.name[0] == 0)) {
+ res = -ENOENT;
+ goto errout;
+ }
+
paddr = pstr.name;
/* Null-terminate the name */