All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fs: ext4: Prevent infinite loop in ext4fs_iterate_dir
Date: Mon, 23 Nov 2015 08:06:26 +0100	[thread overview]
Message-ID: <5652BAF2.3060900@denx.de> (raw)
In-Reply-To: <1447868573-18488-1-git-send-email-fitzsim@cisco.com>

Hi Thomas,

On 18.11.2015 18:42, Thomas Fitzsimmons wrote:
> If the ext3 journal gets out of sync with what is written on disk, for
> example because of an unexpected power cut, ext4fs_read_file can
> return an all-zero directory entry.  In that case, ext4fs_iterate_dir
> would infinite loop.
>
> This patch detects when a directory entry's direntlen member is 0 and
> returns a failure status, which breaks out of the infinite loop.  As a
> result, U-Boot will not find files that may subsequently be recovered
> when the journal is replayed.
>
> This is better behaviour than hanging in an infinite loop, but as a
> further improvement maybe U-Boot could interpret the ext3 journal and
> actually find the unsynced entries.
>
> Signed-off-by: Thomas Fitzsimmons <fitzsim@cisco.com>
> ---
>   fs/ext4/ext4_common.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
> index 727a2f7..e73223a 100644
> --- a/fs/ext4/ext4_common.c
> +++ b/fs/ext4/ext4_common.c
> @@ -1920,6 +1920,11 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
>   		if (status < 0)
>   			return 0;
>
> +		if (dirent.direntlen == 0) {
> +			printf("Failed to iterate over directory %s\n", name);
> +			return 0;
> +		}
> +
>   		if (dirent.namelen != 0) {
>   			char filename[dirent.namelen + 1];
>   			struct ext2fs_node *fdiro;
>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

  reply	other threads:[~2015-11-23  7:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 17:42 [U-Boot] [PATCH] fs: ext4: Prevent infinite loop in ext4fs_iterate_dir Thomas Fitzsimmons
2015-11-23  7:06 ` Stefan Roese [this message]
2015-11-23 22:44 ` [U-Boot] " Tom Rini

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=5652BAF2.3060900@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.