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>
This commit is contained in:
parent
fd694733d5
commit
c90e09f7fb
|
@ -1027,12 +1027,6 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
|
||||||
goto errout;
|
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) {
|
if ((cstr.len + sizeof(struct fscrypt_symlink_data) - 1) > max_size) {
|
||||||
/* Symlink data on the disk is corrupted */
|
/* Symlink data on the disk is corrupted */
|
||||||
res = -EIO;
|
res = -EIO;
|
||||||
|
@ -1046,6 +1040,12 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
|
/* this is broken symlink case */
|
||||||
|
if (unlikely(pstr.name[0] == 0)) {
|
||||||
|
res = -ENOENT;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
paddr = pstr.name;
|
paddr = pstr.name;
|
||||||
|
|
||||||
/* Null-terminate the name */
|
/* Null-terminate the name */
|
||||||
|
|
Loading…
Reference in New Issue