The patch titled Avoid truncating to 'long' in ALIGN() macro has been added to the -mm tree. Its filename is avoid-truncating-to-long-in-align-macro.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: Avoid truncating to 'long' in ALIGN() macro From: Roland Dreier <rdreier@xxxxxxxxx> Commit 4c8bd7ee ("Do not truncate to 'int' in ALIGN() macro.") was merged to fix the case of code like the following: unsigned long addr; unsigned int alignment; addr = ALIGN(addr, alignment); The original ALIGN macro calculated a mask as ~(alignment - 1), and when alignment is just an int, this creates an int mask. If alignment is also unsigned, then this mask will not be sign extended when promoted to a long, which leads to the code above chopping off the top half of addr when long is 64 bits. However, the changed ALIGN macro, which computes the mask as ~(alignment - 1UL) actually breaks code like the following when long is 32 bits: u64 addr; int alignment; addr = ALIGN(addr, alignment); The reason this breaks is pretty much the same as the original bug that the change was supposed to fix: ~(alignment - 1UL) creates a mask that is an unsigned long, which is not sign extended when promoted to u64 (if long is 32 bits). As suggested by Dave Miller and Al Viro, I fixed this by having the ALIGN macro make sure the alignment is promoted to the same type as the value being aligned before doing the negation. This second construct is actually used in the amso1100 driver, so that driver does not work on 32-bit architectures right now. Unfortunately almost everyone using it runs 64-bit kernels, so this regression was not noticed until now. Signed-off-by: Roland Dreier <rolandd@xxxxxxxxx> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- include/linux/kernel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff -puN include/linux/kernel.h~avoid-truncating-to-long-in-align-macro include/linux/kernel.h --- a/include/linux/kernel.h~avoid-truncating-to-long-in-align-macro +++ a/include/linux/kernel.h @@ -31,7 +31,7 @@ extern const char linux_banner[]; #define STACK_MAGIC 0xdeadbeef #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL)) +#define ALIGN(x,a) ((typeof(x)) (((x) + (a) - 1) & ~((typeof(x)) (a) - 1))) #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) _ Patches currently in -mm which might be from rdreier@xxxxxxxxx are avoid-truncating-to-long-in-align-macro.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html