SlideShare a Scribd company logo
Live Patching Technology
Linux Kernel 4.0
SZ LIN
szlin@cs.nctu.edu.tw
1
Time for Kernel 4.0
2
Time for Kernel 4.0
3
4
Live Patching
0 down time.
Why you need Patch?
1 Bug Fixes
2
3
5
New Feature
Code Refactoring
Kernel update frequency
6
7
Live Patching Technology
Oracle - 2009
Ksplice
SUSE - 2014
kGraft
RedHat - 2014
Kpatch
8
9
kGraft & Kpatch
Ksplice & Kpatch
10
11
12
Ksplice License
GPLv2
13
Ksplice License
Oracle Patents
14
15
Ksplice behavior
Original Kernel Patched Kernel
16
Ksplice behavior
• foo method is updated
• Find foo in running kernel
• Find a safe time to insert jmp
17
Ksplice behavior
Limitation of Ksplice
1. Stop services < 1ms
2. Cannot patch common structures of kernel
3. Cannot patch common function (schedule, hrtimer)
Ksplice behavior
Building an update
Applying an update
Actions
18
 Match pre code to running kernel
1. Discover symbol values
2. Safety check
 Call stop_machine
1. Perform “safe time” check
2. Insert jmp instruction
 Find what has been changed
 Build pre and post source code to
get object code
 Compare to find the list of changed
functions
 Tell kernel to use new object code
 Ksplice.ko
 Load new object code
 Ksplice-new.ko
19
kGraft
kGraft
Target on…
not even for short time periods unlike
other technologies
Doesn't require stopping the kernel,
ever
1. kGraft patch can be built from C
source directly, without the need for
object code manipulation
2. Object-code based automated patch
generation is provided as an
alternative
Allows code review on kGraft
patch sources
Small amount of code thanks to
leveraging other Linux technologies,
no complex instruction decoders or
such
kGraft is lean
20
How does kGraft work?
1 A kGraft patch is a .ko kernel module in a KMP RPM
2 The .ko is inserted into the kernel using 'insmod' at RPM install or update time
3 kGraft replaces whole functions in the kernel
even while those functions may be executed
4 An updated kGraft RPM/module can replace an existing patch
21
kGraft
Limitations
1 kGraft is designed for fixing critical bugs
and thus primarily for simple changes
2 Changes in kernel data structure layout require special care
and depending on the size of the change, the change may not be possible to do without rebooting at all – same as with
other live patching tech
3 kGraft depends on a stable build environment
and thus best suited for Linux distributions, their customers or anyone who builds their own kernels, rather than 3 rd party
support companies
22
23
kGraft
1 INT3/IPI-NMI self-modifying code
2 RCU-like update mechanism
3 mcount-based NOP space allocation
4 standard kernel module loading/linking mechanisms
kGraft
Object Code Comparison
2 kernel compilations
 objcopy
 nm
 readelf
O/S tools
24
 With & without patch
 Compiler flags
1. ffunction-sections
2. fdata-sections
kGraft Behavior (1/7)
25
kGraft Behavior (2/7)
26
kGraft Behavior (3/7)
27
kGraft Behavior (4/7)
28
RCU-like replacement
kGraft Behavior (5/7)
29
RCU-like replacement
kGraft Behavior (6/7)
30
RCU-like replacement
kGraft Behavior (7/7)
31
32
kGraft
Toolbox
1 http://git.kernel.org/cgit/linux/kernel/git/jirislaby/kgraft.git/
2 http://github.com/useidel/kgraft-tools
33
Kpatch
Kpatch
What’s Kpatch?
 This applies a binary patch to kernel on-line
 Patching is done without shutdown
Kpatch is a LIVE patching function for kernel
 Security and stability fixes
 Not for major kernel update
Possible to fail patching with big patch
1. Constantly used system calls
2. Data structures
Only for a small and critical issues
34
Kpatch
Overview
35
 Kpatch build:
 Build a binary patch module
 Kpatch.ko:
 The kernel module of Kpatch
Kpatch
How to Patch
36
 Kpatch uses Ftrace to patch
1. Hook the target function entry with registers
2. Change regs->ip to new function (change the flow)
Kpatch
Conflict of Old and New Functions
37
 Kpatch ensures the old functions are not executed when patching
 “Active Safeness Check”
 Do stack dump to check the target functions are not executed, for each thread.
Kpatch
Active Safeness Check With Stop_machine
38
 Kpatch uses stop_machine to check stacks
Kpatch
Active Safeness Check With Stop_machine
39
Kpatch
Active Safeness Check With Stop_machine
40
Kpatch
Active Safeness Check With Stop_machine
41
Kpatch
Stop_machine: Pros and Cons
Pros
 Stop_machine stops all processes a while
 It is critical for control/network appliances
 In virtual environment, this takes longer
time
 We need to wait all VCPUs are scheduled on the
host machine
Cons
42
 Safe, simple and easy to review,
Good for the 1st version
Stop_machine-free kpatch is in discussion stage
 push current stop_machine-based kpatch to upstream
1 Human safety analysis required!
2 Not a general purpose upgrade tool
3
~80% of all CVE patches currently supported
1. Data structure changes, edge cases
2. Goal: 99%
4 stop_machine() latency: 1ms – 40ms
43
Kpatch
Limitations
Currently x86_64 only5
44
Kpatch
Toolbox
1 http://github.com/dynup/kpatch/
45
Conclusion
46
Conclusion
1 kGraft/ Kpatch
RCU/ stop_machine
2 Implemented for x86 only as a reference architecture
powerpc, s390 and arm is already in the works
3 Only for a small and critical issues
Not for major kernel update
4 Two groups got together
Combine kpatch and kGraft in the Linux Kernel 4.0 .
47
Thank you
48
References
Linux Kernel
https://www.kernel.org/
LWN
https://lwn.net/
LKML.ORG - the Linux Kernel Mailing List Archive
https://lkml.org/
Kgraft official site
https://www.suse.com/promo/kgraft.html
Kpatch official site
http://rhelblog.redhat.com/2014/02/26/kpatch/
https://github.com/dynup/kpatch
Kpslice – Oracle official site
http://www.ksplice.com/
Kpatch Without Stop Machine
Masami Hiramatsu
49
References
kpatch - Have your security and eat it too!
Josh Poimboeuf
Reboot adieu! Online Linux kernel patching
Udo Seidel
Oracle Ksplice for Oracle Linux
Ksplice-quickstart
Ksplice+ : Rebootless kernel updates in a distributed system
Sanjay Kulhari
KSPLICE: ZERO DOWNTIME UPDATES FOR ORACLE LINUX
ORACLE DATA SHEET
Note to Module Vendors With Respect to kGraft
SUSE SolidDriver Program
kGraft - Live patching of the Linux kernel
Vojtěch Pavlik
Ksplice: Automatic Rebootless Kernel Updates
Jeff Arnold and M. Frans Kaashoek

More Related Content

PDF
Linux Kernel Live Patching
GlobalLogic Ukraine
 
PDF
Intel® RDT Hands-on Lab
Michelle Holley
 
PPT
Process and Threads in Linux - PPT
QUONTRASOLUTIONS
 
PPTX
eBPF Basics
Michael Kehoe
 
PPTX
Linux Kernel Booting Process (1) - For NLKB
shimosawa
 
PDF
Programming Embedded linux
Liran Ben Haim
 
PDF
eBPF - Rethinking the Linux Kernel
Thomas Graf
 
PDF
I2C Subsystem In Linux-2.6.24
Varun Mahajan
 
Linux Kernel Live Patching
GlobalLogic Ukraine
 
Intel® RDT Hands-on Lab
Michelle Holley
 
Process and Threads in Linux - PPT
QUONTRASOLUTIONS
 
eBPF Basics
Michael Kehoe
 
Linux Kernel Booting Process (1) - For NLKB
shimosawa
 
Programming Embedded linux
Liran Ben Haim
 
eBPF - Rethinking the Linux Kernel
Thomas Graf
 
I2C Subsystem In Linux-2.6.24
Varun Mahajan
 

What's hot (20)

PDF
Introduction to eBPF
RogerColl2
 
PDF
Linux Linux Traffic Control
SUSE Labs Taipei
 
PPTX
Cfgmgmtcamp 2023 — eBPF Superpowers
Raphaël PINSON
 
PDF
Introduction to Modern U-Boot
GlobalLogic Ukraine
 
PDF
Hands-on ethernet driver
SUSE Labs Taipei
 
PPTX
Linux Kernel Booting Process (2) - For NLKB
shimosawa
 
PDF
Arm device tree and linux device drivers
Houcheng Lin
 
PDF
Everything You Ever Wanted to Know About Move Semantics, Howard Hinnant, Accu...
Ripple Labs
 
PDF
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
 
PDF
Docker, Linux Containers (LXC), and security
Jérôme Petazzoni
 
PPTX
UNIX Operating System
Fatima Qayyum
 
PDF
Toolchain
Anil Kumar Pugalia
 
PDF
Kdump and the kernel crash dump analysis
Buland Singh
 
PDF
Arquitetura de Memoria do PostgreSQL
Raul Oliveira
 
PPTX
Linux Network Stack
Adrien Mahieux
 
PDF
Receive side scaling (RSS) with eBPF in QEMU and virtio-net
Yan Vugenfirer
 
PDF
In-memory OLTP storage with persistence and transaction support
Alexander Korotkov
 
PPTX
Introduction Linux Device Drivers
NEEVEE Technologies
 
PDF
Introduction to eBPF and XDP
lcplcp1
 
Introduction to eBPF
RogerColl2
 
Linux Linux Traffic Control
SUSE Labs Taipei
 
Cfgmgmtcamp 2023 — eBPF Superpowers
Raphaël PINSON
 
Introduction to Modern U-Boot
GlobalLogic Ukraine
 
Hands-on ethernet driver
SUSE Labs Taipei
 
Linux Kernel Booting Process (2) - For NLKB
shimosawa
 
Arm device tree and linux device drivers
Houcheng Lin
 
Everything You Ever Wanted to Know About Move Semantics, Howard Hinnant, Accu...
Ripple Labs
 
U-Boot - An universal bootloader
Emertxe Information Technologies Pvt Ltd
 
Docker, Linux Containers (LXC), and security
Jérôme Petazzoni
 
UNIX Operating System
Fatima Qayyum
 
Kdump and the kernel crash dump analysis
Buland Singh
 
Arquitetura de Memoria do PostgreSQL
Raul Oliveira
 
Linux Network Stack
Adrien Mahieux
 
Receive side scaling (RSS) with eBPF in QEMU and virtio-net
Yan Vugenfirer
 
In-memory OLTP storage with persistence and transaction support
Alexander Korotkov
 
Introduction Linux Device Drivers
NEEVEE Technologies
 
Introduction to eBPF and XDP
lcplcp1
 
Ad

Viewers also liked (16)

PDF
Learning notes on Open Source License
SZ Lin
 
PPTX
y2038 issue
SZ Lin
 
PPTX
Distributed Compiler Icecc
SZ Lin
 
PPTX
Fast boot
SZ Lin
 
PPTX
Embedded Linux/ Debian with ARM64 Platform
SZ Lin
 
PDF
Debian 套件打包教學指南 - 繁體中文翻譯
SZ Lin
 
PDF
Cellular technology with Embedded Linux - COSCUP 2016
SZ Lin
 
PDF
Debian 套件打包教學指南 v0.19 - 繁體中文翻譯
SZ Lin
 
PDF
Oracle ksplice
Sabinkari Vijay
 
PDF
Implementing a Security strategy in IoT, Practical example Automotive Grade L...
LibreCon
 
PDF
TIZEN Application Validation
Ryo Jin
 
PDF
Contributing to Automotive Grade Linux (AGL) and GENIVI Development Platform ...
Leon Anavi
 
ODP
Introduction to Optee (26 may 2016)
Yannick Gicquel
 
PPTX
LAS16-203: Platform security architecture for embedded devices
Linaro
 
PDF
Q4.11: Introduction to eMMC
Linaro
 
PDF
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
Linaro
 
Learning notes on Open Source License
SZ Lin
 
y2038 issue
SZ Lin
 
Distributed Compiler Icecc
SZ Lin
 
Fast boot
SZ Lin
 
Embedded Linux/ Debian with ARM64 Platform
SZ Lin
 
Debian 套件打包教學指南 - 繁體中文翻譯
SZ Lin
 
Cellular technology with Embedded Linux - COSCUP 2016
SZ Lin
 
Debian 套件打包教學指南 v0.19 - 繁體中文翻譯
SZ Lin
 
Oracle ksplice
Sabinkari Vijay
 
Implementing a Security strategy in IoT, Practical example Automotive Grade L...
LibreCon
 
TIZEN Application Validation
Ryo Jin
 
Contributing to Automotive Grade Linux (AGL) and GENIVI Development Platform ...
Leon Anavi
 
Introduction to Optee (26 may 2016)
Yannick Gicquel
 
LAS16-203: Platform security architecture for embedded devices
Linaro
 
Q4.11: Introduction to eMMC
Linaro
 
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
Linaro
 
Ad

Similar to 淺談 Live patching technology (20)

PDF
Testing real-time Linux. What to test and how
Chirag Jog
 
PDF
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
Linaro
 
PDF
Linux Foundation Mentorship Sessions - Kernel Livepatch: An Introduction
Marcos de Souza
 
PPTX
Real time Linux
navid ashrafi
 
PDF
An Essential Relationship between Real-time and Resource Partitioning
Yoshitake Kobayashi
 
PDF
Polyteda Power DRC/LVS July 2016
Oleksandra Nazola
 
PDF
PowerDRC/LVS 2.2 released by POLYTEDA
Alexander Grudanov
 
PPTX
RTDroid_Presentation
Aswin Bharadwaj
 
PDF
Polyteda: Power DRC/LVS, October 2016
Oleksandra Nazola
 
PPT
POLYTEDA: Power DRC/LVS, June 2017
Oleksandra Nazola
 
PDF
Porting_uClinux_CELF2008_Griffin
Peter Griffin
 
PDF
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Michelle Holley
 
PDF
Linux conna kpatch-without-stopmachine-fixed
Tommy Lee
 
PPTX
ProjectVault[VivekKumar_CS-C_6Sem_MIT].pptx
Vivek Kumar
 
PDF
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...
Anne Nicolas
 
PDF
Trends in Systems and How to Get Efficient Performance
inside-BigData.com
 
PDF
LCA14: LCA14-412: GPGPU on ARM SoC session
Linaro
 
PDF
DPDK Integration: A Product's Journey - Roger B. Melton
harryvanhaaren
 
PDF
Introduction to Civil Infrastructure Platform
SZ Lin
 
PDF
Parallel Vector Tile-Optimized Library (PVTOL) Architecture-v3.pdf
Slide_N
 
Testing real-time Linux. What to test and how
Chirag Jog
 
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
Linaro
 
Linux Foundation Mentorship Sessions - Kernel Livepatch: An Introduction
Marcos de Souza
 
Real time Linux
navid ashrafi
 
An Essential Relationship between Real-time and Resource Partitioning
Yoshitake Kobayashi
 
Polyteda Power DRC/LVS July 2016
Oleksandra Nazola
 
PowerDRC/LVS 2.2 released by POLYTEDA
Alexander Grudanov
 
RTDroid_Presentation
Aswin Bharadwaj
 
Polyteda: Power DRC/LVS, October 2016
Oleksandra Nazola
 
POLYTEDA: Power DRC/LVS, June 2017
Oleksandra Nazola
 
Porting_uClinux_CELF2008_Griffin
Peter Griffin
 
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Michelle Holley
 
Linux conna kpatch-without-stopmachine-fixed
Tommy Lee
 
ProjectVault[VivekKumar_CS-C_6Sem_MIT].pptx
Vivek Kumar
 
Kernel Recipes 2018 - Live (Kernel) Patching: status quo and status futurus -...
Anne Nicolas
 
Trends in Systems and How to Get Efficient Performance
inside-BigData.com
 
LCA14: LCA14-412: GPGPU on ARM SoC session
Linaro
 
DPDK Integration: A Product's Journey - Roger B. Melton
harryvanhaaren
 
Introduction to Civil Infrastructure Platform
SZ Lin
 
Parallel Vector Tile-Optimized Library (PVTOL) Architecture-v3.pdf
Slide_N
 

More from SZ Lin (14)

PDF
OpenChain 電信 SBOM 指引 1.0:強化軟體供應鏈透明度與安全性
SZ Lin
 
PDF
Industry Insights Common Pitfalls and Key Considerations in Using Software Bi...
SZ Lin
 
PDF
Select, manage, and backport the long term stable kernels
SZ Lin
 
PPTX
Manage kernel vulnerabilities in the software development lifecycle
SZ Lin
 
PPTX
OpenChain 2.0 specification in a nutshell
SZ Lin
 
PPTX
OpenChain - The Industry Standard for Open Source Compliance
SZ Lin
 
PPTX
Design, Build,and Maintain the Embedded Linux Platform
SZ Lin
 
PDF
[ELCE] Activities of super long term support kernel workgroup in civil infras...
SZ Lin
 
PDF
Using open source software to build an industrial grade embedded linux platfo...
SZ Lin
 
PDF
Take a step forward from user to maintainer or developer in open source secur...
SZ Lin
 
PPTX
Software update for embedded systems
SZ Lin
 
DOCX
OpenChain spec 2.0 繁體中文
SZ Lin
 
PDF
Long-term Maintenance Model of Embedded Industrial Linux Distribution
SZ Lin
 
PDF
Building, deploying and testing an industrial linux platform @ Open source su...
SZ Lin
 
OpenChain 電信 SBOM 指引 1.0:強化軟體供應鏈透明度與安全性
SZ Lin
 
Industry Insights Common Pitfalls and Key Considerations in Using Software Bi...
SZ Lin
 
Select, manage, and backport the long term stable kernels
SZ Lin
 
Manage kernel vulnerabilities in the software development lifecycle
SZ Lin
 
OpenChain 2.0 specification in a nutshell
SZ Lin
 
OpenChain - The Industry Standard for Open Source Compliance
SZ Lin
 
Design, Build,and Maintain the Embedded Linux Platform
SZ Lin
 
[ELCE] Activities of super long term support kernel workgroup in civil infras...
SZ Lin
 
Using open source software to build an industrial grade embedded linux platfo...
SZ Lin
 
Take a step forward from user to maintainer or developer in open source secur...
SZ Lin
 
Software update for embedded systems
SZ Lin
 
OpenChain spec 2.0 繁體中文
SZ Lin
 
Long-term Maintenance Model of Embedded Industrial Linux Distribution
SZ Lin
 
Building, deploying and testing an industrial linux platform @ Open source su...
SZ Lin
 

Recently uploaded (20)

PDF
This slide provides an overview Technology
mineshkharadi333
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
The Power of IoT Sensor Integration in Smart Infrastructure and Automation.pptx
Rejig Digital
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PPTX
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Test Bank, Solutions for Java How to Program, An Objects-Natural Approach, 12...
famaw19526
 
PDF
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
This slide provides an overview Technology
mineshkharadi333
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
The Power of IoT Sensor Integration in Smart Infrastructure and Automation.pptx
Rejig Digital
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Doc9.....................................
SofiaCollazos
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
C Programming Basics concept krnppt.pptx
Karan Prajapat
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
Software Development Company | KodekX
KodekX
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Test Bank, Solutions for Java How to Program, An Objects-Natural Approach, 12...
famaw19526
 
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Software Development Methodologies in 2025
KodekX
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 

淺談 Live patching technology