1. 24 10月, 2014 15 次提交
    • W
      kvm: vfio: fix unregister kvm_device_ops of vfio · 571ee1b6
      Wanpeng Li 提交于
      After commit 80ce1639 (KVM: VFIO: register kvm_device_ops dynamically),
      kvm_device_ops of vfio can be registered dynamically. Commit 3c3c29fd
      (kvm-vfio: do not use module_init) move the dynamic register invoked by
      kvm_init in order to fix broke unloading of the kvm module. However,
      kvm_device_ops of vfio is unregistered after rmmod kvm-intel module
      which lead to device type collision detection warning after kvm-intel
      module reinsmod.
      
          WARNING: CPU: 1 PID: 10358 at /root/cathy/kvm/arch/x86/kvm/../../../virt/kvm/kvm_main.c:3289 kvm_init+0x234/0x282 [kvm]()
          Modules linked in: kvm_intel(O+) kvm(O) nfsv3 nfs_acl auth_rpcgss oid_registry nfsv4 dns_resolver nfs fscache lockd sunrpc pci_stub bridge stp llc autofs4 8021q cpufreq_ondemand ipv6 joydev microcode pcspkr igb i2c_algo_bit ehci_pci ehci_hcd e1000e i2c_i801 ixgbe ptp pps_core hwmon mdio tpm_tis tpm ipmi_si ipmi_msghandler acpi_cpufreq isci libsas scsi_transport_sas button dm_mirror dm_region_hash dm_log dm_mod [last unloaded: kvm_intel]
          CPU: 1 PID: 10358 Comm: insmod Tainted: G        W  O   3.17.0-rc1 #2
          Hardware name: Intel Corporation S2600CP/S2600CP, BIOS RMLSDP.86I.00.29.D696.1311111329 11/11/2013
           0000000000000cd9 ffff880ff08cfd18 ffffffff814a61d9 0000000000000cd9
           0000000000000000 ffff880ff08cfd58 ffffffff810417b7 ffff880ff08cfd48
           ffffffffa045bcac ffffffffa049c420 0000000000000040 00000000000000ff
          Call Trace:
           [<ffffffff814a61d9>] dump_stack+0x49/0x60
           [<ffffffff810417b7>] warn_slowpath_common+0x7c/0x96
           [<ffffffffa045bcac>] ? kvm_init+0x234/0x282 [kvm]
           [<ffffffff810417e6>] warn_slowpath_null+0x15/0x17
           [<ffffffffa045bcac>] kvm_init+0x234/0x282 [kvm]
           [<ffffffffa016e995>] vmx_init+0x1bf/0x42a [kvm_intel]
           [<ffffffffa016e7d6>] ? vmx_check_processor_compat+0x64/0x64 [kvm_intel]
           [<ffffffff810002ab>] do_one_initcall+0xe3/0x170
           [<ffffffff811168a9>] ? __vunmap+0xad/0xb8
           [<ffffffff8109c58f>] do_init_module+0x2b/0x174
           [<ffffffff8109d414>] load_module+0x43e/0x569
           [<ffffffff8109c6d8>] ? do_init_module+0x174/0x174
           [<ffffffff8109c75a>] ? copy_module_from_user+0x39/0x82
           [<ffffffff8109b7dd>] ? module_sect_show+0x20/0x20
           [<ffffffff8109d65f>] SyS_init_module+0x54/0x81
           [<ffffffff814a9a12>] system_call_fastpath+0x16/0x1b
          ---[ end trace 0626f4a3ddea56f3 ]---
      
      The bug can be reproduced by:
      
          rmmod kvm_intel.ko
          insmod kvm_intel.ko
      
      without rmmod/insmod kvm.ko
      This patch fixes the bug by unregistering kvm_device_ops of vfio when the
      kvm-intel module is removed.
      Reported-by: NLiu Rongrong <rongrongx.liu@intel.com>
      Fixes: 3c3c29fdSigned-off-by: NWanpeng Li <wanpeng.li@linux.intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      571ee1b6
    • N
      KVM: x86: Wrong assertion on paging_tmpl.h · 1715d0dc
      Nadav Amit 提交于
      Even after the recent fix, the assertion on paging_tmpl.h is triggered.
      Apparently, the assertion wants to check that the PAE is always set on
      long-mode, but does it in incorrect way.  Note that the assertion is not
      enabled unless the code is debugged by defining MMU_DEBUG.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1715d0dc
    • Q
      kvm: fix excessive pages un-pinning in kvm_iommu_map error path. · 3d32e4db
      Quentin Casasnovas 提交于
      The third parameter of kvm_unpin_pages() when called from
      kvm_iommu_map_pages() is wrong, it should be the number of pages to un-pin
      and not the page size.
      
      This error was facilitated with an inconsistent API: kvm_pin_pages() takes
      a size, but kvn_unpin_pages() takes a number of pages, so fix the problem
      by matching the two.
      
      This was introduced by commit 350b8bdd ("kvm: iommu: fix the third parameter
      of kvm_iommu_put_pages (CVE-2014-3601)"), which fixes the lack of
      un-pinning for pages intended to be un-pinned (i.e. memory leak) but
      unfortunately potentially aggravated the number of pages we un-pin that
      should have stayed pinned. As far as I understand though, the same
      practical mitigations apply.
      
      This issue was found during review of Red Hat 6.6 patches to prepare
      Ksplice rebootless updates.
      
      Thanks to Vegard for his time on a late Friday evening to help me in
      understanding this code.
      
      Fixes: 350b8bdd ("kvm: iommu: fix the third parameter of... (CVE-2014-3601)")
      Cc: stable@vger.kernel.org
      Signed-off-by: NQuentin Casasnovas <quentin.casasnovas@oracle.com>
      Signed-off-by: NVegard Nossum <vegard.nossum@oracle.com>
      Signed-off-by: NJamie Iles <jamie.iles@oracle.com>
      Reviewed-by: NSasha Levin <sasha.levin@oracle.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3d32e4db
    • N
      KVM: x86: PREFETCH and HINT_NOP should have SrcMem flag · 3f6f1480
      Nadav Amit 提交于
      The decode phase of the x86 emulator assumes that every instruction with the
      ModRM flag, and which can be used with RIP-relative addressing, has either
      SrcMem or DstMem.  This is not the case for several instructions - prefetch,
      hint-nop and clflush.
      
      Adding SrcMem|NoAccess for prefetch and hint-nop and SrcMem for clflush.
      
      This fixes CVE-2014-8480.
      
      Fixes: 41061cdb
      Cc: stable@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3f6f1480
    • N
      KVM: x86: Emulator does not decode clflush well · 13e457e0
      Nadav Amit 提交于
      Currently, all group15 instructions are decoded as clflush (e.g., mfence,
      xsave).  In addition, the clflush instruction requires no prefix (66/f2/f3)
      would exist. If prefix exists it may encode a different instruction (e.g.,
      clflushopt).
      
      Creating a group for clflush, and different group for each prefix.
      
      This has been the case forever, but the next patch needs the cflush group
      in order to fix a bug introduced in 3.17.
      
      Fixes: 41061cdb
      Cc: stable@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      13e457e0
    • P
      KVM: emulate: avoid accessing NULL ctxt->memopp · a430c916
      Paolo Bonzini 提交于
      A failure to decode the instruction can cause a NULL pointer access.
      This is fixed simply by moving the "done" label as close as possible
      to the return.
      
      This fixes CVE-2014-8481.
      Reported-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: stable@vger.kernel.org
      Fixes: 41061cdbSigned-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      a430c916
    • N
      KVM: x86: Decoding guest instructions which cross page boundary may fail · 08da44ae
      Nadav Amit 提交于
      Once an instruction crosses a page boundary, the size read from the second page
      disregards the common case that part of the operand resides on the first page.
      As a result, fetch of long insturctions may fail, and thereby cause the
      decoding to fail as well.
      
      Cc: stable@vger.kernel.org
      Fixes: 5cfc7e0fSigned-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      08da44ae
    • M
      kvm: x86: don't kill guest on unknown exit reason · 2bc19dc3
      Michael S. Tsirkin 提交于
      KVM_EXIT_UNKNOWN is a kvm bug, we don't really know whether it was
      triggered by a priveledged application.  Let's not kill the guest: WARN
      and inject #UD instead.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2bc19dc3
    • P
      kvm: vmx: handle invvpid vm exit gracefully · a642fc30
      Petr Matousek 提交于
      On systems with invvpid instruction support (corresponding bit in
      IA32_VMX_EPT_VPID_CAP MSR is set) guest invocation of invvpid
      causes vm exit, which is currently not handled and results in
      propagation of unknown exit to userspace.
      
      Fix this by installing an invvpid vm exit handler.
      
      This is CVE-2014-3646.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NPetr Matousek <pmatouse@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      a642fc30
    • N
      KVM: x86: Handle errors when RIP is set during far jumps · d1442d85
      Nadav Amit 提交于
      Far jmp/call/ret may fault while loading a new RIP.  Currently KVM does not
      handle this case, and may result in failed vm-entry once the assignment is
      done.  The tricky part of doing so is that loading the new CS affects the
      VMCS/VMCB state, so if we fail during loading the new RIP, we are left in
      unconsistent state.  Therefore, this patch saves on 64-bit the old CS
      descriptor and restores it if loading RIP failed.
      
      This fixes CVE-2014-3647.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d1442d85
    • N
      KVM: x86: Emulator fixes for eip canonical checks on near branches · 234f3ce4
      Nadav Amit 提交于
      Before changing rip (during jmp, call, ret, etc.) the target should be asserted
      to be canonical one, as real CPUs do.  During sysret, both target rsp and rip
      should be canonical. If any of these values is noncanonical, a #GP exception
      should occur.  The exception to this rule are syscall and sysenter instructions
      in which the assigned rip is checked during the assignment to the relevant
      MSRs.
      
      This patch fixes the emulator to behave as real CPUs do for near branches.
      Far branches are handled by the next patch.
      
      This fixes CVE-2014-3647.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      234f3ce4
    • N
      KVM: x86: Fix wrong masking on relative jump/call · 05c83ec9
      Nadav Amit 提交于
      Relative jumps and calls do the masking according to the operand size, and not
      according to the address size as the KVM emulator does today.
      
      This patch fixes KVM behavior.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      05c83ec9
    • A
      KVM: x86: Improve thread safety in pit · 2febc839
      Andy Honig 提交于
      There's a race condition in the PIT emulation code in KVM.  In
      __kvm_migrate_pit_timer the pit_timer object is accessed without
      synchronization.  If the race condition occurs at the wrong time this
      can crash the host kernel.
      
      This fixes CVE-2014-3611.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NAndrew Honig <ahonig@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2febc839
    • A
      KVM: x86: Prevent host from panicking on shared MSR writes. · 8b3c3104
      Andy Honig 提交于
      The previous patch blocked invalid writes directly when the MSR
      is written.  As a precaution, prevent future similar mistakes by
      gracefulling handle GPs caused by writes to shared MSRs.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NAndrew Honig <ahonig@google.com>
      [Remove parts obsoleted by Nadav's patch. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8b3c3104
    • N
      KVM: x86: Check non-canonical addresses upon WRMSR · 854e8bb1
      Nadav Amit 提交于
      Upon WRMSR, the CPU should inject #GP if a non-canonical value (address) is
      written to certain MSRs. The behavior is "almost" identical for AMD and Intel
      (ignoring MSRs that are not implemented in either architecture since they would
      anyhow #GP). However, IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if
      non-canonical address is written on Intel but not on AMD (which ignores the top
      32-bits).
      
      Accordingly, this patch injects a #GP on the MSRs which behave identically on
      Intel and AMD.  To eliminate the differences between the architecutres, the
      value which is written to IA32_SYSENTER_ESP and IA32_SYSENTER_EIP is turned to
      canonical value before writing instead of injecting a #GP.
      
      Some references from Intel and AMD manuals:
      
      According to Intel SDM description of WRMSR instruction #GP is expected on
      WRMSR "If the source register contains a non-canonical address and ECX
      specifies one of the following MSRs: IA32_DS_AREA, IA32_FS_BASE, IA32_GS_BASE,
      IA32_KERNEL_GS_BASE, IA32_LSTAR, IA32_SYSENTER_EIP, IA32_SYSENTER_ESP."
      
      According to AMD manual instruction manual:
      LSTAR/CSTAR (SYSCALL): "The WRMSR instruction loads the target RIP into the
      LSTAR and CSTAR registers.  If an RIP written by WRMSR is not in canonical
      form, a general-protection exception (#GP) occurs."
      IA32_GS_BASE and IA32_FS_BASE (WRFSBASE/WRGSBASE): "The address written to the
      base field must be in canonical form or a #GP fault will occur."
      IA32_KERNEL_GS_BASE (SWAPGS): "The address stored in the KernelGSbase MSR must
      be in canonical form."
      
      This patch fixes CVE-2014-3610.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      854e8bb1
  2. 22 10月, 2014 3 次提交
    • L
      Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending · c3351dfa
      Linus Torvalds 提交于
      Pull SCSI target updates from Nicholas Bellinger:
       "Here are the target updates for v3.18-rc2 code.  These where
        originally destined for -rc1, but due to the combination of travel
        last week for KVM Forum and my mistake of taking the three week merge
        window literally, the pull request slipped..  Apologies for that.
      
        Things where reasonably quiet this round.  The highlights include:
      
         - New userspace backend driver (target_core_user.ko) by Shaohua Li
           and Andy Grover
         - A number of cleanups in target, iscsi-taret and qla_target code
           from Joern Engel
         - Fix an OOPs related to queue full handling with CHECK_CONDITION
           status from Quinn Tran
         - Fix to disable TX completion interrupt coalescing in iser-target,
           that was causing problems on some hardware
         - Fix for PR APTPL metadata handling with demo-mode ACLs
      
        I'm most excited about the new backend driver that uses UIO + shared
        memory ring to dispatch I/O and control commands into user-space.
        This was probably the most requested feature by users over the last
        couple of years, and opens up a new area of development + porting of
        existing user-space storage applications to LIO.  Thanks to Shaohua +
        Andy for making this happen.
      
        Also another honorable mention, a new Xen PV SCSI driver was merged
        via the xen/tip.git tree recently, which puts us now at 10 target
        drivers in upstream! Thanks to David Vrabel + Juergen Gross for their
        work to get this code merged"
      
      * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (40 commits)
        target/file: fix inclusive vfs_fsync_range() end
        iser-target: Disable TX completion interrupt coalescing
        target: Add force_pr_aptpl device attribute
        target: Fix APTPL metadata handling for dynamic MappedLUNs
        qla_target: don't delete changed nacls
        target/user: Recalculate pad size inside is_ring_space_avail()
        tcm_loop: Fixup tag handling
        iser-target: Fix smatch warning
        target/user: Fix up smatch warnings in tcmu_netlink_event
        target: Add a user-passthrough backstore
        target: Add documentation on the target userspace pass-through driver
        uio: Export definition of struct uio_device
        target: Remove unneeded check in sbc_parse_cdb
        target: Fix queue full status NULL pointer for SCF_TRANSPORT_TASK_SENSE
        qla_target: rearrange struct qla_tgt_prm
        qla_target: improve qlt_unmap_sg()
        qla_target: make some global functions static
        qla_target: remove unused parameter
        target: simplify core_tmr_abort_task
        target: encapsulate smp_mb__after_atomic()
        ...
      c3351dfa
    • L
      Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd · 848a5528
      Linus Torvalds 提交于
      Pull email address change from Boaz Harrosh.
      
      * 'for-linus' of git://git.open-osd.org/linux-open-osd:
        Boaz Harrosh - fix email in Documentation
        Boaz Harrosh - Fix broken email address
        MAINTAINERS: Change Boaz Harrosh's email
      848a5528
    • L
      Merge branch 'mailbox-for-linus' of git://git.linaro.org/landing-teams/working/fujitsu/integration · 43d451f1
      Linus Torvalds 提交于
      Pull mailbox framework from Jassi Brar:
       "A framework for Mailbox controllers and clients have been cooking for
        more than a year now.
      
        Everybody in the CC list had been copied on patchset revisions and
        most of them have made sounds of approval, though just one concrete
        Reviewed-by.  The patchset has also been in linux-next for a couple of
        weeks now and no conflict has been reported.  The framework has the
        backing of at least 5 platforms, though I can't say if/when they
        upstream their drivers (some businesses have 'changed')"
      
      (Further acked-by by Arnd Bergmann and Suman Anna in the pull request
      thread)
      
      * 'mailbox-for-linus' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
        dt: mailbox: add generic bindings
        doc: add documentation for mailbox framework
        mailbox: Introduce framework for mailbox
        mailbox: rename pl320-ipc specific mailbox.h
      43d451f1
  3. 21 10月, 2014 22 次提交