SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
A look at live patching
It’s 2021. Why are we
still rebooting for
patches?
Live Patching - How it started
● In 2006, Jeff Arnold, a student at MIT, started working on what would
eventually become ksplice
● A way to apply changes, specifically security patches, to running
Linux kernels without interrupting processes or users
● The motivation was a hacked system while a patch existed but
couldn’t be applied in a timely fashion
Live Patching - 15 years gone by, the
same problem exists
● Deploying security patches on time is still heavily
constrained by the availability of maintenance
windows
● Patches for Critical or High-Priority
vulnerabilities take, on average, 5 to 6 weeks to
be deployed*
● That is a very large window of opportunity for
malicious actors
* “State of Enterprise Linux Security Management v2” - A study conducted by the
Ponemom Institute, targeting IT leaders across different industries. This will be
freely available for download at blog.tuxcare.com and other locations in the
coming days.
The underlying issue
● The way patch operations are done has not changed, even when
the technology available has
● The rate at which new vulnerabilities appear has been steadily
growing year-on-year
● System downtime is one of the big friction points between IT teams
and other business units
Compliance rules are changing
• 30 days patch window is a "best
practice" today
o Shrunk from 6 months, to 3 months, to 1 month
within a decade
• Ransomware attacks are causing people
to start questioning if that window is too
long
Live patching to the rescue
● Live patching is a better way to
deploy patches
● This was recognized by different
teams when kSplice was acquired
and became focused solely on
Oracle’s own distribution
● Three new projects, kPatch, kGraft
and KernelCare, were started as
alternatives
The patches
● Replacing running code is not trivial, but simple function code changes
are easier than bigger changes touching multiple functions
● Most vulnerabilities are fixed with one-liners: bounds-check, off-by-one,
input validation
● As long as function signatures or data structures don’t change, live
patching is easier
The different Kernel facilities for Live Patching
● There are usually multiple ways to do
something in the Linux Kernel
● Live patching follows this trend:
○ Livepatch - patch creation/loading
○ Ftrace - tracing/debugging tool
repurposed to aid live patching by
adding custom code at specific
instructions
○ Kprobes - debugging tool repurposed to
aid live patching with breakpoints in
specific functions
○ eBPF - A mechanism to attach logic at
certain hook points in the kernel
Ftrace
● Tracing mechanism originally built to help
developers writing code for the Kernel
● With it, you can add custom code
handlers that run whenever a specific
instruction is reached
● It can be used to redirect execution away
from the “bad” function to the “corrected”
version
Kprobes
● Generic way of adding breakpoints at any instruction
● By setting the breakpoint at strategic locations before applying a patch, you
can check if the function you want to change is in use (for example, by
checking the stack)
● It’s desirable that the function being patched is not in use. Some tools will wait
for the right opportunity to apply a live patch
For more information: https://www.kernel.org/doc/html/latest/livepatch/livepatch.html
How they all work together (or not)
● The most common way to use them is adding kprobe’s breakpoints inside of ftrace
handler code at the start of the functions you want to change, then using livepatch to
load the fixed code into the kernel memory space
● Some of their functionality conflicts with each other (some ftrace instructions can be
overwritten by some livepatch calls, for example)
● Kprobes and ftrace are repurposed kernel facilities, not designed with live patching in
mind
● Third-party live patching solutions will often have their own custom ways for achieving
live patching
Livepatch
● Eventually, the kPatch and kGraft project’s common features were merged
into “livepatch” and included in the Linux Kernel
● Livepatch contains basic functionality for live patch creation and loading
● Some third-party tools for live patching use livepatch functionality, while
others have opted for their own implementation to achieve the same goal
For more information: https://www.kernel.org/doc/html/latest/livepatch/livepatch.html
Patches - How they are created
● Like “regular” patches, it all starts with the code
that fixes the problem
● Live patching specific issues are addressed:
function signature changes, data structure
changes, non maskable interrupts. These are
some of the new concerns when creating these
patches
● A binary “diff” between the running code and the
new code has to be created and packaged in such
a way that it can be deployed on different systems
Consistency model
● The code execution should be in a “safe” situation before applying a patch
● You don’t want to replace a function when it’s in use, or active locks are
originating from it, or memory assignments are not yet released
● Live patching tools will have mechanisms that “wait” for this safe situation to
appear, and may even refuse to apply a patch if they can’t find one
● Maintaining consistency is one of the trickier parts of the process
For more information: https://www.kernel.org/doc/html/latest/livepatch/livepatch.html#consistency-model
Build environments
● Tiny differences in build environments can create big changes in binary outputs
● This means that binary “diffs” will be unusable
● Compiler, linker, and binutils changes like different versions or flags will all likely
invalidate patch creation
● Every different kernel version or distribution supported by a live patching tool
requires a different build environment
Testing
● Live patches, like traditional patches, need to be tested
● Not just for actually fixing what they are supposed to fix, but also for
unexpected side-effects of being deployed live
● It’s desirable to use extensive test automation when creating live patches and
to continually expand the tests with validation for every new fix introduced
● Traditional Kernel tests* often not suitable for live patching integration
*For more information: https://www.kernel.org/doc/html/latest/dev-tools/testing-overview.html
Patch creation
Loading into kernel memory space with a live patching
provider-specific tool
Enabling/activating the patch
Maintaining the consistency of the kernel, the live patching tool will probably:
Pause the process briefly
Check if the function is in use or not
If it’s safe, apply the code change to redirect the function to the new code. If not, retry later.
Unpause the process
Disabling/removing the patch
Lifetime of a life patch
Other ways to 'update'
kernel without reboot
● Kexec lets you replace the running
kernel with another
○ Requires a whole new kernel to be loaded
and restarts the existing user space
processes
What about userspace?
Patching one running process should be the same no
matter what that process is
Except:
● coroutines / schedulers need to be taken into account
● stack usage (exceptions?) need to be taken into account
Services like databases or libraries
like OpenSSL, glibc & QEMU would
benefit from live patching.
Creating a patch - Example (1/5)
For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”)
Original code Patched code
Creating a patch - Example (2/5)
We want to compare the
assembly code obtained
through:
For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”)
Looking at the changes
with diff, we can see
the added text and the
code changes.
Creating a patch - Example (3/5)
Every live patching solution has its own scripts to
aid in patch creation, and so does TuxCare’s. We
use “kpatch_gensrc” to create a patch file from the
binary diff:
This will create a very long file with assembly code
and special sections for the patch deployment tool.
You can find the complete output at the github
repository linked below.
For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”)
(...)
Creating a patch - Example (4/5)
Now moving from assembly to the
compiled code, using the special linker
flag “-q” to store relocation information:
For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”)
There is still a process for fixing relocations
that is detailed in the github repository and
not shown here. After that is done, the
binary patch is finally obtained with:
Some clean up is still needed:
Creating a patch - Example (5/5)
Applying the patch:
For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”)
Note that the actual file on disk for the original process has not been touched, so
that a restart would bring back the original behavior.
Changing the status quo
● IT is usually very fast at adopting new
technologies but rather slow at changing
processes
● Live patching is reliable and proven —
and a better way to deploy patches
● It doesn’t just shorten maintenance
windows — it completely eliminates
their use for patching
Get in touch:
Thank you!
i@tuxcare.com
@iseletsk

Mais conteúdo relacionado

Mais procurados

WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?
Weaveworks
 
A Reference Architecture to Enable Visibility and Traceability across the Ent...
A Reference Architecture to Enable Visibility and Traceability across the Ent...A Reference Architecture to Enable Visibility and Traceability across the Ent...
A Reference Architecture to Enable Visibility and Traceability across the Ent...
CollabNet
 
Build your android app with gradle
Build your android app with gradleBuild your android app with gradle
Build your android app with gradle
Swain Loda
 
Preventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source SoftwarePreventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source Software
All Things Open
 

Mais procurados (20)

Gerrit linuxtag2011
Gerrit linuxtag2011Gerrit linuxtag2011
Gerrit linuxtag2011
 
Intro to Git: a hands-on workshop
Intro to Git: a hands-on workshopIntro to Git: a hands-on workshop
Intro to Git: a hands-on workshop
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog Artifactory
 
WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?
 
Agnostic Continuous Delivery
Agnostic Continuous DeliveryAgnostic Continuous Delivery
Agnostic Continuous Delivery
 
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2
 
A Reference Architecture to Enable Visibility and Traceability across the Ent...
A Reference Architecture to Enable Visibility and Traceability across the Ent...A Reference Architecture to Enable Visibility and Traceability across the Ent...
A Reference Architecture to Enable Visibility and Traceability across the Ent...
 
JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...
JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...
JavaCro'14 - Continuous delivery of Java EE applications with Jenkins and Doc...
 
Writing Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfWriting Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future Self
 
CI is dead, long live CI
CI is dead, long live CICI is dead, long live CI
CI is dead, long live CI
 
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
PuppetConf 2016: Using Puppet with Kubernetes and OpenShift – Diane Mueller, ...
 
Embracing Observability in CI/CD with OpenTelemetry
Embracing Observability in CI/CD with OpenTelemetryEmbracing Observability in CI/CD with OpenTelemetry
Embracing Observability in CI/CD with OpenTelemetry
 
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
CI and CD Across the Enterprise with Jenkins (devops.com Nov 2014)
 
Build your android app with gradle
Build your android app with gradleBuild your android app with gradle
Build your android app with gradle
 
Preventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source SoftwarePreventing Supply Chain Attacks on Open Source Software
Preventing Supply Chain Attacks on Open Source Software
 
Dev ops using Jenkins
Dev ops using JenkinsDev ops using Jenkins
Dev ops using Jenkins
 
Jenkins Reviewbot
Jenkins ReviewbotJenkins Reviewbot
Jenkins Reviewbot
 
Gerrit Workshop
Gerrit WorkshopGerrit Workshop
Gerrit Workshop
 
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
MJC 2021: "Debugging Java Microservices Running on Kubernetes with Telepresence"
 
Building a Service Delivery Platform - JCICPH 2014
Building a Service Delivery Platform - JCICPH 2014Building a Service Delivery Platform - JCICPH 2014
Building a Service Delivery Platform - JCICPH 2014
 

Semelhante a It’s 2021. Why are we -still- rebooting for patches? A look at Live Patching.

Don't Fear the Autotools
Don't Fear the AutotoolsDon't Fear the Autotools
Don't Fear the Autotools
Scott Garman
 
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
ICS
 

Semelhante a It’s 2021. Why are we -still- rebooting for patches? A look at Live Patching. (20)

Don't Fear the Autotools
Don't Fear the AutotoolsDon't Fear the Autotools
Don't Fear the Autotools
 
Build and deploy scientific Python Applications
Build and deploy scientific Python Applications  Build and deploy scientific Python Applications
Build and deploy scientific Python Applications
 
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
 
ELC-E 2016 Neil Armstrong - No, it's never too late to upstream your legacy l...
ELC-E 2016 Neil Armstrong - No, it's never too late to upstream your legacy l...ELC-E 2016 Neil Armstrong - No, it's never too late to upstream your legacy l...
ELC-E 2016 Neil Armstrong - No, it's never too late to upstream your legacy l...
 
Programming Sessions KU Leuven - Session 01
Programming Sessions KU Leuven - Session 01Programming Sessions KU Leuven - Session 01
Programming Sessions KU Leuven - Session 01
 
DevOps presentation
DevOps presentationDevOps presentation
DevOps presentation
 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdf
 
jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.pdf
 
Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?
 
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
 
7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users7 Habits of Highly Effective Jenkins Users
7 Habits of Highly Effective Jenkins Users
 
The 10 Commandments of Release Engineering
The 10 Commandments of Release EngineeringThe 10 Commandments of Release Engineering
The 10 Commandments of Release Engineering
 
Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?Why is .Net Technology Recognised for Software Development?
Why is .Net Technology Recognised for Software Development?
 
LCE13: Test and Validation Summit: The future of testing at Linaro
LCE13: Test and Validation Summit: The future of testing at LinaroLCE13: Test and Validation Summit: The future of testing at Linaro
LCE13: Test and Validation Summit: The future of testing at Linaro
 
LCE13: Test and Validation Mini-Summit: Review Current Linaro Engineering Pro...
LCE13: Test and Validation Mini-Summit: Review Current Linaro Engineering Pro...LCE13: Test and Validation Mini-Summit: Review Current Linaro Engineering Pro...
LCE13: Test and Validation Mini-Summit: Review Current Linaro Engineering Pro...
 
Reproducibility in artificial intelligence
Reproducibility in artificial intelligenceReproducibility in artificial intelligence
Reproducibility in artificial intelligence
 
Version Uncontrolled - How to Manage Your Version Control (whitepaper)
Version Uncontrolled - How to Manage Your Version Control (whitepaper)Version Uncontrolled - How to Manage Your Version Control (whitepaper)
Version Uncontrolled - How to Manage Your Version Control (whitepaper)
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
Long Term Support the Eclipse Way
Long Term Support the Eclipse WayLong Term Support the Eclipse Way
Long Term Support the Eclipse Way
 
What is the merge window?
What is the merge window?What is the merge window?
What is the merge window?
 

Mais de All Things Open

Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public Policy
All Things Open
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
All Things Open
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart Contract
All Things Open
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with Background
All Things Open
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open Source
All Things Open
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in control
All Things Open
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
All Things Open
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
All Things Open
 

Mais de All Things Open (20)

Building Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityBuilding Reliability - The Realities of Observability
Building Reliability - The Realities of Observability
 
Modern Database Best Practices
Modern Database Best PracticesModern Database Best Practices
Modern Database Best Practices
 
Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public Policy
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
 
The State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil Nash
 
Total ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScript
 
What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart Contract
 
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 
DEI Challenges and Success
DEI Challenges and SuccessDEI Challenges and Success
DEI Challenges and Success
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with Background
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssembly
 
Using SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksUsing SQL to Find Needles in Haystacks
Using SQL to Find Needles in Haystacks
 
Configuration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptConfiguration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit Intercept
 
Scaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramScaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship Program
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open Source
 
Deploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamDeploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache Beam
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in control
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

It’s 2021. Why are we -still- rebooting for patches? A look at Live Patching.

  • 1. A look at live patching It’s 2021. Why are we still rebooting for patches?
  • 2. Live Patching - How it started ● In 2006, Jeff Arnold, a student at MIT, started working on what would eventually become ksplice ● A way to apply changes, specifically security patches, to running Linux kernels without interrupting processes or users ● The motivation was a hacked system while a patch existed but couldn’t be applied in a timely fashion
  • 3. Live Patching - 15 years gone by, the same problem exists ● Deploying security patches on time is still heavily constrained by the availability of maintenance windows ● Patches for Critical or High-Priority vulnerabilities take, on average, 5 to 6 weeks to be deployed* ● That is a very large window of opportunity for malicious actors * “State of Enterprise Linux Security Management v2” - A study conducted by the Ponemom Institute, targeting IT leaders across different industries. This will be freely available for download at blog.tuxcare.com and other locations in the coming days.
  • 4. The underlying issue ● The way patch operations are done has not changed, even when the technology available has ● The rate at which new vulnerabilities appear has been steadily growing year-on-year ● System downtime is one of the big friction points between IT teams and other business units
  • 5. Compliance rules are changing • 30 days patch window is a "best practice" today o Shrunk from 6 months, to 3 months, to 1 month within a decade • Ransomware attacks are causing people to start questioning if that window is too long
  • 6. Live patching to the rescue ● Live patching is a better way to deploy patches ● This was recognized by different teams when kSplice was acquired and became focused solely on Oracle’s own distribution ● Three new projects, kPatch, kGraft and KernelCare, were started as alternatives
  • 7. The patches ● Replacing running code is not trivial, but simple function code changes are easier than bigger changes touching multiple functions ● Most vulnerabilities are fixed with one-liners: bounds-check, off-by-one, input validation ● As long as function signatures or data structures don’t change, live patching is easier
  • 8. The different Kernel facilities for Live Patching ● There are usually multiple ways to do something in the Linux Kernel ● Live patching follows this trend: ○ Livepatch - patch creation/loading ○ Ftrace - tracing/debugging tool repurposed to aid live patching by adding custom code at specific instructions ○ Kprobes - debugging tool repurposed to aid live patching with breakpoints in specific functions ○ eBPF - A mechanism to attach logic at certain hook points in the kernel
  • 9. Ftrace ● Tracing mechanism originally built to help developers writing code for the Kernel ● With it, you can add custom code handlers that run whenever a specific instruction is reached ● It can be used to redirect execution away from the “bad” function to the “corrected” version
  • 10. Kprobes ● Generic way of adding breakpoints at any instruction ● By setting the breakpoint at strategic locations before applying a patch, you can check if the function you want to change is in use (for example, by checking the stack) ● It’s desirable that the function being patched is not in use. Some tools will wait for the right opportunity to apply a live patch For more information: https://www.kernel.org/doc/html/latest/livepatch/livepatch.html
  • 11. How they all work together (or not) ● The most common way to use them is adding kprobe’s breakpoints inside of ftrace handler code at the start of the functions you want to change, then using livepatch to load the fixed code into the kernel memory space ● Some of their functionality conflicts with each other (some ftrace instructions can be overwritten by some livepatch calls, for example) ● Kprobes and ftrace are repurposed kernel facilities, not designed with live patching in mind ● Third-party live patching solutions will often have their own custom ways for achieving live patching
  • 12. Livepatch ● Eventually, the kPatch and kGraft project’s common features were merged into “livepatch” and included in the Linux Kernel ● Livepatch contains basic functionality for live patch creation and loading ● Some third-party tools for live patching use livepatch functionality, while others have opted for their own implementation to achieve the same goal For more information: https://www.kernel.org/doc/html/latest/livepatch/livepatch.html
  • 13. Patches - How they are created ● Like “regular” patches, it all starts with the code that fixes the problem ● Live patching specific issues are addressed: function signature changes, data structure changes, non maskable interrupts. These are some of the new concerns when creating these patches ● A binary “diff” between the running code and the new code has to be created and packaged in such a way that it can be deployed on different systems
  • 14. Consistency model ● The code execution should be in a “safe” situation before applying a patch ● You don’t want to replace a function when it’s in use, or active locks are originating from it, or memory assignments are not yet released ● Live patching tools will have mechanisms that “wait” for this safe situation to appear, and may even refuse to apply a patch if they can’t find one ● Maintaining consistency is one of the trickier parts of the process For more information: https://www.kernel.org/doc/html/latest/livepatch/livepatch.html#consistency-model
  • 15. Build environments ● Tiny differences in build environments can create big changes in binary outputs ● This means that binary “diffs” will be unusable ● Compiler, linker, and binutils changes like different versions or flags will all likely invalidate patch creation ● Every different kernel version or distribution supported by a live patching tool requires a different build environment
  • 16. Testing ● Live patches, like traditional patches, need to be tested ● Not just for actually fixing what they are supposed to fix, but also for unexpected side-effects of being deployed live ● It’s desirable to use extensive test automation when creating live patches and to continually expand the tests with validation for every new fix introduced ● Traditional Kernel tests* often not suitable for live patching integration *For more information: https://www.kernel.org/doc/html/latest/dev-tools/testing-overview.html
  • 17. Patch creation Loading into kernel memory space with a live patching provider-specific tool Enabling/activating the patch Maintaining the consistency of the kernel, the live patching tool will probably: Pause the process briefly Check if the function is in use or not If it’s safe, apply the code change to redirect the function to the new code. If not, retry later. Unpause the process Disabling/removing the patch Lifetime of a life patch
  • 18. Other ways to 'update' kernel without reboot ● Kexec lets you replace the running kernel with another ○ Requires a whole new kernel to be loaded and restarts the existing user space processes
  • 19. What about userspace? Patching one running process should be the same no matter what that process is Except: ● coroutines / schedulers need to be taken into account ● stack usage (exceptions?) need to be taken into account Services like databases or libraries like OpenSSL, glibc & QEMU would benefit from live patching.
  • 20. Creating a patch - Example (1/5) For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”) Original code Patched code
  • 21. Creating a patch - Example (2/5) We want to compare the assembly code obtained through: For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”) Looking at the changes with diff, we can see the added text and the code changes.
  • 22. Creating a patch - Example (3/5) Every live patching solution has its own scripts to aid in patch creation, and so does TuxCare’s. We use “kpatch_gensrc” to create a patch file from the binary diff: This will create a very long file with assembly code and special sections for the patch deployment tool. You can find the complete output at the github repository linked below. For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”) (...)
  • 23. Creating a patch - Example (4/5) Now moving from assembly to the compiled code, using the special linker flag “-q” to store relocation information: For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”) There is still a process for fixing relocations that is detailed in the github repository and not shown here. After that is done, the binary patch is finally obtained with: Some clean up is still needed:
  • 24. Creating a patch - Example (5/5) Applying the patch: For more information and the complete test example: https://github.com/cloudlinux/libcare/blob/master/docs/internals.rst (under “Manual patch Creation”) Note that the actual file on disk for the original process has not been touched, so that a restart would bring back the original behavior.
  • 25. Changing the status quo ● IT is usually very fast at adopting new technologies but rather slow at changing processes ● Live patching is reliable and proven — and a better way to deploy patches ● It doesn’t just shorten maintenance windows — it completely eliminates their use for patching
  • 26. Get in touch: Thank you! i@tuxcare.com @iseletsk