From: David S. Miller Date: Mon, 23 Oct 2006 04:53:30 +0000 (-0700) Subject: [SPARC64]: 8-byte align return value from compat_alloc_user_space() X-Git-Tag: v2.6.19-rc3~7^2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a94b1d1fd7ca3129e1d38d38167779fa6ee69780;p=linux-2.6 [SPARC64]: 8-byte align return value from compat_alloc_user_space() Otherwise we get a ton of unaligned exceptions, for cases such as compat_sys_msgrcv() which go: p = compat_alloc_user_space(second + sizeof(struct msgbuf)); and here 'second' can for example be an arbitrary odd value. Based upon a bug report from Jurij Smakov. Signed-off-by: David S. Miller --- diff --git a/include/asm-sparc64/compat.h b/include/asm-sparc64/compat.h index c73935dc7b..36511ca514 100644 --- a/include/asm-sparc64/compat.h +++ b/include/asm-sparc64/compat.h @@ -164,7 +164,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr) return (u32)(unsigned long)uptr; } -static __inline__ void __user *compat_alloc_user_space(long len) +static inline void __user *compat_alloc_user_space(long len) { struct pt_regs *regs = current_thread_info()->kregs; unsigned long usp = regs->u_regs[UREG_I6]; @@ -174,7 +174,10 @@ static __inline__ void __user *compat_alloc_user_space(long len) else usp &= 0xffffffffUL; - return (void __user *) (usp - len); + usp -= len; + usp &= ~0x7UL; + + return (void __user *) usp; } struct compat_ipc64_perm {