aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-03-30 13:13:16 -0700
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:33:14 +0200
commit7ae521feb79a8b5d5188b99a9daeaca664505b49 (patch)
treeeec2ed66f01bfbbd8ca70ef7227351a2ded20d76
parentaade968b93469199aa8b601f8d1219870f1313be (diff)
downloadandroid_kernel_m2note-7ae521feb79a8b5d5188b99a9daeaca664505b49.tar.gz
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>
-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 a0bb668bc..cd4bc5584 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -762,12 +762,6 @@ static void *f2fs_encrypted_follow_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;
@@ -781,6 +775,12 @@ static void *f2fs_encrypted_follow_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 */