Re: [SOLVED + PATCH]: documented Oops running big-endian reiserfs on parisc architecture

From: Ulrich Weigand (weigand@immd1.informatik.uni-erlangen.de)
Date: Tue Sep 04 2001 - 17:55:24 EST


Jeff Mahoney wrote:

> Are the S/390 asm/unaligned.h versions broken, or is the ReiserFS code doing
> something not planned for? It's a 16-bit member, at a 16-bit alignment
> in the structure. The structure itself need not be aligned in any
> particular manner as it is read directly from disk, and is a packed structure.

One other point I overlooked before: using set_bit etc on a *16-bit*
member is fundamentally broken on S/390 anyway (and I far as I know all
other bigendian architectures as well). set_bit assumes to operate on
a long (or an array of longs); if you use set_bit to set bit number 0
in the bitfield starting at address X, it will actually modify the byte
located at address X+3 (or X+7 on 64-bit bigendian machines), because
this is where the bit with value 2^0 is located in a long.

If your bitfield is only 2 bytes long, this will obviously clobber
random memory after the field ... (Note that the _unaligned variants
do not fix this problem, they will just cause it to clobber memory
*before* the field instead, if I interpret them correctly.)

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Sep 07 2001 - 21:00:29 EST