linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao2.yu@samsung.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Changman Lee <cm224.lee@samsung.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [f2fs-dev][PATCH 1/2] f2fs: check name_len of dir entry to prevent from deadloop
Date: Wed, 02 Jul 2014 13:23:47 +0800	[thread overview]
Message-ID: <000001cf95b5$eac71ad0$c0555070$@samsung.com> (raw)

We assume that modification of some special application could result in zeroed
name_len, or it is consciously made by somebody. We will deadloop in
find_in_block when name_len of dir entry is zero.

This patch is added for preventing deadloop in above scenario.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/dir.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index be8c7af..4316ec5 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
 			}
 		}
 
+		/* check name_len to prevent from deadloop here */
+		if (unlikely(de->name_len == 0)) {
+			struct inode *inode = dentry_page->mapping->host;
+
+			f2fs_msg(inode->i_sb, KERN_ERR,
+				"zero-length dir entry, ino = %lu, name = %s",
+				(unsigned long)inode->i_ino, name->name);
+			break;
+		}
+
 		bit_start = bit_pos
 				+ GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
 	}
-- 
1.7.9.5

             reply	other threads:[~2014-07-02  5:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-02  5:23 Chao Yu [this message]
2014-07-05  6:43 ` [f2fs-dev][PATCH 1/2] f2fs: check name_len of dir entry to prevent from deadloop Jaegeuk Kim
2014-07-07  1:24   ` [PATCH " Chao Yu
2014-07-08  5:56     ` Jaegeuk Kim
2014-07-09  2:57       ` Chao Yu
2014-07-09 13:47         ` [f2fs-dev][PATCH " Jaegeuk Kim
2014-07-10  4:18           ` [PATCH " Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001cf95b5$eac71ad0$c0555070$@samsung.com' \
    --to=chao2.yu@samsung.com \
    --cc=cm224.lee@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).