kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kvm: WARNING in kvm_arch_vcpu_ioctl_run
@ 2016-11-14 14:00 Dmitry Vyukov
  2016-11-14 14:03 ` Paolo Bonzini
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Vyukov @ 2016-11-14 14:00 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, x86@kernel.org, KVM list, LKML,
	Steve Rutherford
  Cc: syzkaller

Hello,

The following program triggers WARNING in kvm_arch_vcpu_ioctl_run in
run in parallel loop:
https://gist.githubusercontent.com/dvyukov/08091eee6f38548ff9e6905c5e0eaaee/raw/8cae95f2e88eeb98c4ddc06d227670c1e248222f/gistfile1.txt

On commit e234832afb623fe5c7d1d5703d6619494d8d703f (Nov 13)

WARNING: CPU: 3 PID: 11141 at arch/x86/kvm/x86.c:6984
kvm_arch_vcpu_ioctl_run+0x1f0/0x4f50
CPU: 3 PID: 11141 Comm: syz-executor Not tainted 4.9.0-rc5+ #24
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 ffff880039cef698 ffffffff834c3959 ffffffff00000003 1ffff1000739de66
 ffffed000739de5e 0000000041b58ab3 ffffffff89576450 ffffffff834c366b
 0000000041b58ab3 ffffffff894d2830 ffffffff81590020 ffffffff810d90f0
Call Trace:
 [<     inline     >] __dump_stack lib/dump_stack.c:15
 [<ffffffff834c3959>] dump_stack+0x2ee/0x3f5 lib/dump_stack.c:51
 [<ffffffff81849908>] panic+0x200/0x425 kernel/panic.c:179
 [<ffffffff813fd919>] __warn+0x1c9/0x1e0 kernel/panic.c:542
 [<ffffffff813fdb81>] warn_slowpath_null+0x31/0x40 kernel/panic.c:585
 [<ffffffff810ee930>] kvm_arch_vcpu_ioctl_run+0x1f0/0x4f50
arch/x86/kvm/x86.c:6984
 [<ffffffff8107b328>] kvm_vcpu_ioctl+0x678/0x11c0
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2557
 [<     inline     >] vfs_ioctl fs/ioctl.c:43
 [<ffffffff81abdb44>] do_vfs_ioctl+0x1c4/0x1630 fs/ioctl.c:679
 [<     inline     >] SYSC_ioctl fs/ioctl.c:694
 [<ffffffff81abf044>] SyS_ioctl+0x94/0xc0 fs/ioctl.c:685
 [<ffffffff88144885>] entry_SYSCALL_64_fastpath+0x23/0xc6

^ permalink raw reply	[flat|nested] 11+ messages in thread
* kvm: WARNING in kvm_arch_vcpu_ioctl_run
@ 2017-08-09 17:07 Dmitry Vyukov
  2017-08-09 17:09 ` Dmitry Vyukov
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Dmitry Vyukov @ 2017-08-09 17:07 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář, KVM list, LKML,
	David Hildenbrand, P J P, James Mattson, Xiao Guangrong,
	Haozhong Zhang, Wanpeng Li, Steve Rutherford
  Cc: syzkaller

Hello,

syzkaller fuzzer has hit the following WARNING in kvm_arch_vcpu_ioctl_run.
This is easily reproducible and reproducer is attached at the bottom.
The report is on upstream commit
26c5cebfdb6ca799186f1e56be7d6f2480c5012c. This requires setting
kvm-intel.unrestricted_guest=0 on the machine, with
unrestricted_guest=1 the WARNING does not happen. Output of the
program is:

ret1=0 exit_reason=17 suberror=1
ret2=0 exit_reason=8 suberror=65530


WARNING: CPU: 1 PID: 2850 at arch/x86/kvm/x86.c:7223
kvm_arch_vcpu_ioctl_run+0x213/0x5870 arch/x86/kvm/x86.c:7223
CPU: 1 PID: 2850 Comm: a.out Not tainted 4.13.0-rc3+ #445
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:52
 panic+0x1e4/0x417 kernel/panic.c:180
 __warn+0x1c4/0x1d9 kernel/panic.c:541
 report_bug+0x211/0x2d0 lib/bug.c:183
 fixup_bug+0x40/0x90 arch/x86/kernel/traps.c:190
 do_trap_no_signal arch/x86/kernel/traps.c:224 [inline]
 do_trap+0x260/0x390 arch/x86/kernel/traps.c:273
 do_error_trap+0x120/0x390 arch/x86/kernel/traps.c:310
 do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:323
 invalid_op+0x1e/0x30 arch/x86/entry/entry_64.S:846
RIP: 0010:kvm_arch_vcpu_ioctl_run+0x213/0x5870 arch/x86/kvm/x86.c:7222
RSP: 0018:ffff8800627cf670 EFLAGS: 00010297
RAX: ffff880066c44480 RBX: ffff88006b07f000 RCX: ffff880067d0845c
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff880067d08260
RBP: ffff8800627cfa40 R08: 0000000000000001 R09: 0000000000000000
R10: ffff8800627cfa58 R11: 0000000000000000 R12: 0000000000000001
R13: 0000000000000000 R14: ffff88006b934880 R15: ffff880067d08040
 kvm_vcpu_ioctl+0x64c/0x1010 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2592
 vfs_ioctl fs/ioctl.c:45 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x44ccc9
RSP: 002b:00007f9ecbc37db8 EFLAGS: 00000297 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000044ccc9
RDX: 0000000000000000 RSI: 000000000000ae80 RDI: 0000000000000005
RBP: 0000000000000082 R08: 00007f9ecbc38700 R09: 0000000000000000
R10: 00007f9ecbc38700 R11: 0000000000000297 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f9ecbc389c0 R15: 00007f9ecbc38700



// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/kvm.h>
#include <stdio.h>

int kvmcpu;
struct kvm_run *run;

void* thr(void* arg)
{
  int res;
  res = ioctl(kvmcpu, KVM_RUN, 0);
  printf("ret1=%d exit_reason=%d suberror=%d\n",
      res, run->exit_reason, run->internal.suberror);
  return 0;
}

void test()
{
  int i, kvm, kvmvm;
  pthread_t th[4];

  kvm = open("/dev/kvm", O_RDWR);
  kvmvm = ioctl(kvm, KVM_CREATE_VM, 0);
  kvmcpu = ioctl(kvmvm, KVM_CREATE_VCPU, 0);
  run = (struct kvm_run*)mmap(0, 4096, PROT_READ|PROT_WRITE,
MAP_SHARED, kvmcpu, 0);
  srand(getpid());
  for (i = 0; i < 4; i++) {
    pthread_create(&th[i], 0, thr, 0);
    usleep(rand() % 10000);
  }
  for (i = 0; i < 4; i++)
    pthread_join(th[i], 0);
}

int main()
{
  for (;;) {
    int pid = fork();
    if (pid < 0)
      exit(1);
    if (pid == 0) {
      test();
      exit(0);
    }
    int status;
    while (waitpid(pid, &status, __WALL) != pid) {}
  }
  return 0;
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-08-10  5:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-14 14:00 kvm: WARNING in kvm_arch_vcpu_ioctl_run Dmitry Vyukov
2016-11-14 14:03 ` Paolo Bonzini
2016-11-14 14:09   ` Dmitry Vyukov
2016-11-14 14:45     ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2017-08-09 17:07 Dmitry Vyukov
2017-08-09 17:09 ` Dmitry Vyukov
2017-08-09 17:11   ` Dmitry Vyukov
2017-08-09 20:24 ` David Hildenbrand
2017-08-09 20:35   ` Dmitry Vyukov
2017-08-09 21:53 ` Wanpeng Li
2017-08-10  5:37 ` Wanpeng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).