linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] mess in jbd2_block_tag_csum_verify()
@ 2013-05-08 15:51 Al Viro
  2013-05-08 16:04 ` Andreas Dilger
  0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2013-05-08 15:51 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Theodore Ts'o, linux-fsdevel

You have
	calculated = jbd2_chksum(j, calculated, buf, j->j_blocksize);
	provided = be32_to_cpu(tag->t_checksum);

	return provided == cpu_to_be32(calculated);

in there, which makes no sense whatsoever.  First of all, you are
converting big-endian to native, then another native to big-endian
and compare results.  The bogosity aside, it's equivalent to simply
comparing tag->t_checksum with calculated - cpu_to_be32() is the
same mapping as be32_to_cpu() on all architectures and it's a one-to-one
mapping, at that.

Bogosity, of course, is that tag->t_checksum is apparently big-endian
and definitely a 16bit value.  How in hell is that check going to
yield true?  Note that you are asking for 16 bits out of crc32c result
to be zero, _NOT_ to be ignored.

Producer of that value shoves lower 16 bits of cpu_to_be32(crc) into the
on-disk structure.  Also a bloody bad idea, since the values on little-endian
and big-endian hosts will be different; move the disk from one box to
another and watch the mismatches...

What the hell is going on there?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-05-08 22:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-08 15:51 [RFC] mess in jbd2_block_tag_csum_verify() Al Viro
2013-05-08 16:04 ` Andreas Dilger
2013-05-08 16:11   ` Andreas Dilger
2013-05-08 16:45   ` Darrick J. Wong
2013-05-08 17:07     ` Al Viro
2013-05-08 21:55       ` Darrick J. Wong
2013-05-08 22:58         ` Al Viro

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).