All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: alazar@bitdefender.com, Stefan Hajnoczi <stefanha@gmail.com>
Cc: "Mihai Dontu" <mdontu@bitdefender.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	kvm@vger.kernel.org
Subject: Re: [RFC PATCH 00/19] Guest introspection
Date: Tue, 20 Jun 2017 17:03:37 +0200	[thread overview]
Message-ID: <da4620cf-3949-0ee9-24ff-8dbadcd6e421@siemens.com> (raw)
In-Reply-To: <1497970721.139b8aD.12149@host>

On 2017-06-20 16:58, alazar@bitdefender.com wrote:
> On Mon, 19 Jun 2017 10:39:28 +0100, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>> On Fri, Jun 16, 2017 at 05:34:48PM +0200, Jan Kiszka wrote:
>>> On 2017-06-16 17:18, Mihai Donțu wrote:
>>>> On Fri, 2017-06-16 at 16:45 +0200, Jan Kiszka wrote:
>>>>> On 2017-06-16 15:43, Adalbert Lazar wrote:
>>>>>> This patch series proposes an interface that will allow a guest
>>>>>> introspection tool to monitor and control other guests, in order to
>>>>>> protect them against different forms of exploits. This type of interface
>>>>>> is already present in the XEN hypervisor.
>>>>>>
>>>>>> With the current implementation, the introspection tool connects to
>>>>>> the KVMi (the introspection subsystem from KVM) using a vsock socket,
>>>>>> establishes a main communication channel, used for a few messages
>>>>>> (KVMI_EVENT_GUEST_ON, KVMI_EVENT_GUEST_OFF, KVMI_GET_GUESTS and
>>>>>> KVMI_GET_VERSION).
>>>>>>
>>>>>> Every KVMI_EVENT_GUEST_ON notification, makes the introspection tool
>>>>>> establish a new connection, used to monitor and control that guest.
>>>>
>>>>> What prevented building this on top of the already existing guest debug
>>>>> interfaces of KVM, maybe extending it where needed? Could be win-win.
>>>>
>>>> I might be mistaking, but this would require the application using the
>>>> introspection capabilities to run on the host. If so, what we are
>>>> trying to do is to isolate the application into its own VM. This is why
>>>> we use vSock to communicate with the host.
>>>
>>> The hypervisor process could terminate your link, providing that other
>>> VM the introspection access. Or you even have a gdb-speaking process
>>> running on the host, just reusing the existing gdbstub of QEMU. Just
>>> wild ideas, I didn't look into details, and you may further elaborate on
>>> your requirements.
>>
>> QEMU userspace can provide the interface on an AF_VSOCK listen socket.
>> Here is a rough idea:
>>
>>   qemu --chardev socket,id=chardev0,type=vsock,port=1234,server,nowait \
>>        --guest-introspection chardev=chardev0,allowed-cids=10
>>
>> Since it uses a chardev this means the guest introspection API is also
>> available via UNIX domain sockets to local applications, etc.
> 
> Exposing the introspections commands and events as IOCTLs can be done easily.
> 
> However, dropping the vsock access from the kernel, or having
> the IOCTL <-> vsock adapter only in userspace will change more things.
> With the proposed API, the guest introspection looks like:
> 
>  ------------------                  -----------------------------
> |                  |<-- /dev/kvm -->| qemu        VM1             |
> |                  |                |-------                      |
> |                  |                | Linux |                     |
> | KVM              |                 -----------------------------
> |                  |<-- /dev/kvm -->| qemu        VM2             |
> |                  |                |---------                    |
> |                  |                | Windows |                   |
> |                  |                 -----------------------------
> |                  |<-- /dev/kvm -->| qemu        VM3             |
> |    --------------|                |---------------------------  |
> |   | kvmi <- vhost-vsock -----------> guest introspection tool | |
>  ------------------                  -----------------------------
> 
> The introspection tool connects directly to the introspection subsystem (kvmi).
> 
> Moving the vsock to userland will change this:
> 
>                                      -----------------------------
>                  /----- /dev/kvm -->| new_tool (guest on/off/list)|<-- vsock -->\
>                  |                   -----------------------------              |
>                  |                                                              |
>  ----------------v-                  -----------------------------              |
> |                  |<-- /dev/kvm -->| qemu        VM1             |<-- vsock -->|
> |                  |                |-------                      |             |
> |                  |                | Linux |                     |             |
> | KVM              |                 -----------------------------              |
> |                  |<-- /dev/kvm -->| qemu        VM2             |<-- vsock -->|
> |                  |                |---------                    |             |
> |                  |                | Windows |                   |             |
> |                  |                 -----------------------------              |
> |                  |<-- /dev/kvm -->| qemu        VM3      /----->|<-- vsock -->/
> |           -------|                |---------------------v----   |
> |          | kvmi  |                | guest introspection tool |  |
>  ------------------                  -----------------------------
> 
> There will be a need for a new tool (and/or libvirt modified) to get
> the guest events (on/off/list) and change the VM1, VM2 invocations (to
> make them connect with the introspection tool). This might also be a
> problem with products having the host locked down (eg. RHEV).
> 
> Moving more code to QEMU will make the introspection harder with other
> hw emulators (from kvmtool to Google's implementation) because they will

I would bet that (not only) Google folks will look rather skeptical at
any proposal to widen the existing kvm user interface anyway, because of
security implications. Reducing that should be a primary design goal IMHO.

Jan

> need more than just:
>    - migration notification: the introspection tool needs to unhook
>      from the introspected guests [minor change]
>    - KVM_SET_VM_UUID support [minor change]
>    - vsock [medium change], but only if this particular emulator is used
>      to start the guest introspection tool
> 
> Also, the path between kvmi and the introspection tool (when running
> isolated in a guest) will be bigger, adding some overhead, which is
> a big problem with live introspectors. EXTERIOR VMI paper shows[1]
> between 5-20 times slower execution for small programs (ps, uptime).
> So, a smaller path will help in keeping the overhead lower.
> 
> My colleague will follow up with some stats collected during an
> introspection session. Hopefully they will shed more light on the
> performance required from the tool-KVM communication channel.
> 
> [1]: https://www.utdallas.edu/~zhiqiang.lin/file/VEE13-Slides.pdf
> 

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

  reply	other threads:[~2017-06-20 15:26 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-16 13:43 [RFC PATCH 00/19] Guest introspection Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 01/19] kvm: x86: mmu: Add kvm_mmu_get_spte() and kvm_mmu_set_spte() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 02/19] kvm: x86: Add kvm_arch_vcpu_set_regs() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 03/19] mm: Add vm_replace_page() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 04/19] kvm: Add kvm_enum() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 05/19] kvm: Add uuid member in struct kvm + support for KVM_CAP_VM_UUID Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 06/19] kvm: Add kvm_vm_shutdown() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 07/19] kvm: x86: Add kvm_arch_msr_intercept() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 08/19] kvm: Add the introspection subsystem Adalbert Lazar
2017-06-21 11:54   ` Paolo Bonzini
2017-06-21 12:36     ` Mihai Donțu
2017-06-21 12:57       ` Paolo Bonzini
2017-06-16 13:43 ` [RFC PATCH 09/19] kvm: Hook in kvmi on VM on/off events Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 10/19] kvm: vmx: Hook in kvmi_page_fault() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 11/19] kvm: x86: Hook in kvmi_breakpoint_event() Adalbert Lazar
2017-06-21 11:48   ` Paolo Bonzini
2017-06-21 12:37     ` Mihai Donțu
2017-06-16 13:43 ` [RFC PATCH 12/19] kvm: x86: Hook in kvmi_trap_event() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 13/19] kvm: x86: Hook in kvmi_cr_event() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 14/19] kvm: x86: Hook in kvmi_xsetbv_event() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 15/19] kvm: x86: Hook in kvmi_msr_event() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 16/19] kvm: x86: Change the emulation context Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 17/19] kvm: x86: Hook in kvmi_vmcall_event() Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 18/19] kvm: x86: Set the new spte flags before entering the guest Adalbert Lazar
2017-06-16 13:43 ` [RFC PATCH 19/19] kvm: x86: Handle KVM_REQ_INTROSPECTION Adalbert Lazar
2017-06-16 14:45 ` [RFC PATCH 00/19] Guest introspection Jan Kiszka
2017-06-16 15:18   ` Mihai Donțu
2017-06-16 15:34     ` Jan Kiszka
2017-06-16 15:59       ` Mihai Donțu
2017-06-19  9:39       ` Stefan Hajnoczi
2017-06-20 14:58         ` alazar
2017-06-20 15:03           ` Jan Kiszka [this message]
2017-06-21 11:04           ` Stefan Hajnoczi
2017-06-21 13:25             ` Paolo Bonzini
2017-06-27 16:12               ` Mihai Donțu
2017-06-27 16:23                 ` Paolo Bonzini
2017-06-16 17:05     ` Paolo Bonzini
2017-06-16 17:27       ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da4620cf-3949-0ee9-24ff-8dbadcd6e421@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=alazar@bitdefender.com \
    --cc=kvm@vger.kernel.org \
    --cc=mdontu@bitdefender.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.