SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
LIVE PATCHING THE XEN PROJECT HYPERVISOR
Ross Lagerwall (Citrix)
FOSDEM 2017
Introduction
Xen supports live migration — so why live patch?
VM is using a pass-through device.
Live migration downtime is too long.
To avoid host downtime.
Not enough spare resources to move all VMs off the host.
There are several good reasons to live patch the hypervisor!
Patching basics
Inline replacement of hypervisor code would be possible but
not necessarily practical.
We replace old functions with new functions instead.
Xen Live Patch has a function-level granularity.
Payloads
A payload is a set of replacement functions plus metadata.
It is packaged in a relocatable object le, like a kernel module.
Since the module is relocatable, all the symbols need to be
resolved.
Xen has a simple linker to do this while loading the payload.
Plus a whole lot more: perform relocations, apply alternative
instructions, and parse the replacement table, hook
functions, and bug and exception frames.
Stacking payloads
Payloads are speci c to a particular build of the hypervisor.
They depend on the exact hypervisor internal ABI — not
stable.
The hypervisor and each live patch contains a build-id.
Each payload is designed to be applied on top of a speci c
build-id to prevent applying a patch on the wrong base.
This model allows loading a stack of patches.
Applying payloads
A loaded payload needs to be applied to take effect.
To avoid modifying code while it is being executed, the system
is quiesced.
We check in the return-to-guest path if any live patches need
to be applied.
At this point, there is a xed, small subset of functions that
could be on the stack.
Hypervisor interface
The sysctl hypercall was extended with four new sub-
operations for:
Uploading a payload
Listing payloads
Querying a payload state
Sending a command to apply, revert or unload a payload
The new sub-operations are controllable through XSM.
The xen-livepatch tool is used to access this functionality.
Compared with Linux live patching
Latency for VMs is not usually that critical so we don't use
kGraft's model.
Xen's model is largely similar to kPatch but there is no need
to perform stack checking.
Xen does not have ftrace and is not compiled with -pg to
get mcount() calls so the start of the function is
overwritten.
Can patch any function which is at least 5 bytes long.
Overhead is a single unconditional jump.
Building live patches
How are these created?
Build them by hand? — NO!
Enter livepatch-build-tools!
livepatch-build-tools is based on kpatch-build
http://xenbits.xen.org/gitweb/?p=livepatch-build-tools.git
Building live patches: Inputs
$ livepatch­build ­s xen ­c orig.config 
    ­­depends 55776af8c7377e7191d733797543b87a59631c50 
    ­p xsa182.patch ­o outdir
Takes as input:
The exact source tree from the running Xen.
The .con g from the original build of Xen.
A build-id onto which the livepatch will be applied.
A source patch.
Building live patches: Process
livepatch-build does:
1. Build Xen
2. Apply the source patch
3. Build Xen with "-ffunction-sections -fdata-sections"
4. Revert the source patch
5. Build Xen again with "-ffunction-sections -fdata-sections"
6. Create a livepatch from the changed object les.
For each pair of changed objects, ‘original’ and ‘patched’, run
:
Building live patches: Diff
create-diff-tool
Load objects and check that the headers match.
Adjust the ELFs to make them easier to process.
Correlate sections, symbols, and static locals.
Compare and mark as SAME, CHANGED or NEW.
For each CHANGED function or NEW global, include it and
its references recursively.
Building live patches: Diff
Handle special sections (bug frames, altinstructions,
exception tables).
For each CHANGED function, create an entry in a special
livepatch section (.livepatch.funcs).
Write out the new object le.
Link each object le together into a relocatable module.
Handling live patches with data
New data and read-only data is handled correctly.
Changing initialized data or existing data structures is hard
so such changes are prevented.
Hook functions allow code to be executed at various stages
during the patch apply (or revert) process.
Allows data to be transformed during patch apply, even if
the data is dynamically allocated
Allows once-off initializations.
Use shadow variables to attach new members to existing
data structures.
Compared with Linux live patching
Linux live patches are contained in modules.
Xen does not support loadable modules which avoids many
issues.
kGraft does not use a tool to automatically create live
patches.
kpatch is moving towards not using kpatch-build.
Future Work
Support for handling NMIs and MCEs while
applying/reverting payloads.
Support for signing payloads similarly to how kernel
modules can be signed.
This would make it more dif cult to load a malicious
module.
Add OSStest support.
Remove the experimental tag.

Mais conteúdo relacionado

Mais de The Linux Foundation

Mais de The Linux Foundation (20)

ELC2019: Static Partitioning Made Simple
ELC2019: Static Partitioning Made SimpleELC2019: Static Partitioning Made Simple
ELC2019: Static Partitioning Made Simple
 
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
XPDDS19: How TrenchBoot is Enabling Measured Launch for Open-Source Platform ...
 
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
XPDDS19 Keynote: Xen in Automotive - Artem Mygaiev, Director, Technology Solu...
 
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
XPDDS19 Keynote: Xen Project Weather Report 2019 - Lars Kurth, Director of Op...
 
XPDDS19 Keynote: Unikraft Weather Report
XPDDS19 Keynote:  Unikraft Weather ReportXPDDS19 Keynote:  Unikraft Weather Report
XPDDS19 Keynote: Unikraft Weather Report
 
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
XPDDS19 Keynote: Secret-free Hypervisor: Now and Future - Wei Liu, Software E...
 
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxXPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
 
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
XPDDS19 Keynote: Patch Review for Non-maintainers - George Dunlap, Citrix Sys...
 
XPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender
XPDDS19: Memories of a VM Funk - Mihai Donțu, BitdefenderXPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender
XPDDS19: Memories of a VM Funk - Mihai Donțu, Bitdefender
 
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng...
OSSJP/ALS19:  The Road to Safety Certification: Overcoming Community Challeng...OSSJP/ALS19:  The Road to Safety Certification: Overcoming Community Challeng...
OSSJP/ALS19: The Road to Safety Certification: Overcoming Community Challeng...
 
OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making...
 OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making... OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making...
OSSJP/ALS19: The Road to Safety Certification: How the Xen Project is Making...
 
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, CitrixXPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
 
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltdXPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd
XPDDS19: Keeping Coherency on Arm: Reborn - Julien Grall, Arm ltd
 
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...
XPDDS19: QEMU PV Backend 'qdevification'... What Does it Mean? - Paul Durrant...
 
XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D
XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&DXPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D
XPDDS19: Status of PCI Emulation in Xen - Roger Pau Monné, Citrix Systems R&D
 
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM SystemsXPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems
XPDDS19: [ARM] OP-TEE Mediator in Xen - Volodymyr Babchuk, EPAM Systems
 
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...
XPDDS19: Bringing Xen to the Masses: The Story of Building a Community-driven...
 
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
XPDDS19: Will Robots Automate Your Job Away? Streamlining Xen Project Contrib...
 
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
XPDDS19: Client Virtualization Toolstack in Go - Nick Rosbrook & Brendan Kerr...
 
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSEXPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

FOSDEM17 - Live patching the xen project hypervisor

  • 1. LIVE PATCHING THE XEN PROJECT HYPERVISOR Ross Lagerwall (Citrix) FOSDEM 2017
  • 2. Introduction Xen supports live migration — so why live patch? VM is using a pass-through device. Live migration downtime is too long. To avoid host downtime. Not enough spare resources to move all VMs off the host. There are several good reasons to live patch the hypervisor!
  • 3. Patching basics Inline replacement of hypervisor code would be possible but not necessarily practical. We replace old functions with new functions instead. Xen Live Patch has a function-level granularity.
  • 4. Payloads A payload is a set of replacement functions plus metadata. It is packaged in a relocatable object le, like a kernel module. Since the module is relocatable, all the symbols need to be resolved. Xen has a simple linker to do this while loading the payload. Plus a whole lot more: perform relocations, apply alternative instructions, and parse the replacement table, hook functions, and bug and exception frames.
  • 5. Stacking payloads Payloads are speci c to a particular build of the hypervisor. They depend on the exact hypervisor internal ABI — not stable. The hypervisor and each live patch contains a build-id. Each payload is designed to be applied on top of a speci c build-id to prevent applying a patch on the wrong base. This model allows loading a stack of patches.
  • 6. Applying payloads A loaded payload needs to be applied to take effect. To avoid modifying code while it is being executed, the system is quiesced. We check in the return-to-guest path if any live patches need to be applied. At this point, there is a xed, small subset of functions that could be on the stack.
  • 7.
  • 8. Hypervisor interface The sysctl hypercall was extended with four new sub- operations for: Uploading a payload Listing payloads Querying a payload state Sending a command to apply, revert or unload a payload The new sub-operations are controllable through XSM. The xen-livepatch tool is used to access this functionality.
  • 9. Compared with Linux live patching Latency for VMs is not usually that critical so we don't use kGraft's model. Xen's model is largely similar to kPatch but there is no need to perform stack checking. Xen does not have ftrace and is not compiled with -pg to get mcount() calls so the start of the function is overwritten. Can patch any function which is at least 5 bytes long. Overhead is a single unconditional jump.
  • 10. Building live patches How are these created? Build them by hand? — NO! Enter livepatch-build-tools! livepatch-build-tools is based on kpatch-build http://xenbits.xen.org/gitweb/?p=livepatch-build-tools.git
  • 11. Building live patches: Inputs $ livepatch­build ­s xen ­c orig.config      ­­depends 55776af8c7377e7191d733797543b87a59631c50      ­p xsa182.patch ­o outdir Takes as input: The exact source tree from the running Xen. The .con g from the original build of Xen. A build-id onto which the livepatch will be applied. A source patch.
  • 12. Building live patches: Process livepatch-build does: 1. Build Xen 2. Apply the source patch 3. Build Xen with "-ffunction-sections -fdata-sections" 4. Revert the source patch 5. Build Xen again with "-ffunction-sections -fdata-sections" 6. Create a livepatch from the changed object les.
  • 13. For each pair of changed objects, ‘original’ and ‘patched’, run : Building live patches: Diff create-diff-tool Load objects and check that the headers match. Adjust the ELFs to make them easier to process. Correlate sections, symbols, and static locals. Compare and mark as SAME, CHANGED or NEW. For each CHANGED function or NEW global, include it and its references recursively.
  • 14. Building live patches: Diff Handle special sections (bug frames, altinstructions, exception tables). For each CHANGED function, create an entry in a special livepatch section (.livepatch.funcs). Write out the new object le. Link each object le together into a relocatable module.
  • 15. Handling live patches with data New data and read-only data is handled correctly. Changing initialized data or existing data structures is hard so such changes are prevented. Hook functions allow code to be executed at various stages during the patch apply (or revert) process. Allows data to be transformed during patch apply, even if the data is dynamically allocated Allows once-off initializations. Use shadow variables to attach new members to existing data structures.
  • 16. Compared with Linux live patching Linux live patches are contained in modules. Xen does not support loadable modules which avoids many issues. kGraft does not use a tool to automatically create live patches. kpatch is moving towards not using kpatch-build.
  • 17. Future Work Support for handling NMIs and MCEs while applying/reverting payloads. Support for signing payloads similarly to how kernel modules can be signed. This would make it more dif cult to load a malicious module. Add OSStest support. Remove the experimental tag.