Skip to content

Commit dbc374d

Browse files
mdmilleriigregkh
authored andcommitted
powerpc/vdso: Fix vdso cpu truncation
[ Upstream commit a9f675f ] The code in vdso_cpu_init that exposes the cpu and numa node to userspace via SPRG_VDSO incorrctly masks the cpu to 12 bits. This means that any kernel running on a box with more than 4096 threads (NR_CPUS advertises a limit of of 8192 cpus) would expose userspace to two cpu contexts running at the same time with the same cpu number. Note: I'm not aware of any distro shipping a kernel with support for more than 4096 threads today, nor of any system image that currently exceeds 4096 threads. Found via code browsing. Fixes: 18ad51d ("powerpc: Add VDSO version of getcpu") Signed-off-by: Milton Miller <miltonm@us.ibm.com> Signed-off-by: Anton Blanchard <anton@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200715233704.1352257-1-anton@ozlabs.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent daa69a2 commit dbc374d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/powerpc/kernel/vdso.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ int vdso_getcpu_init(void)
705705
node = cpu_to_node(cpu);
706706
WARN_ON_ONCE(node > 0xffff);
707707

708-
val = (cpu & 0xfff) | ((node & 0xffff) << 16);
708+
val = (cpu & 0xffff) | ((node & 0xffff) << 16);
709709
mtspr(SPRN_SPRG_VDSO_WRITE, val);
710710
get_paca()->sprg_vdso = val;
711711

0 commit comments

Comments
 (0)