public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 3/5] xfs_logprint: fix some unaligned accesses
Date: Fri, 9 Oct 2015 16:08:27 -0400	[thread overview]
Message-ID: <20151009200827.GH27982@bfoster.bfoster> (raw)
In-Reply-To: <56181AF0.7090904@sandeen.net>

On Fri, Oct 09, 2015 at 02:52:16PM -0500, Eric Sandeen wrote:
> This routine had a fair bit of gyration to avoid unaligned
> accesses, but didn't fix them all.
> Fix some more spotted at runtime by libubsan.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> V2: Change variable scope, remove extraneous hunk
> 

Thanks!

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  logprint/log_misc.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/logprint/log_misc.c b/logprint/log_misc.c
> index d76145c..4cdcbec 100644
> --- a/logprint/log_misc.c
> +++ b/logprint/log_misc.c
> @@ -243,9 +243,6 @@ int
>  xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
>  {
>      xfs_buf_log_format_t *f;
> -    xfs_agi_t		 *agi;
> -    xfs_agf_t		 *agf;
> -    xfs_disk_dquot_t	 *dq;
>      xlog_op_header_t	 *head = NULL;
>      int			 num, skip;
>      int			 super_block = 0;
> @@ -325,7 +322,11 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
>  		}
>  		super_block = 0;
>  	} else if (be32_to_cpu(*(__be32 *)(*ptr)) == XFS_AGI_MAGIC) {
> -		agi = (xfs_agi_t *)(*ptr);
> +  	  	struct xfs_agi	*agi, agi_s;
> +
> +		/* memmove because *ptr may not be 8-byte aligned */
> +		agi = &agi_s;
> +		memmove(agi, *ptr, sizeof(struct xfs_agi));
>  		printf(_("AGI Buffer: XAGI  "));
>  		/*
>  		 * v4 filesystems only contain the fields before the uuid.
> @@ -375,7 +376,11 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
>  			}
>  		}
>  	} else if (be32_to_cpu(*(__be32 *)(*ptr)) == XFS_AGF_MAGIC) {
> -		agf = (xfs_agf_t *)(*ptr);
> +    		struct xfs_agf	*agf, agf_s;
> +
> +		/* memmove because *ptr may not be 8-byte aligned */
> +		agf = &agf_s;
> +		memmove(agf, *ptr, sizeof(struct xfs_agf));
>  		printf(_("AGF Buffer: XAGF  "));
>  		/*
>  		 * v4 filesystems only contain the fields before the uuid.
> @@ -408,7 +413,11 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
>  				be32_to_cpu(agf->agf_longest));
>  		}
>  	} else if (be32_to_cpu(*(__be32 *)(*ptr)) == XFS_DQUOT_MAGIC) {
> -		dq = (xfs_disk_dquot_t *)(*ptr);
> +		struct xfs_disk_dquot *dq, dq_s;
> +
> +		/* memmove because *ptr may not be 8-byte aligned */
> +		dq = &dq_s;
> +		memmove(dq, *ptr, sizeof(struct xfs_disk_dquot));
>  		printf(_("DQUOT Buffer: DQ  "));
>  		if (be32_to_cpu(head->oh_len) <
>  				sizeof(xfs_disk_dquot_t)) {
> -- 
> 2.6.1
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-10-09 20:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09 19:48 [PATCH 0/5 V2] fix (mostly) minor nits spotted by gcc sanitization Eric Sandeen
2015-10-09 19:49 ` [PATCH 1/5] libxfs: avoid negative (and full-width) shifts in radix-tree.c Eric Sandeen
2015-10-09 19:51 ` [PATCH 2/5] xfs_repair: fix unaligned accesses Eric Sandeen
2015-10-09 20:08   ` Brian Foster
2015-10-13  0:35     ` Dave Chinner
2015-10-09 19:52 ` [PATCH 3/5] xfs_logprint: fix some " Eric Sandeen
2015-10-09 20:08   ` Brian Foster [this message]
2015-10-09 19:53 ` [PATCH 4/5] xfs_metadump: Fix " Eric Sandeen
2015-10-09 20:08   ` Brian Foster
2015-10-09 19:53 ` [PATCH 5/5] xfs_repair: fix left-shift overflows Eric Sandeen

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=20151009200827.GH27982@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.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