Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Fix personality handling in ppc64_personality()

Directly comparing current->personality against PER_LINUX32 doesn't work
in cases when any of the personality flags stored in the top three bytes
are used.

Directly forcefully setting personality to PER_LINUX32 or PER_LINUX
discards any flags stored in the top three bytes

Use personality() macro to compare only PER_MASK bytes and make sure that
we are setting only the bits that should be set, instead of overwriting
the whole value.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Jiri Kosina and committed by
Benjamin Herrenschmidt
7256a5d2 4c374af5

+4 -4
+4 -4
arch/powerpc/kernel/syscalls.c
··· 107 107 long ret; 108 108 109 109 if (personality(current->personality) == PER_LINUX32 110 - && personality == PER_LINUX) 111 - personality = PER_LINUX32; 110 + && personality(personality) == PER_LINUX) 111 + personality = (personality & ~PER_MASK) | PER_LINUX32; 112 112 ret = sys_personality(personality); 113 - if (ret == PER_LINUX32) 114 - ret = PER_LINUX; 113 + if (personality(ret) == PER_LINUX32) 114 + ret = (ret & ~PER_MASK) | PER_LINUX; 115 115 return ret; 116 116 } 117 117 #endif