x86: fix global_flush_tlb() bug
Ingo Molnar authored
patch 9a24d04a upstream

While we were reviewing pageattr_32/64.c for unification,
Thomas Gleixner noticed the following serious SMP bug in
global_flush_tlb():

	down_read(&init_mm.mmap_sem);
	list_replace_init(&deferred_pages, &l);
	up_read(&init_mm.mmap_sem);

this is SMP-unsafe because list_replace_init() done on two CPUs in
parallel can corrupt the list.

This bug has been introduced about a year ago in the 64-bit tree:

       commit ea7322de


       Author: Andi Kleen <ak@suse.de>
       Date:   Thu Dec 7 02:14:05 2006 +0100

       [PATCH] x86-64: Speed and clean up cache flushing in change_page_attr

                down_read(&init_mm.mmap_sem);
        -       dpage = xchg(&deferred_pages, NULL);
        +       list_replace_init(&deferred_pages, &l);
                up_read(&init_mm.mmap_sem);

the xchg() based version was SMP-safe, but list_replace_init() is not.
So this "cleanup" introduced a nasty bug.

why this bug never become prominent is a mystery - it can probably be
explained with the (still) relative obscurity of the x86_64 architecture.

the safe fix for now is to write-lock init_mm.mmap_sem.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
4b69ffe3
Name Last commit Last update
..
alpha alpha: -Werror fixes for sys_titan.c
arm [ARM] 4598/2: OSIRIS: Ensure we do not get nRSTOUT during suspend
avr32 [AVR32] Wire up i2c-gpio on the ATNGW100 board
blackfin Blackfin arch: fix PORT_J BUG for BF537/6 EMAC driver reported by Kalle Pokki <kalle.pokki@iki.fi>
cris ide: fix hidden dependencies on CONFIG_IDE_GENERIC
frv FRV: connect up fallocate
h8300 H8/300: Fix misnamed "CONFIG_BLKDEV_RESERVE_ADDRESS" Kconfig variable
i386 xen: fix incorrect vcpu_register_vcpu_info hypercall argument
ia64 Fix spurious syscall tracing after PTRACE_DETACH + PTRACE_ATTACH
m32r m32r: Rename STI/CLI macros
m68k m68k(nommu): add missing syscalls
m68knommu m68k(nommu): add missing syscalls
mips MIPS: MT: Fix bug in multithreaded kernels.
parisc [PARISC] Add NOTES section
powerpc POWERPC: Make sure to of_node_get() the result of pci_device_to_OF_node()
ppc [PPC] Fix cpm_dpram_addr returning phys mem instead of virt mem
s390 [S390] kprobes: fix instruction length calculation
sh sh: missing symbol fix for sh4-202
sh64 sh64: arch/sh64/kernel/setup.c: duplicate include removal.
sparc [SPARC]: Fix EBUS use of uninitialized variable.
sparc64 Fix sparc64 MAP_FIXED handling of framebuffer mmaps
um UML - kill subprocesses on exit
v850 PTRACE_POKEDATA consolidation
x86_64 x86: fix global_flush_tlb() bug
xtensa [patch 2/2] xtensa console.c: remove duplicate #include