SlideShare a Scribd company logo
1 of 33
Download to read offline
VM Forking & Hypervisor-based Fuzzing with Xen
Open Source Summit Europe 2020
Tamas K Lengyel
2
Notices & Disclaimers
Intel technologies may require enabled hardware, software or service activation.
No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document. Intel
disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a
particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage
in trade.
The products described may contain design defects or errors known as errata which may cause the product to deviate from
published specifications. Current characterized errata are available on request.
You may not use or facilitate the use of this document in connection with any infringement or other legal analysis concerning Intel
products described herein. You agree to grant Intel a non-exclusive, royalty-free license to any patent claim thereafter drafted
which includes subject matter disclosed herein.
Intel does not control or audit third-party data. You should consult other sources to evaluate accuracy.
No product or component can be absolutely secure.
Your costs and results may vary.
© Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names
and brands may be claimed as the property of others.
3
# whoami
• Senior Security Research @ Intel
• Maintainer of Xen’s introspection subsystem
• Maintainer of LibVMI
• Hypervisor agnostic introspection library (Xen, KVM, etc)
• Lot’s of convenient APIs to do introspection with
• Background in malware research & black-box binary analysis
4
Outline
1. Intro & Motivation
2. VM introspection
3. VM forking nuts & bolts
4. Fuzzing on Xen
• Harnessing & coverage tracing
• VMs with PCI-passthrough (IOMMU) devices
• Doublefetch detection
5
Motivation
• Time-tested approach to software validation
• Conceptually straight-forward
• In practice can be difficult depending on what you want to fuzz
• How do you create coverage trace for the kernel?
• How do you recover fast enough for fuzzing to be effective?
• How do you ensure system is in the proper state?
• How do you fuzz kernel-internal interfaces?
• How do you detect more then just “crashes”?
6
Kernel fuzzers do exist
• syzkaller
• Linux syscall fuzzer with built-in coverage guidance
• kAFL
• KVM based using AFL, coverage via Intel PT & PML
• Chocolate milk
• Custom bootloader & hypervisor, all in rust
7
Why make another one?
• These platforms are tightly coupled to their use-case
• We wanted something stable but also flexible to build on
• Preferring code that’s upstream to cut down on time it takes to
maintain custom patches & debugging things when they break
• Xen’s VMI subsystem is still experimental but fits the bill
• Also allows us to consider new types of fuzzing approaches
• Also allows us to target new use-cases
8
VM introspection
• Inspect VM internals from an external perspective
• Very similar to kernel debugging & memory forensics
• We can pause the VM at any event that traps to the VMM
• EPT faults
• Breakpoints
• CPUID
• Singlestep (MTF)
• Can do it both with in-guest help or without
9
Why VM forking?
• We need a way to restore VMs to a start point quickly after each
fuzz cycle
• Restoring from a save-file can take up to 2s
• Even from a fast SSD or tmpfs
• Fuzzing to be effective we need to be faster than that
• Xen has a long-forgotten, half abandoned subsystem:
• Memory sharing!
• We can use it to create forks in a fast & lightweight manner!
10
VM forking overview
1. Create VM with an empty EPT (ie. no memory)
2. Specify its parent VM
3. Copy vCPU parameters from parent
4. When VM is started it will page-fault back to Xen each time it tries
to access memory not yet mapped
5. Populate pages on-demand in the page-fault handler
• Read & execute accesses are populated with a shared entry
• Write accesses are deduplicated
11
VM forking details
• It’s a bit different then fork() on Linux
• The parent domain currently remains paused while forks are active
• This was fine for our use-case
• For a full domain split, all the parent pages need to be made shared
• Pages that can’t be made shared would need an extra copy
• Doable, was out-of-scope for now
• Forks can be further forked!
• Pages are searched for recursively
12
VM forking details
• VM forks can run with only CPU & memory
• No disk
• No networking
• No I/O
• No interrupts!
• It’s possible to launch QEMU to start backend services
• Patches implementing this are posted but not yet upstream
• Launching & resetting QEMU is slow
• Not a priority since it’s not required for fuzzing
13
VM forks: resetting
• No need to keep creating forks for every fuzz iteration
• We can just reset a previously forked VM
• Re-copy vCPU settings from parent
• Keep memory shared entries in place
• Future iterations will be that much faster
• Throw-away deduplicated memory
• Reset speed depends on how much memory needs to be freed here
• During fuzzing it’s usually very few pages
14
VM forking speed
VM fork creation time:
~745 μs ~= 1300 VM/s
VM fork reset time:
~111 μs ~= 9000 reset/s
Measured on i5-8350U
15
Harnessing
• Fuzzer needs to know where the target code starts & stops
• Need to manually mark it
• Harness needs to trap to the hypervisor
• Should not have side-effects
• Code needs to execute normally between start & stop harness
• Code needs to consume some input
• We need to know where the input is so we can fuzz it
16
Harnessing
CPUID instruction always traps to VMM
We use a magic CPUID leaf as our mark
No side-effect on target code, without
the fuzzer this is effectively a NOP
Call harness() before and after target code
Just printk info before the first harness!
17
Harnessing
• Parent VM will display information about target (buffer address) on
its virtual serial console that we’ll fuzz
• Parent VM will trap to the VMM on CPUID
• Detect if it’s the start signal (magic value) and pause Parent VM
• Increments IP so vCPU will be next starting just after the CPUID
18
Coverage tracing
• Fuzzer (AFL) needs to know when new code-paths are discovered
• By default AFL requires you to recompile your target
• Instruments each branch with hooks
• We don’t want to recompile the whole kernel
• We want to minimize the modifications we make to the target
• Just adding the calls to harness() and displaying relevant information
• During fuzzing code will run in a VM fork & the only visibility we
have is when it traps to VMM
19
Coverage tracing with VMI
• We can read & write to the VM forks memory from the VMM!
1. Configure VM fork to trap breakpoints to the VMM
2. Read & disassemble code from start point (RIP)
3. Find next control-flow instruction
4. Replace it with breakpoint
5. Resume vCPU
6. Breakpoint traps, remove breakpoint and enable singlestep (MTF)
7. MTF traps, disable MTF, goto Step 2
• Works in nested setups as well (tested with Xen inside VMware)!
20
Detecting crashes
• Breakpoint the kernel’s crash handlers
• Defined as “sink” points
• Breakpoints trap to the hypervisor, if any of them execute report
“crash”
• Good base targets to sink:
• panic()
• oops_begin()
• page_fault() or it’s new name asm_exc_page_fault()
21
Putting it all together
1. Setup parent VM: trap on first call to harness()
2. Create first fork: breakpoint the sinks
3. Create second fork: fuzz, execute & collect coverage trace!
Parent VM -> Sink VM -> Fuzz VM
22
Demo:
https://youtu.be/0A4msmDx30c
23
Coverage tracing with Intel Processor Trace
• Disassembly, breakpoint & singlestep is expensive
• We can go faster if the silicon collects the info for us
• Designate memory location (up to 4GB) as PT buffer
• VM forks’ execution will be recorded there
• Need to decode custom PT buffer format to reconstruct coverage
• Can be tedious and existing decoders not designed for high-speed fuzzing
• Open Source community to the rescue: https://github.com/nyx-fuzz/libxdc
• Does not work in nested setup, only single address-space
24
AFL + PT demo
25
Alternative harnessing
• What if we can’t recompile our target to add the harness()?
• We can use a debugger to add breakpoints as our harness!
• Run with GDB, set breakpoint before & after target code
• Fuzzer needs to know original instruction before it was
breakpointed (really just the first byte)
• When breakpoint traps to the VMM, replace breakpoint with
original content
• Fuzz!
26
Demo:
https://youtu.be/kundkmZMbl4
27
PCI-passthrough devices & fuzzing
• Making sure your target code is in the right state can be difficult
• Kernel modules may only fully initialize if physical device is present
• We can attach device to parent VM!
• Kernel module fully initializes & actively drives device
• Harness & fork works just the same!
• Only parent VM has access to device
• VM fork can’t corrupt device
• VM fork can’t access the device
28
Demo:
https://youtu.be/O6zti8V45ds
29
Detecting doublefetches
• We can define any condition as a “crash”
• Detecting doublefetch conditions is very difficult
• Sometimes introduced by the compiler so source review is not sufficient
• We are already hooked into the VMM pagefault handler
• We can detect doublefetches using EPT
1. Remove R/W permissions from page suspected of being doublefetched from
2. When an access faults, record page offset, reset permission & singlestep
3. In singlestep handler remove permissions & continue
4. If next access fault is at the same offset: doublefetch detected!
30
Demo:
https://youtu.be/O6zti8V45ds
31
Code released as open-source (MIT)
VM forking is upstream in Xen 4.14
Kernel Fuzzer for Xen Project (kfx):
https://github.com/intel/kernel-fuzzer-for-xen-project
32
Thanks!
Questions? Comments?
tamas.lengyel@intel.com
@tklengyel
Special thanks to the following people for their significant help:
Andrew Cooper, @buherator, @icedevml, @0xTony, @poeplau,
@proskurinserg, @is_eqv, @ms_s3c
33

More Related Content

What's hot

Hacktivity2014: Virtual Machine Introspection to Detect and Protect
Hacktivity2014: Virtual Machine Introspection to Detect and ProtectHacktivity2014: Virtual Machine Introspection to Detect and Protect
Hacktivity2014: Virtual Machine Introspection to Detect and ProtectTamas K Lengyel
 
Cloud Security with LibVMI
Cloud Security with LibVMICloud Security with LibVMI
Cloud Security with LibVMITamas K Lengyel
 
31c3 Presentation - Virtual Machine Introspection
31c3 Presentation - Virtual Machine Introspection31c3 Presentation - Virtual Machine Introspection
31c3 Presentation - Virtual Machine IntrospectionTamas K Lengyel
 
Virtual Machine Introspection with Xen on ARM
Virtual Machine Introspection with Xen on ARMVirtual Machine Introspection with Xen on ARM
Virtual Machine Introspection with Xen on ARMTamas K Lengyel
 
[Hackito2012] Hardware backdooring is practical
[Hackito2012] Hardware backdooring is practical[Hackito2012] Hardware backdooring is practical
[Hackito2012] Hardware backdooring is practicalMoabi.com
 
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...The Linux Foundation
 
XPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE Systems
XPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE SystemsXPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE Systems
XPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE SystemsThe Linux Foundation
 
XPDS16: AMD's virtualization memory encryption technology - Brijesh Singh, A...
XPDS16:  AMD's virtualization memory encryption technology - Brijesh Singh, A...XPDS16:  AMD's virtualization memory encryption technology - Brijesh Singh, A...
XPDS16: AMD's virtualization memory encryption technology - Brijesh Singh, A...The Linux Foundation
 
Hardware backdooring is practical : slides
Hardware backdooring is practical : slidesHardware backdooring is practical : slides
Hardware backdooring is practical : slidesMoabi.com
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practicalMoabi.com
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted Computing[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted ComputingOWASP
 
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Shota Shinogi
 
XPDS16: Xenbedded: Xen-based client virtualization for phones and tablets - ...
XPDS16:  Xenbedded: Xen-based client virtualization for phones and tablets - ...XPDS16:  Xenbedded: Xen-based client virtualization for phones and tablets - ...
XPDS16: Xenbedded: Xen-based client virtualization for phones and tablets - ...The Linux Foundation
 
High Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux KernelHigh Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux KernelKernel TLV
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesPeter Hlavaty
 
DefCon 2012 - Hardware Backdooring (Slides)
DefCon 2012 - Hardware Backdooring (Slides)DefCon 2012 - Hardware Backdooring (Slides)
DefCon 2012 - Hardware Backdooring (Slides)Michael Smith
 
LFNW2014 Advanced Security Features of Xen Project Hypervisor
LFNW2014 Advanced Security Features of Xen Project HypervisorLFNW2014 Advanced Security Features of Xen Project Hypervisor
LFNW2014 Advanced Security Features of Xen Project HypervisorThe Linux Foundation
 
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Nate Lawson
 

What's hot (20)

Hacktivity2014: Virtual Machine Introspection to Detect and Protect
Hacktivity2014: Virtual Machine Introspection to Detect and ProtectHacktivity2014: Virtual Machine Introspection to Detect and Protect
Hacktivity2014: Virtual Machine Introspection to Detect and Protect
 
Cloud Security with LibVMI
Cloud Security with LibVMICloud Security with LibVMI
Cloud Security with LibVMI
 
31c3 Presentation - Virtual Machine Introspection
31c3 Presentation - Virtual Machine Introspection31c3 Presentation - Virtual Machine Introspection
31c3 Presentation - Virtual Machine Introspection
 
Virtual Machine Introspection with Xen on ARM
Virtual Machine Introspection with Xen on ARMVirtual Machine Introspection with Xen on ARM
Virtual Machine Introspection with Xen on ARM
 
[Hackito2012] Hardware backdooring is practical
[Hackito2012] Hardware backdooring is practical[Hackito2012] Hardware backdooring is practical
[Hackito2012] Hardware backdooring is practical
 
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...
 
XPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE Systems
XPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE SystemsXPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE Systems
XPDS16: The OpenXT Project in 2016 - Christopher Clark, BAE Systems
 
XPDS16: AMD's virtualization memory encryption technology - Brijesh Singh, A...
XPDS16:  AMD's virtualization memory encryption technology - Brijesh Singh, A...XPDS16:  AMD's virtualization memory encryption technology - Brijesh Singh, A...
XPDS16: AMD's virtualization memory encryption technology - Brijesh Singh, A...
 
Hardware backdooring is practical : slides
Hardware backdooring is practical : slidesHardware backdooring is practical : slides
Hardware backdooring is practical : slides
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis
 
[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted Computing[Wroclaw #3] Trusted Computing
[Wroclaw #3] Trusted Computing
 
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
 
XPDS16: Xenbedded: Xen-based client virtualization for phones and tablets - ...
XPDS16:  Xenbedded: Xen-based client virtualization for phones and tablets - ...XPDS16:  Xenbedded: Xen-based client virtualization for phones and tablets - ...
XPDS16: Xenbedded: Xen-based client virtualization for phones and tablets - ...
 
High Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux KernelHigh Performance Storage Devices in the Linux Kernel
High Performance Storage Devices in the Linux Kernel
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
 
DefCon 2012 - Hardware Backdooring (Slides)
DefCon 2012 - Hardware Backdooring (Slides)DefCon 2012 - Hardware Backdooring (Slides)
DefCon 2012 - Hardware Backdooring (Slides)
 
Intel update
Intel updateIntel update
Intel update
 
LFNW2014 Advanced Security Features of Xen Project Hypervisor
LFNW2014 Advanced Security Features of Xen Project HypervisorLFNW2014 Advanced Security Features of Xen Project Hypervisor
LFNW2014 Advanced Security Features of Xen Project Hypervisor
 
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
 

Similar to VM Forking & Hypervisor-based Fuzzing with Xen

eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...
eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...
eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...eFolder
 
Venom vulnerability Overview and a basic demo
Venom vulnerability Overview and a basic demoVenom vulnerability Overview and a basic demo
Venom vulnerability Overview and a basic demoAkash Mahajan
 
Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...
Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...
Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...Peter Tripp
 
Experiences porting KVM to SmartOS
Experiences porting KVM to SmartOSExperiences porting KVM to SmartOS
Experiences porting KVM to SmartOSbcantrill
 
Windows 7 professional Vs Windows 7 enterprise
Windows 7 professional Vs Windows 7 enterpriseWindows 7 professional Vs Windows 7 enterprise
Windows 7 professional Vs Windows 7 enterprise247infotech
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNoSuchCon
 
ZertoCON_Support_Toolz.pdf
ZertoCON_Support_Toolz.pdfZertoCON_Support_Toolz.pdf
ZertoCON_Support_Toolz.pdftestslebew
 
Auto Deploy Deep Dive – vBrownBag Style
Auto Deploy Deep Dive – vBrownBag StyleAuto Deploy Deep Dive – vBrownBag Style
Auto Deploy Deep Dive – vBrownBag StyleRobert Nelson
 
Opening last bits of the infrastructure
Opening last bits of the infrastructureOpening last bits of the infrastructure
Opening last bits of the infrastructureErwan Velu
 
Kvm virtualization in_rhel_7
Kvm virtualization in_rhel_7Kvm virtualization in_rhel_7
Kvm virtualization in_rhel_7Urgen Sherpa
 
Distro Recipes 2013: Secure Boot and Linux: several issues, one solution
Distro Recipes 2013: Secure Boot and Linux: several issues, one solutionDistro Recipes 2013: Secure Boot and Linux: several issues, one solution
Distro Recipes 2013: Secure Boot and Linux: several issues, one solutionAnne Nicolas
 
Project ACRN Device Passthrough Introduction
Project ACRN Device Passthrough IntroductionProject ACRN Device Passthrough Introduction
Project ACRN Device Passthrough IntroductionProject ACRN
 
XPDS14 - Xen in EFI World - Daniel Kiper, Oracle
XPDS14 - Xen in EFI World - Daniel Kiper, OracleXPDS14 - Xen in EFI World - Daniel Kiper, Oracle
XPDS14 - Xen in EFI World - Daniel Kiper, OracleThe Linux Foundation
 
Introduction to Virtualization
Introduction to VirtualizationIntroduction to Virtualization
Introduction to VirtualizationMuhammadRizkyFaza
 
Joanna Rutkowska Subverting Vista Kernel
Joanna Rutkowska   Subverting Vista KernelJoanna Rutkowska   Subverting Vista Kernel
Joanna Rutkowska Subverting Vista Kernelguestf1a032
 

Similar to VM Forking & Hypervisor-based Fuzzing with Xen (20)

eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...
eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...
eFolder Expert Series Webinar - BDR Do's and Dont's: Featuring Andrew Bensing...
 
Venom vulnerability Overview and a basic demo
Venom vulnerability Overview and a basic demoVenom vulnerability Overview and a basic demo
Venom vulnerability Overview and a basic demo
 
Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...
Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...
Joyent's Bryan Cantrill: Experiences Porting KVM to SmartOS at KVM Forum, Aug...
 
Experiences porting KVM to SmartOS
Experiences porting KVM to SmartOSExperiences porting KVM to SmartOS
Experiences porting KVM to SmartOS
 
Windows 7 professional Vs Windows 7 enterprise
Windows 7 professional Vs Windows 7 enterpriseWindows 7 professional Vs Windows 7 enterprise
Windows 7 professional Vs Windows 7 enterprise
 
Fuzzing_with_Xen.pdf
Fuzzing_with_Xen.pdfFuzzing_with_Xen.pdf
Fuzzing_with_Xen.pdf
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
virtual machine.ppt
virtual machine.pptvirtual machine.ppt
virtual machine.ppt
 
ZertoCON_Support_Toolz.pdf
ZertoCON_Support_Toolz.pdfZertoCON_Support_Toolz.pdf
ZertoCON_Support_Toolz.pdf
 
Hypervisors
HypervisorsHypervisors
Hypervisors
 
Auto Deploy Deep Dive – vBrownBag Style
Auto Deploy Deep Dive – vBrownBag StyleAuto Deploy Deep Dive – vBrownBag Style
Auto Deploy Deep Dive – vBrownBag Style
 
Opening last bits of the infrastructure
Opening last bits of the infrastructureOpening last bits of the infrastructure
Opening last bits of the infrastructure
 
Kvm virtualization in_rhel_7
Kvm virtualization in_rhel_7Kvm virtualization in_rhel_7
Kvm virtualization in_rhel_7
 
Distro Recipes 2013: Secure Boot and Linux: several issues, one solution
Distro Recipes 2013: Secure Boot and Linux: several issues, one solutionDistro Recipes 2013: Secure Boot and Linux: several issues, one solution
Distro Recipes 2013: Secure Boot and Linux: several issues, one solution
 
003-vmm.pptx
003-vmm.pptx003-vmm.pptx
003-vmm.pptx
 
Project ACRN Device Passthrough Introduction
Project ACRN Device Passthrough IntroductionProject ACRN Device Passthrough Introduction
Project ACRN Device Passthrough Introduction
 
Good virtual machines
Good virtual machinesGood virtual machines
Good virtual machines
 
XPDS14 - Xen in EFI World - Daniel Kiper, Oracle
XPDS14 - Xen in EFI World - Daniel Kiper, OracleXPDS14 - Xen in EFI World - Daniel Kiper, Oracle
XPDS14 - Xen in EFI World - Daniel Kiper, Oracle
 
Introduction to Virtualization
Introduction to VirtualizationIntroduction to Virtualization
Introduction to Virtualization
 
Joanna Rutkowska Subverting Vista Kernel
Joanna Rutkowska   Subverting Vista KernelJoanna Rutkowska   Subverting Vista Kernel
Joanna Rutkowska Subverting Vista Kernel
 

More from Tamas K Lengyel

Estimating Security Risk Through Repository Mining
Estimating Security Risk Through Repository MiningEstimating Security Risk Through Repository Mining
Estimating Security Risk Through Repository MiningTamas K Lengyel
 
Hacktivity 2016: Stealthy, hypervisor based malware analysis
Hacktivity 2016: Stealthy, hypervisor based malware analysisHacktivity 2016: Stealthy, hypervisor based malware analysis
Hacktivity 2016: Stealthy, hypervisor based malware analysisTamas K Lengyel
 
Anti-evil maid with UEFI and Xen
Anti-evil maid with UEFI and XenAnti-evil maid with UEFI and Xen
Anti-evil maid with UEFI and XenTamas K Lengyel
 
Stealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisStealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisTamas K Lengyel
 
Malware Collection and Analysis via Hardware Virtualization
Malware Collection and Analysis via Hardware VirtualizationMalware Collection and Analysis via Hardware Virtualization
Malware Collection and Analysis via Hardware VirtualizationTamas K Lengyel
 
CyberSEED: Virtual Machine Introspection to Detect and Protect
CyberSEED: Virtual Machine Introspection to Detect and ProtectCyberSEED: Virtual Machine Introspection to Detect and Protect
CyberSEED: Virtual Machine Introspection to Detect and ProtectTamas K Lengyel
 
Troopers15 Lightning talk: VMI & DRAKVUF
Troopers15 Lightning talk: VMI & DRAKVUFTroopers15 Lightning talk: VMI & DRAKVUF
Troopers15 Lightning talk: VMI & DRAKVUFTamas K Lengyel
 
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and CloningNSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and CloningTamas K Lengyel
 
Virtual Machine Introspection in a Hyberid Honeypot Architecture
Virtual Machine Introspection in a Hyberid Honeypot ArchitectureVirtual Machine Introspection in a Hyberid Honeypot Architecture
Virtual Machine Introspection in a Hyberid Honeypot ArchitectureTamas K Lengyel
 
Dfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopDfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopTamas K Lengyel
 

More from Tamas K Lengyel (10)

Estimating Security Risk Through Repository Mining
Estimating Security Risk Through Repository MiningEstimating Security Risk Through Repository Mining
Estimating Security Risk Through Repository Mining
 
Hacktivity 2016: Stealthy, hypervisor based malware analysis
Hacktivity 2016: Stealthy, hypervisor based malware analysisHacktivity 2016: Stealthy, hypervisor based malware analysis
Hacktivity 2016: Stealthy, hypervisor based malware analysis
 
Anti-evil maid with UEFI and Xen
Anti-evil maid with UEFI and XenAnti-evil maid with UEFI and Xen
Anti-evil maid with UEFI and Xen
 
Stealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisStealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware Analysis
 
Malware Collection and Analysis via Hardware Virtualization
Malware Collection and Analysis via Hardware VirtualizationMalware Collection and Analysis via Hardware Virtualization
Malware Collection and Analysis via Hardware Virtualization
 
CyberSEED: Virtual Machine Introspection to Detect and Protect
CyberSEED: Virtual Machine Introspection to Detect and ProtectCyberSEED: Virtual Machine Introspection to Detect and Protect
CyberSEED: Virtual Machine Introspection to Detect and Protect
 
Troopers15 Lightning talk: VMI & DRAKVUF
Troopers15 Lightning talk: VMI & DRAKVUFTroopers15 Lightning talk: VMI & DRAKVUF
Troopers15 Lightning talk: VMI & DRAKVUF
 
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and CloningNSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
 
Virtual Machine Introspection in a Hyberid Honeypot Architecture
Virtual Machine Introspection in a Hyberid Honeypot ArchitectureVirtual Machine Introspection in a Hyberid Honeypot Architecture
Virtual Machine Introspection in a Hyberid Honeypot Architecture
 
Dfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopDfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshop
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

VM Forking & Hypervisor-based Fuzzing with Xen

  • 1. VM Forking & Hypervisor-based Fuzzing with Xen Open Source Summit Europe 2020 Tamas K Lengyel
  • 2. 2 Notices & Disclaimers Intel technologies may require enabled hardware, software or service activation. No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document. Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade. The products described may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request. You may not use or facilitate the use of this document in connection with any infringement or other legal analysis concerning Intel products described herein. You agree to grant Intel a non-exclusive, royalty-free license to any patent claim thereafter drafted which includes subject matter disclosed herein. Intel does not control or audit third-party data. You should consult other sources to evaluate accuracy. No product or component can be absolutely secure. Your costs and results may vary. © Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others.
  • 3. 3 # whoami • Senior Security Research @ Intel • Maintainer of Xen’s introspection subsystem • Maintainer of LibVMI • Hypervisor agnostic introspection library (Xen, KVM, etc) • Lot’s of convenient APIs to do introspection with • Background in malware research & black-box binary analysis
  • 4. 4 Outline 1. Intro & Motivation 2. VM introspection 3. VM forking nuts & bolts 4. Fuzzing on Xen • Harnessing & coverage tracing • VMs with PCI-passthrough (IOMMU) devices • Doublefetch detection
  • 5. 5 Motivation • Time-tested approach to software validation • Conceptually straight-forward • In practice can be difficult depending on what you want to fuzz • How do you create coverage trace for the kernel? • How do you recover fast enough for fuzzing to be effective? • How do you ensure system is in the proper state? • How do you fuzz kernel-internal interfaces? • How do you detect more then just “crashes”?
  • 6. 6 Kernel fuzzers do exist • syzkaller • Linux syscall fuzzer with built-in coverage guidance • kAFL • KVM based using AFL, coverage via Intel PT & PML • Chocolate milk • Custom bootloader & hypervisor, all in rust
  • 7. 7 Why make another one? • These platforms are tightly coupled to their use-case • We wanted something stable but also flexible to build on • Preferring code that’s upstream to cut down on time it takes to maintain custom patches & debugging things when they break • Xen’s VMI subsystem is still experimental but fits the bill • Also allows us to consider new types of fuzzing approaches • Also allows us to target new use-cases
  • 8. 8 VM introspection • Inspect VM internals from an external perspective • Very similar to kernel debugging & memory forensics • We can pause the VM at any event that traps to the VMM • EPT faults • Breakpoints • CPUID • Singlestep (MTF) • Can do it both with in-guest help or without
  • 9. 9 Why VM forking? • We need a way to restore VMs to a start point quickly after each fuzz cycle • Restoring from a save-file can take up to 2s • Even from a fast SSD or tmpfs • Fuzzing to be effective we need to be faster than that • Xen has a long-forgotten, half abandoned subsystem: • Memory sharing! • We can use it to create forks in a fast & lightweight manner!
  • 10. 10 VM forking overview 1. Create VM with an empty EPT (ie. no memory) 2. Specify its parent VM 3. Copy vCPU parameters from parent 4. When VM is started it will page-fault back to Xen each time it tries to access memory not yet mapped 5. Populate pages on-demand in the page-fault handler • Read & execute accesses are populated with a shared entry • Write accesses are deduplicated
  • 11. 11 VM forking details • It’s a bit different then fork() on Linux • The parent domain currently remains paused while forks are active • This was fine for our use-case • For a full domain split, all the parent pages need to be made shared • Pages that can’t be made shared would need an extra copy • Doable, was out-of-scope for now • Forks can be further forked! • Pages are searched for recursively
  • 12. 12 VM forking details • VM forks can run with only CPU & memory • No disk • No networking • No I/O • No interrupts! • It’s possible to launch QEMU to start backend services • Patches implementing this are posted but not yet upstream • Launching & resetting QEMU is slow • Not a priority since it’s not required for fuzzing
  • 13. 13 VM forks: resetting • No need to keep creating forks for every fuzz iteration • We can just reset a previously forked VM • Re-copy vCPU settings from parent • Keep memory shared entries in place • Future iterations will be that much faster • Throw-away deduplicated memory • Reset speed depends on how much memory needs to be freed here • During fuzzing it’s usually very few pages
  • 14. 14 VM forking speed VM fork creation time: ~745 μs ~= 1300 VM/s VM fork reset time: ~111 μs ~= 9000 reset/s Measured on i5-8350U
  • 15. 15 Harnessing • Fuzzer needs to know where the target code starts & stops • Need to manually mark it • Harness needs to trap to the hypervisor • Should not have side-effects • Code needs to execute normally between start & stop harness • Code needs to consume some input • We need to know where the input is so we can fuzz it
  • 16. 16 Harnessing CPUID instruction always traps to VMM We use a magic CPUID leaf as our mark No side-effect on target code, without the fuzzer this is effectively a NOP Call harness() before and after target code Just printk info before the first harness!
  • 17. 17 Harnessing • Parent VM will display information about target (buffer address) on its virtual serial console that we’ll fuzz • Parent VM will trap to the VMM on CPUID • Detect if it’s the start signal (magic value) and pause Parent VM • Increments IP so vCPU will be next starting just after the CPUID
  • 18. 18 Coverage tracing • Fuzzer (AFL) needs to know when new code-paths are discovered • By default AFL requires you to recompile your target • Instruments each branch with hooks • We don’t want to recompile the whole kernel • We want to minimize the modifications we make to the target • Just adding the calls to harness() and displaying relevant information • During fuzzing code will run in a VM fork & the only visibility we have is when it traps to VMM
  • 19. 19 Coverage tracing with VMI • We can read & write to the VM forks memory from the VMM! 1. Configure VM fork to trap breakpoints to the VMM 2. Read & disassemble code from start point (RIP) 3. Find next control-flow instruction 4. Replace it with breakpoint 5. Resume vCPU 6. Breakpoint traps, remove breakpoint and enable singlestep (MTF) 7. MTF traps, disable MTF, goto Step 2 • Works in nested setups as well (tested with Xen inside VMware)!
  • 20. 20 Detecting crashes • Breakpoint the kernel’s crash handlers • Defined as “sink” points • Breakpoints trap to the hypervisor, if any of them execute report “crash” • Good base targets to sink: • panic() • oops_begin() • page_fault() or it’s new name asm_exc_page_fault()
  • 21. 21 Putting it all together 1. Setup parent VM: trap on first call to harness() 2. Create first fork: breakpoint the sinks 3. Create second fork: fuzz, execute & collect coverage trace! Parent VM -> Sink VM -> Fuzz VM
  • 23. 23 Coverage tracing with Intel Processor Trace • Disassembly, breakpoint & singlestep is expensive • We can go faster if the silicon collects the info for us • Designate memory location (up to 4GB) as PT buffer • VM forks’ execution will be recorded there • Need to decode custom PT buffer format to reconstruct coverage • Can be tedious and existing decoders not designed for high-speed fuzzing • Open Source community to the rescue: https://github.com/nyx-fuzz/libxdc • Does not work in nested setup, only single address-space
  • 24. 24 AFL + PT demo
  • 25. 25 Alternative harnessing • What if we can’t recompile our target to add the harness()? • We can use a debugger to add breakpoints as our harness! • Run with GDB, set breakpoint before & after target code • Fuzzer needs to know original instruction before it was breakpointed (really just the first byte) • When breakpoint traps to the VMM, replace breakpoint with original content • Fuzz!
  • 27. 27 PCI-passthrough devices & fuzzing • Making sure your target code is in the right state can be difficult • Kernel modules may only fully initialize if physical device is present • We can attach device to parent VM! • Kernel module fully initializes & actively drives device • Harness & fork works just the same! • Only parent VM has access to device • VM fork can’t corrupt device • VM fork can’t access the device
  • 29. 29 Detecting doublefetches • We can define any condition as a “crash” • Detecting doublefetch conditions is very difficult • Sometimes introduced by the compiler so source review is not sufficient • We are already hooked into the VMM pagefault handler • We can detect doublefetches using EPT 1. Remove R/W permissions from page suspected of being doublefetched from 2. When an access faults, record page offset, reset permission & singlestep 3. In singlestep handler remove permissions & continue 4. If next access fault is at the same offset: doublefetch detected!
  • 31. 31 Code released as open-source (MIT) VM forking is upstream in Xen 4.14 Kernel Fuzzer for Xen Project (kfx): https://github.com/intel/kernel-fuzzer-for-xen-project
  • 32. 32 Thanks! Questions? Comments? tamas.lengyel@intel.com @tklengyel Special thanks to the following people for their significant help: Andrew Cooper, @buherator, @icedevml, @0xTony, @poeplau, @proskurinserg, @is_eqv, @ms_s3c
  • 33. 33