linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: ext4 development <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 2/6] e2fsprogs: fix endian handling of ext3_extent_header
Date: Thu, 23 Oct 2014 15:03:05 -0700	[thread overview]
Message-ID: <20141023220305.GA10047@birch.djwong.org> (raw)
In-Reply-To: <544972C4.2040204@redhat.com>

On Thu, Oct 23, 2014 at 04:27:32PM -0500, Eric Sandeen wrote:
> 
> 
> This turned up when trying to resize a filesystem containing
> a file with many extents on PPC64.
> 
> Fix all locations where ext3_extent_header members aren't
> handled in an endian-safe manner.

Looks ok to me (and fixed resize2fs on ${BE}64), so
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>  lib/ext2fs/ext3_extents.h |   15 ++++++++++-----
>  lib/ext2fs/inline_data.c  |    2 +-
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/ext2fs/ext3_extents.h b/lib/ext2fs/ext3_extents.h
> index 4163436..a18d705 100644
> --- a/lib/ext2fs/ext3_extents.h
> +++ b/lib/ext2fs/ext3_extents.h
> @@ -106,15 +106,20 @@ struct ext3_ext_path {
>  	((struct ext3_extent_idx *) (((char *) (__hdr__)) +	\
>  				     sizeof(struct ext3_extent_header)))
>  #define EXT_HAS_FREE_INDEX(__path__) \
> -	((__path__)->p_hdr->eh_entries < (__path__)->p_hdr->eh_max)
> +	(ext2fs_le16_to_cpu((__path__)->p_hdr->eh_entries) < \
> +	 ext2fs_le16_to_cpu((__path__)->p_hdr->eh_max))
>  #define EXT_LAST_EXTENT(__hdr__) \
> -	(EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->eh_entries - 1)
> +	(EXT_FIRST_EXTENT((__hdr__)) + \
> +	ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
>  #define EXT_LAST_INDEX(__hdr__) \
> -	(EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->eh_entries - 1)
> +	(EXT_FIRST_INDEX((__hdr__)) + \
> +	ext2fs_le16_to_cpu((__hdr__)->eh_entries) - 1)
>  #define EXT_MAX_EXTENT(__hdr__) \
> -	(EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->eh_max - 1)
> +	(EXT_FIRST_EXTENT((__hdr__)) + \
> +	ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
>  #define EXT_MAX_INDEX(__hdr__) \
> -	(EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->eh_max - 1)
> +	(EXT_FIRST_INDEX((__hdr__)) + \
> +	ext2fs_le16_to_cpu((__hdr__)->eh_max) - 1)
>  
>  #endif /* _LINUX_EXT3_EXTENTS */
>  
> diff --git a/lib/ext2fs/inline_data.c b/lib/ext2fs/inline_data.c
> index 7eb8b94..8167b76 100644
> --- a/lib/ext2fs/inline_data.c
> +++ b/lib/ext2fs/inline_data.c
> @@ -420,7 +420,7 @@ ext2fs_inline_data_file_expand(ext2_filsys fs, ext2_ino_t ino,
>  		eh = (struct ext3_extent_header *) &inode->i_block[0];
>  		eh->eh_depth = 0;
>  		eh->eh_entries = 0;
> -		eh->eh_magic = EXT3_EXT_MAGIC;
> +		eh->eh_magic = ext2fs_cpu_to_le16(EXT3_EXT_MAGIC);
>  		i = (sizeof(inode->i_block) - sizeof(*eh)) /
>  			sizeof(struct ext3_extent);
>  		eh->eh_max = ext2fs_cpu_to_le16(i);
> -- 1.7.1
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-10-23 22:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 21:26 [PATCH 0/6] RFC: (partially) endian-annotate e2fsprogs Eric Sandeen
2014-10-23 21:27 ` [PATCH 1/6] e2fsprogs: define bitwise types and annotate conversion routines Eric Sandeen
2014-10-23 21:27 ` [PATCH 2/6] e2fsprogs: fix endian handling of ext3_extent_header Eric Sandeen
2014-10-23 22:03   ` Darrick J. Wong [this message]
2014-10-23 21:28 ` [PATCH 3/6] e2fsprogs: Endian-annotate most on-disk structures Eric Sandeen
2014-10-23 21:28 ` [PATCH 4/6] debugfs: don't swap htree nodes in-place Eric Sandeen
2014-10-23 21:29 ` [PATCH 5/6] libext2: minor sparse endian checker fixup Eric Sandeen
2014-10-23 21:29 ` [PATCH 6/6] quotaio: annotate & fix up for sparse endian checker Eric Sandeen
2014-10-23 23:56 ` [PATCH 0/6] RFC: (partially) endian-annotate e2fsprogs Andreas Dilger
2014-11-04 16:34 ` Theodore Ts'o
2014-11-04 23:27   ` Darrick J. Wong

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=20141023220305.GA10047@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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).