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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACT4Y+a01sL5jhLi_tOCBtdq4LuXDB_YYPuNkMDSDoQBPXKn4A@mail.gmail.com>
Date:	Tue, 21 Jun 2016 15:18:31 +0200
From:	Dmitry Vyukov <dvyukov@...gle.com>
To:	Paolo Bonzini <pbonzini@...hat.com>, mtosatti@...hat.com,
	yoshikawa_takuya_b1@....ntt.co.jp, guangrong.xiao@...ux.intel.com,
	Steve Rutherford <srutherford@...gle.com>, rkrcmar@...hat.com,
	KVM list <kvm@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>
Cc:	syzkaller <syzkaller@...glegroups.com>,
	Alexander Potapenko <glider@...gle.com>,
	Sasha Levin <sasha.levin@...cle.com>,
	Kostya Serebryany <kcc@...gle.com>
Subject: kvm: GPF in kvm_lapic_set_tpr

Hello,

The following program triggers GPF in kvm_lapic_set_tpr:

kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN
Modules linked in:
CPU: 0 PID: 7683 Comm: syz-executor Not tainted 4.7.0-rc4+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: ffff8800300b46c0 ti: ffff880030e78000 task.ti: ffff880030e78000
RIP: 0010:[<ffffffff811269be>]
  [<ffffffff811269be>] kvm_lapic_set_tpr+0x5e/0xe0 arch/x86/kvm/lapic.c:1648
RSP: 0018:ffff880030e7fa40  EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: 0000000000000016 RSI: 0000000000000000 RDI: 00000000000000b0
RBP: ffff880030e7fa58 R08: ffffed0006142069 R09: ffff880030a102c0
R10: ffff880030a10347 R11: ffffed0006142069 R12: 0000000000000000
R13: ffff880030a10040 R14: 0000000000000000 R15: dffffc0000000000
FS:  00007fc65886c700(0000) GS:ffff88003ec00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fc65884b000 CR3: 00000000315cd000 CR4: 00000000000026f0
Stack:
 ffff880030a10040 0000000000000000 ffff880030a10040 ffff880030e7fa78
 ffffffff8109496c 0000000000000001 0000000000000000 ffff880030e7faa0
 ffffffff81094a22 ffff880030a10040 1ffff100061cff57 ffff880030e7fb58
Call Trace:
 [<ffffffff8109496c>] kvm_set_cr8.part.135+0x2c/0xb0 arch/x86/kvm/x86.c:809
 [<ffffffff81094a22>] kvm_set_cr8+0x32/0x50 arch/x86/kvm/x86.c:806
 [<ffffffff81178dd4>] vmx_vcpu_reset+0x114/0xb60 arch/x86/kvm/vmx.c:4996
 [<ffffffff810b91b0>] kvm_vcpu_reset+0x410/0x580 arch/x86/kvm/x86.c:7470
 [<ffffffff810b9355>] kvm_arch_vcpu_setup+0x35/0x60 arch/x86/kvm/x86.c:7393
 [<     inline     >] kvm_vm_ioctl_create_vcpu
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2355
 [<ffffffff8106b9f2>] kvm_vm_ioctl+0x582/0x10d0
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2839
 [<     inline     >] vfs_ioctl fs/ioctl.c:43
 [<ffffffff818510bc>] do_vfs_ioctl+0x18c/0xff0 fs/ioctl.c:674
 [<     inline     >] SYSC_ioctl fs/ioctl.c:689
 [<ffffffff81851faf>] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:680
 [<ffffffff86a96fc0>] entry_SYSCALL_64_fastpath+0x23/0xc1
arch/x86/entry/entry_64.S:207
Code: 92 00 00 00 4d 8b a4 24 60 03 00 00 48 b8 00 00 00 00 00 fc ff
df c1 e3 04 0f b6 db 49 8d bc 24 b0 00 00 00 48 89 fa 48 c1 ea 03 <80>
3c 02 00 75 5e 4d 8b ac 24 b0 00 00 00 48 b8 00 00 00 00 00
RIP  [<ffffffff811269be>] kvm_lapic_set_tpr+0x5e/0xe0 arch/x86/kvm/lapic.c:1648
 RSP <ffff880030e7fa40>
---[ end trace a57f94f7314716fc ]---


Run in a parallel loop:

// 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[9];

void* thr(void* arg)
{
  switch ((long)arg) {
  case 0:
    r[0] = syscall(SYS_mmap, 0x20000000ul, 0x16000ul, 0x3ul, 0x32ul,
                   0xfffffffffffffffful, 0x0ul);
    break;
  case 1:
    r[2] = syscall(SYS_open, "/dev/kvm", 0x540ul, 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], 0xae41ul, 0x1ul, 0, 0, 0);
    break;
  case 4:
    r[5] = syscall(SYS_ioctl, r[4], 0xae80ul, 0, 0, 0, 0);
    break;
  case 5:
    r[6] = syscall(SYS_ioctl, r[4], 0xae80ul, 0, 0, 0, 0);
    break;
  case 6:
    r[7] = syscall(SYS_ioctl, r[4], 0xae80ul, 0, 0, 0, 0);
    break;
  case 7:
    r[8] =
        syscall(SYS_ioctl, r[4], 0x8040ae9ful, 0x20014fe4ul, 0, 0, 0);
    break;
  }
  return 0;
}

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

  syscall(SYS_mmap, 0x20000000ul, 0x16000ul, 0x3ul, 0x32ul,
                   0xfffffffffffffffful, 0x0ul);

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


On commit 67016f6cdfd079e632bbc49e33178b2d558c120a (Jun 20).

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ