public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Anatoly Pugachev <matorola@gmail.com>,
	linux-ext4@vger.kernel.org,
	debian-sparc <debian-sparc@lists.debian.org>
Subject: Re: [sparc64] sigbus in e2fsck
Date: Tue, 30 Aug 2016 10:58:10 -0400	[thread overview]
Message-ID: <20160830145810.rgms25xlnatnyxir@thunk.org> (raw)
In-Reply-To: <6a774a5e-b2e5-6276-c272-2b737bd098f0@physik.fu-berlin.de>

On Tue, Aug 30, 2016 at 02:56:45PM +0200, John Paul Adrian Glaubitz wrote:
> On 08/30/2016 02:42 PM, Anatoly Pugachev wrote:
> > ../../e2fsck/recovery.c:866
> > 866                             blocknr = ext2fs_be64_to_cpu(* ((__u64
> > *) (bh->b_data+offset)));
> 
> The reason is that this expression is casting "char * b_data" [1] into u64 [2]
> which provokes unaligned access. Since such expression are often inevitable,
> it's probably best to modify the conversion macros in bitops.h [3] to be
> safe against unaligned accesses.

I don't think that's it.  b_data is a 4k buffer should be 8 byte
aligned.  For a file system with 64-bit blocks (which you presumably
have since we're on the be64 path as shown in your debugger output)
the offset is initially set to 16, and is incremented in chunks of 8
bytes.  So there shouldn't be any unaligned access.

Since you are able to provke this in a debugger, can you have gdb
print out the value of bh->b_data and offset, so we can be sure what's
going on?

I do see a potential problem which is that we're defining
journal_revoke_header_t structure in a non-portable way:

typedef struct journal_header_s
{
	__u32		h_magic;
	__u32		h_blocktype;
	__u32		h_sequence;
} journal_header_t;

typedef struct journal_revoke_header_s
{
	journal_header_t r_header;
	int		 r_count;	/* Count of bytes used in the block */
} journal_revoke_header_t;

The "int" above should be a __u32.  What is the size of int on
sparc64?  Is it by any chance 8 bytes?  If that's the problem then I'm
kind of surprised we haven't run into massive problems earlier, as
this looks like a long standing bug.

							- Ted

  reply	other threads:[~2016-08-30 14:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 12:42 [sparc64] sigbus in e2fsck Anatoly Pugachev
2016-08-30 12:56 ` John Paul Adrian Glaubitz
2016-08-30 14:58   ` Theodore Ts'o [this message]
2016-08-30 15:03     ` John Paul Adrian Glaubitz
2016-08-30 15:12     ` Anatoly Pugachev
2016-08-30 19:16       ` Theodore Ts'o
2016-08-30 20:17         ` Anatoly Pugachev
2016-08-30 20:25           ` Darrick J. Wong
2016-09-01  1:26             ` Theodore Ts'o
2016-08-30 16:45     ` Jose E. Marchesi

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=20160830145810.rgms25xlnatnyxir@thunk.org \
    --to=tytso@mit.edu \
    --cc=debian-sparc@lists.debian.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-ext4@vger.kernel.org \
    --cc=matorola@gmail.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