lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CACT4Y+bv+iNx7dzt_Z2xVmLaBdaf5RNYHFREzrM5p+KmHH3+fA@mail.gmail.com>
Date:	Mon, 15 Feb 2016 14:50:58 +0100
From:	Dmitry Vyukov <dvyukov@...gle.com>
To:	Gleb Natapov <gleb@...nel.org>,
	Paolo Bonzini <pbonzini@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	"x86@...nel.org" <x86@...nel.org>, kvm@...r.kernel.org,
	LKML <linux-kernel@...r.kernel.org>
Cc:	Eric Northup <digitaleric@...gle.com>,
	Andrew Honig <ahonig@...gle.com>,
	Steve Rutherford <srutherford@...gle.com>,
	Robert Swiecki <swiecki@...gle.com>,
	Kostya Serebryany <kcc@...gle.com>,
	Alexander Potapenko <glider@...gle.com>,
	syzkaller <syzkaller@...glegroups.com>
Subject: kvm: GPF in kvm_pic_clear_all

Hello,

The following program triggers GPF in kvm_pic_clear_all if run in a
tight parallel loop:

general protection fault: 0000 [#71] SMP DEBUG_PAGEALLOC KASAN
Modules linked in:
CPU: 0 PID: 7107 Comm: a2.out Tainted: G      D         4.5.0-rc3+ #326
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: ffff88002144df00 ti: ffff8800219a0000 task.ti: ffff8800219a0000
RIP: 0010:[<ffffffff81467875>]  [<ffffffff81467875>] do_raw_spin_lock+0x25/0x2b0
RSP: 0018:ffff8800219a7840  EFLAGS: 00010247
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: ffff8800219a7868 R08: 0000000000000001 R09: 0000000000000000
R10: ffff88002144df00 R11: 0000000000000018 R12: 0000000000000002
R13: 0000000000000130 R14: 0000000000000000 R15: ffff880022f874e0
FS:  00007f6181c19700(0000) GS:ffff88003ec00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 000000c82071a140 CR3: 0000000027104000 CR4: 00000000000026f0
Stack:
 0000000000000000 0000000000000002 0000000000000130 0000000000000000
 ffff880022f874e0 ffff8800219a7888 ffffffff8666031b ffffffff810cc11c
 00000000000000b0 ffff8800219a78b8 ffffffff810cc11c ffff88004ea70000
Call Trace:
 [<     inline     >] __raw_spin_lock include/linux/spinlock_api_smp.h:145
 [<ffffffff8666031b>] _raw_spin_lock+0x3b/0x50 kernel/locking/spinlock.c:151
 [<     inline     >] spin_lock include/linux/spinlock.h:302
 [<     inline     >] pic_lock arch/x86/kvm/i8259.c:45
 [<ffffffff810cc11c>] kvm_pic_clear_all+0x2c/0x60 arch/x86/kvm/i8259.c:213
 [<ffffffff810e31d9>] kvm_free_irq_source_id+0xa9/0xe0
arch/x86/kvm/irq_comm.c:186
 [<ffffffff810de6cf>] kvm_create_pit+0x51f/0x6d0 arch/x86/kvm/i8254.c:711
 [<ffffffff81061122>] kvm_arch_vm_ioctl+0xaa2/0x1dc0 arch/x86/kvm/x86.c:3856
 [<ffffffff8102013c>] kvm_vm_ioctl+0x17c/0xfe0
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2891
 [<     inline     >] vfs_ioctl fs/ioctl.c:43
 [<ffffffff817fc26c>] do_vfs_ioctl+0x18c/0xfb0 fs/ioctl.c:674
 [<     inline     >] SYSC_ioctl fs/ioctl.c:689
 [<ffffffff817fd11f>] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:680
 [<ffffffff866613f6>] entry_SYSCALL_64_fastpath+0x16/0x7a
arch/x86/entry/entry_64.S:185
Code: 84 00 00 00 00 00 55 48 b8 00 00 00 00 00 fc ff df 48 89 e5 41
57 41 56 41 55 41 54 53 48 89 fb 48 83 c7 04 48 89 fa 48 c1 ea 03 <0f>
b6 14 02 48 89 f8 83 e0 07 83 c0 03 38 d0 7c 08 84 d2 0f 85
RIP  [<     inline     >] debug_spin_lock_before
kernel/locking/spinlock_debug.c:83
RIP  [<ffffffff81467875>] do_raw_spin_lock+0x25/0x2b0
kernel/locking/spinlock_debug.c:135
 RSP <ffff8800219a7840>
---[ end trace a9bcc650712efe82 ]---

BUG: sleeping function called from invalid context at include/linux/sched.h:2805
in_atomic(): 1, irqs_disabled(): 0, pid: 7107, name: a2.out
lockdep is turned off.
CPU: 0 PID: 7107 Comm: a2.out Tainted: G      D         4.5.0-rc3+ #326
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 ffffffff87b05080 ffff8800219a7470 ffffffff82be461f ffffffff00000016
 fffffbfff0f60a10 ffff88002144df00 0000000000001bc3 0000000000000000
 0000000000000000 dffffc0000000000 ffff8800219a7498 ffffffff813cd42b
Call Trace:
 [<     inline     >] __dump_stack lib/dump_stack.c:15
 [<ffffffff82be461f>] dump_stack+0x12e/0x18f lib/dump_stack.c:51
 [<ffffffff813cd42b>] ___might_sleep+0x27b/0x3a0 kernel/sched/core.c:7703
 [<ffffffff813cd5e0>] __might_sleep+0x90/0x1a0 kernel/sched/core.c:7665
 [<     inline     >] threadgroup_change_begin include/linux/sched.h:2805
 [<ffffffff81384b11>] exit_signals+0x81/0x430 kernel/signal.c:2392
 [<ffffffff8135de3c>] do_exit+0x23c/0x2cb0 kernel/exit.c:701
 [<ffffffff811aa28f>] oops_end+0x9f/0xd0 arch/x86/kernel/dumpstack.c:250
 [<ffffffff811aa686>] die+0x46/0x60 arch/x86/kernel/dumpstack.c:316
 [<ffffffff811a4725>] do_general_protection+0x235/0x3e0
arch/x86/kernel/traps.c:463
 [<ffffffff866636a8>] general_protection+0x28/0x30 arch/x86/entry/entry_64.S:982
 [<     inline     >] __raw_spin_lock include/linux/spinlock_api_smp.h:145
 [<ffffffff8666031b>] _raw_spin_lock+0x3b/0x50 kernel/locking/spinlock.c:151
 [<     inline     >] spin_lock include/linux/spinlock.h:302
 [<     inline     >] pic_lock arch/x86/kvm/i8259.c:45
 [<ffffffff810cc11c>] kvm_pic_clear_all+0x2c/0x60 arch/x86/kvm/i8259.c:213
 [<ffffffff810e31d9>] kvm_free_irq_source_id+0xa9/0xe0
arch/x86/kvm/irq_comm.c:186
 [<ffffffff810de6cf>] kvm_create_pit+0x51f/0x6d0 arch/x86/kvm/i8254.c:711
 [<ffffffff81061122>] kvm_arch_vm_ioctl+0xaa2/0x1dc0 arch/x86/kvm/x86.c:3856
 [<ffffffff8102013c>] kvm_vm_ioctl+0x17c/0xfe0
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2891
 [<     inline     >] vfs_ioctl fs/ioctl.c:43
 [<ffffffff817fc26c>] do_vfs_ioctl+0x18c/0xfb0 fs/ioctl.c:674
 [<     inline     >] SYSC_ioctl fs/ioctl.c:689
 [<ffffffff817fd11f>] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:680
 [<ffffffff866613f6>] entry_SYSCALL_64_fastpath+0x16/0x7a
arch/x86/entry/entry_64.S:185
note: a2.out[7107] exited with preempt_count 1



// autogenerated by syzkaller (http://github.com/google/syzkaller)
#include <pthread.h>
#include <stdint.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>

long r[23];

void* thr(void* arg)
{
  switch ((long)arg) {
  case 0:
    r[0] = syscall(SYS_mmap, 0x20000000ul, 0xe000ul, 0x3ul, 0x32ul,
                   0xfffffffffffffffful, 0x0ul);
    break;
  case 1:
    memcpy((void*)0x20001000, "\x2f\x64\x65\x76\x2f\x6b\x76\x6d\x00",
           9);
    r[2] = syscall(SYS_open, "/dev/kvm", 0x2000ul, 0, 0, 0);
    break;
  case 2:
    r[3] = syscall(SYS_ioctl, r[2], 0xae01ul, 0x0ul, 0, 0, 0);
    break;
  case 3:
    r[4] = syscall(SYS_ioctl, r[3], 0xae60ul, 0, 0, 0, 0);
    break;
  case 4:
    r[5] = syscall(SYS_prctl, 0x23ul, 0x4ul, 0x20000000ul, 0, 0, 0);
    break;
  case 5:
    *(uint32_t*)0x20009000 = (uint32_t)0x4;
    *(uint32_t*)0x20009004 = (uint32_t)0x0;
    *(uint32_t*)0x20009008 = (uint32_t)0x0;
    *(uint32_t*)0x2000900c = (uint32_t)0x0;
    *(uint32_t*)0x20009010 = (uint32_t)0x0;
    *(uint32_t*)0x20009014 = (uint32_t)0x0;
    *(uint32_t*)0x20009018 = (uint32_t)0x0;
    *(uint32_t*)0x2000901c = (uint32_t)0x0;
    *(uint32_t*)0x20009020 = (uint32_t)0x0;
    *(uint32_t*)0x20009024 = (uint32_t)0x0;
    *(uint32_t*)0x20009028 = (uint32_t)0x0;
    *(uint32_t*)0x2000902c = (uint32_t)0x0;
    *(uint32_t*)0x20009030 = (uint32_t)0x0;
    *(uint32_t*)0x20009034 = (uint32_t)0x0;
    *(uint32_t*)0x20009038 = (uint32_t)0x0;
    *(uint32_t*)0x2000903c = (uint32_t)0x0;
    r[22] =
        syscall(SYS_ioctl, r[3], 0x4040ae77ul, 0x20009000ul, 0, 0, 0);
    break;
  }
  return 0;
}

int main()
{
  long i;
  pthread_t th[6];

  srand(getpid());
  memset(r, -1, sizeof(r));
  for (i = 0; i < 6; i++) {
    pthread_create(&th[i], 0, thr, (void*)i);
    usleep(1000+rand()%1000);
  }
  for (i = 0; i < 6; i++) {
    pthread_create(&th[i], 0, thr, (void*)i);
    if (rand()%2)
      usleep(rand()%1000);
  }
  usleep(20000);
  return 0;
}

On commit 388f7b1d6e8ca06762e2454d28d6c3c55ad0fe95 (4.5-rc3)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ