Return-Path: Received: from mail.kernel.org ([198.145.29.136]:39091 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751920AbcD1XlQ (ORCPT ); Thu, 28 Apr 2016 19:41:16 -0400 From: Jaegeuk Kim To: gregkh@linuxfoundation.org, linux-stable@vger.kernel.org Cc: Jaegeuk Kim , "stable 4 . 5+" Subject: [PATCH for-4.5 1/8] f2fs crypto: fix corrupted symlink in encrypted case Date: Thu, 28 Apr 2016 16:40:43 -0700 Message-Id: <1461886850-41330-1-git-send-email-jaegeuk@kernel.org> Sender: stable-owner@vger.kernel.org List-ID: 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'. Cc: stable 4.5+ Signed-off-by: Jaegeuk Kim --- fs/f2fs/namei.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 6f944e5..7e9e387 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 */ -- 2.6.3