diff options
| author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-03-30 13:13:16 -0700 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-13 12:33:14 +0200 |
| commit | 7ae521feb79a8b5d5188b99a9daeaca664505b49 (patch) | |
| tree | eec2ed66f01bfbbd8ca70ef7227351a2ded20d76 | |
| parent | aade968b93469199aa8b601f8d1219870f1313be (diff) | |
| download | android_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.c | 12 |
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 */ |
