android_kernel_oneplus_msm8998/drivers/virtio
Jiang Biao a1d7ff2496 virtio_balloon: fix another race between migration and ballooning
commit 89da619bc18d79bca5304724c11d4ba3b67ce2c6 upstream.

Kernel panic when with high memory pressure, calltrace looks like,

PID: 21439 TASK: ffff881be3afedd0 CPU: 16 COMMAND: "java"
  [ffff881ec7ed7630] machine_kexec at ffffffff81059beb
  [ffff881ec7ed7690] __crash_kexec at ffffffff81105942
  [ffff881ec7ed7760] crash_kexec at ffffffff81105a30
  [ffff881ec7ed7778] oops_end at ffffffff816902c8
  [ffff881ec7ed77a0] no_context at ffffffff8167ff46
  [ffff881ec7ed77f0] __bad_area_nosemaphore at ffffffff8167ffdc
  [ffff881ec7ed7838] __node_set at ffffffff81680300
  [ffff881ec7ed7860] __do_page_fault at ffffffff8169320f
  [ffff881ec7ed78c0] do_page_fault at ffffffff816932b5
  [ffff881ec7ed78f0] page_fault at ffffffff8168f4c8
    [exception RIP: _raw_spin_lock_irqsave+47]
    RIP: ffffffff8168edef RSP: ffff881ec7ed79a8 RFLAGS: 00010046
    RAX: 0000000000000246 RBX: ffffea0019740d00 RCX: ffff881ec7ed7fd8
    RDX: 0000000000020000 RSI: 0000000000000016 RDI: 0000000000000008
    RBP: ffff881ec7ed79a8 R8: 0000000000000246 R9: 000000000001a098
    R10: ffff88107ffda000 R11: 0000000000000000 R12: 0000000000000000
    R13: 0000000000000008 R14: ffff881ec7ed7a80 R15: ffff881be3afedd0
    ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018

It happens in the pagefault and results in double pagefault
during compacting pages when memory allocation fails.

Analysed the vmcore, the page leads to second pagefault is corrupted
with _mapcount=-256, but private=0.

It's caused by the race between migration and ballooning, and lock
missing in virtballoon_migratepage() of virtio_balloon driver.
This patch fix the bug.

Fixes: e22504296d ("virtio_balloon: introduce migration primitives to balloon pages")
Cc: stable@vger.kernel.org
Signed-off-by: Jiang Biao <jiang.biao2@zte.com.cn>
Signed-off-by: Huang Chong <huang.chong@zte.com.cn>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-06 16:24:42 +02:00
..
config.c
Kconfig Add virtio-input driver. 2015-03-29 12:13:52 +10:30
Makefile Add virtio-input driver. 2015-03-29 12:13:52 +10:30
virtio.c virtio: release virtio index when fail to device_register 2017-12-16 10:33:48 +01:00
virtio_balloon.c virtio_balloon: fix another race between migration and ballooning 2018-08-06 16:24:42 +02:00
virtio_input.c virtio-input: reset device and detach unused during remove 2015-08-06 10:40:35 +03:00
virtio_mmio.c virtio_mmio: add ACPI probing 2015-09-08 13:30:28 +03:00
virtio_pci_common.c virtio_pci: fix use after free on release 2016-03-03 15:07:18 -08:00
virtio_pci_common.h virtio-pci: alloc only resources actually used. 2015-06-24 08:15:09 +02:00
virtio_pci_legacy.c virtio-pci: alloc only resources actually used. 2015-06-24 08:15:09 +02:00
virtio_pci_modern.c virtio: virtio 1.0 cs04 spec compliance for reset 2016-04-20 15:42:10 +09:00
virtio_ring.c virtio_ring: Make interrupt suppression spec compliant 2016-11-10 16:36:34 +01:00