Commit 672cdd56 authored by Bharath Vedartham's avatar Bharath Vedartham Committed by Linus Torvalds

reiserfs: add comment to explain endianness issue in xattr_hash

csum_partial() gives different results for little-endian and big-endian
hosts.  This causes images created on little-endian hosts and mounted on
big endian hosts to see csum mismatches.  This causes an endianness bug.
Sparse gives a warning as csum_partial returns a restricted integer type
__wsum_t and xattr_hash expects __u32.  This warning acts as a reminder
for this bug and should not be suppressed.

This comment aims to convey these endianness issues.

[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/20190423161831.GA15387@bharath12345-Inspiron-5559Signed-off-by: default avatarBharath Vedartham <linux.bhar@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jann Horn <jannh@google.com>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1dcaa138
......@@ -450,6 +450,15 @@ static struct page *reiserfs_get_page(struct inode *dir, size_t n)
static inline __u32 xattr_hash(const char *msg, int len)
{
/*
* csum_partial() gives different results for little-endian and
* big endian hosts. Images created on little-endian hosts and
* mounted on big-endian hosts(and vice versa) will see csum mismatches
* when trying to fetch xattrs. Treating the hash as __wsum_t would
* lower the frequency of mismatch. This is an endianness bug in
* reiserfs. The return statement would result in a sparse warning. Do
* not fix the sparse warning so as to not hide a reminder of the bug.
*/
return csum_partial(msg, len, 0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment